SUBJECTS
|
BROWSE
|
CAREER CENTER
|
POPULAR
|
JOIN
|
LOGIN
Business Skills
|
Soft Skills
|
Basic Literacy
|
Certifications
About
|
Help
|
Privacy
|
Terms
|
Email
Search
Test your basic knowledge |
Oracle Sun Certified Java Programmer
Start Test
Study First
Subjects
:
certifications
,
it-skills
Instructions:
Answer 50 questions in 15 minutes.
If you are not ready to take this test, you can
study here
.
Match each statement with the correct term.
Don't refresh. All questions and answers are randomly picked and ordered every time you load a test.
This is a study tool. The 3 wrong answers for each question are randomly chosen from answers to other questions. So, you might find at times the answers obvious, but you will see it re-enforces your understanding as you take the test each time.
1. Where can the brackets for an array declaration go?
No. Only the parent (superclass) can access it's own private methods and fields.
Yes. Abstract methods must be marked as abstract - even if the class is abstract. However this isn't true with Interfaces: all methods in an interface are by default abstract as no non-abstract methods can exist in an Interface.
default and public. Protected and private modifiers are not permissible and will give a compile time error.
On either side of the variable name - e.g.: String [] var; String var [];
2. What is the proper syntax for declaring a var-arg in a method signature?
No - Identifiers cannot begin with numbers - further more identifiers may not contain hyphens.
Either the same or a SUBTYPE of the original method's return type.
At compilation
Object type - ellipsis - object reference variable. e.g. doStuff(String ... necklace) { }
3. Putting abstract and final in the class declaration will give you a run-time or compile time error?
abstract
Volatile forces the JVM to reconcile the private field with the one in master memory. Won't generally be covered on test.
strictfp - final - and abstract
At compilation
4. Is this identifier name valid? Why or why not? int $_myVar;
Yes - it is. Identifiers can begin with currency symbols.
The override cannot throw BROADER exceptions nor NEW exceptions. If an exception is a subclass of the original exception - it can be thrown and still be an override. The override can also throw less exceptions.
No other class can extend it.
Java SE 5.0
5. What is the purpose of making a field 'transient'?
equals(Object) - clone() - notify() - wait(empty/long/long - int) - finalize() - getClass() - hashCode() - toString() - & notifyAll()
public - final - and static. However - these modifiers are implicit and do not have to be typed. Interfaces only have Constants.
Only one public class
It prevents the field from being serialized as the JVM will skip it.
6. When accessing an object you really don't have access to (it's 'private' or 'default' in another package - etc) - when will you get an error: at compilation or at run-time?
Warning
: Invalid argument supplied for foreach() in
/var/www/html/basicversity.com/show_quiz.php
on line
183
7. What is the purpose of an Enum?
modified with strictfp
To limit values to a predetermined set.
IEEE 754
Yes - as long as the final method has code in curly braces.
8. What kinds of exceptions can an overriding method throw that the original does not have?
variables
2 Bytes - 2^15 - 1.
No - they can be their own file.
An unchecked exceptions.
9. What modifiers can you use with method parameters?
access modifiers - abstract modifier - other non-access modifiers - return type - method name - parenthesis - semi-colon. e.g.: public abstract String getName();
Technically no. A 'fresh' method with the same name - return type and signature could be made in the subclass - but there is complete separation between the one in the superclass and subclass.
It allows platform-dependent code - like C. It can only be used to modify a method (not a class or field).
final (cannot use static - final - abstract - volatile or transient)
10. Enums cannot be declared inside...
The very first line - excepting any comments.
a method?
No other class can extend it.
Interface methods are always public. A lack of modifier does not make this 'default' in the typical sense of a package-only default access modifier.
11. Enums can be declared...
.values()
Compilation.
No other class can extend it.
inside a Class
12. An ________cannot be static?
interface method
Just one.
No. Only the parent (superclass) can access it's own private methods and fields.
extend another interface
13. What is the basic construction for calling an Enum value?
You must implement every abstract method in the abstract class - as well as every method defined in the interface. Except... however - if a supertype has already made implementation of the abstract methods.
EnumName.VALUE;
No - they can be their own file.
It cannot be more restrictive. It CAN be less restrictive than the supertype method.
14. What access level does the following interface method have? void getSomething(); public.
Warning
: Invalid argument supplied for foreach() in
/var/www/html/basicversity.com/show_quiz.php
on line
183
15. What three non-access modifiers can be used with a class declaration?
strictfp - final - and abstract
Yes - it is. Identifiers can begin with currency symbols.
HiThereSally.java because the file name must exactly match the public class name (excepting the .java extension).
abstract
16. Can a subclass see and use inherited 'private' methods and fields?
Warning
: Invalid argument supplied for foreach() in
/var/www/html/basicversity.com/show_quiz.php
on line
183
17. When are class instance variables instantiated?
strictfp - final - and abstract
It prevents the field from being serialized as the JVM will skip it.
When the class is instantiated (not at compile or run time).
The class must be abstract in order to have any abstract methods (or it could be an interface rather than a class).
18. What is a 'constant specific class body' and where can you use it?
Public and Abstract
You must implement every abstract method in the abstract class - as well as every method defined in the interface. Except... however - if a supertype has already made implementation of the abstract methods.
In an Enum declaration - it allows you to override an Enum default methods and values. You use it in the Enum value declaration list - just after the value in curly braces.
Either the same or a SUBTYPE of the original method's return type.
19. When you try to use a method that you don't have access to (due to 'private' etc) - when do you get an error?
5.0
8 bytes - 2^63 -1.
At compilation.
interface method
20. What are the only two access modifiers valid for a Class?
No. Only the parent (superclass) can access it's own private methods and fields.
default and public. Protected and private modifiers are not permissible and will give a compile time error.
When the class is instantiated (not at compile or run time).
Compilation. Classes can't be modified as protected (or private).
21. What is the length in bytes of type 'short' - and what is it's maximum size?
variables
Compilation.
Only one public class
2 Bytes - 2^15 - 1.
22. What Java version began allowing an Enum type?
It prevents the field from being serialized as the JVM will skip it.
5.0
No. It can throw less or no exceptions.
No - they can be their own file.
23. How many var-arg's can you have in a method signature?
'native'
Just one.
Exactly the same as the original method.
default and public. Protected and private modifiers are not permissible and will give a compile time error.
24. When overriding a method - the return type must be what?
Warning
: Invalid argument supplied for foreach() in
/var/www/html/basicversity.com/show_quiz.php
on line
183
25. An instance variable cannot be...
Compilation. Classes can't be modified as protected (or private).
HiThereSally.java because the file name must exactly match the public class name (excepting the .java extension).
It prevents the field from being serialized as the JVM will skip it.
abstract
26. Where in the source code must a 'package' statement be?
override
At compilation.
Exactly the same as the original method.
The very first line - excepting any comments.
27. What is the purpose of making a field 'volatile'?
Warning
: Invalid argument supplied for foreach() in
/var/www/html/basicversity.com/show_quiz.php
on line
183
28. A reference variable can be reassigned to another object that is of the same type. It can also be reassigned to a supertype or subtype of the original type?
Subtype.
64 bits.
No other class can extend it.
Yes. Beware though that they point to the same object on the heap - whereas primitives maintain separate values.
29. Can an abstract class have a final method?
5.0
Exactly the same as the original method.
Yes - as long as the final method has code in curly braces.
The argument cannot be reassigned to a different object/value within the method.
30. Var-args have been possible since what Java version?
Java SE 5.0
variables
Yes - technically speaking.
Compile and Run time. It will normally happen at compilation - but in case the 'private' method class was changed to private/default/protected after the calling class was compiled - it will be a Run Time 'IllegalAccessError' exception.
31. All fields in an interface must have what three access & non-access modifiers?
modified with strictfp
.values()
public - final - and static. However - these modifiers are implicit and do not have to be typed. Interfaces only have Constants.
variables
32. What is the purpose of making a method 'synchronized'?
It indicates that a method can only be accessed by one thread at a time.
When the class is instantiated (not at compile or run time).
At compilation
byte - short - int - long - float - double - boolean - and char
33. Calling what method will return an Array of Enum values?
An unchecked exceptions.
No limit.
.values()
equals(Object) - clone() - notify() - wait(empty/long/long - int) - finalize() - getClass() - hashCode() - toString() - & notifyAll()
34. Where do var-args have to appear on the method parameter list?
'native'
The original can be overriden if is public or protected and not final.
equals(Object) - clone() - notify() - wait(empty/long/long - int) - finalize() - getClass() - hashCode() - toString() - & notifyAll()
At the end of the list.
35. Does an override have to throw all the exceptions of the original method?
In the same <i>package</i> it can be public - protected - or default and cannot be final or private.
HiThereSally.java because the file name must exactly match the public class name (excepting the .java extension).
abstract
No. It can throw less or no exceptions.
36. What is the code format for an abstract method?
Exactly the same as the original method.
2 Bytes - 2^15 - 1.
Object a - b - c; or Object a -b -c = new Object();
access modifiers - abstract modifier - other non-access modifiers - return type - method name - parenthesis - semi-colon. e.g.: public abstract String getName();
37. You cannot _____ a static method
strictfp - final - and abstract
override
5.0
No - the type cannot change - only the object to which it points can change.
38. How many interfaces can a class implement?
Warning
: Invalid argument supplied for foreach() in
/var/www/html/basicversity.com/show_quiz.php
on line
183
39. Enums can be declared outside a Class - but in...
Either the same or a SUBTYPE of the original method's return type.
the same file
It cannot be more restrictive. It CAN be less restrictive than the supertype method.
No other class can extend it.
40. How many classes can a class extend?
In an Enum declaration - it allows you to override an Enum default methods and values. You use it in the Enum value declaration list - just after the value in curly braces.
Yes - it is. Identifiers can begin with currency symbols.
Subtype.
Only one
41. Can a private method be overriden by a subclass?
Warning
: Invalid argument supplied for foreach() in
/var/www/html/basicversity.com/show_quiz.php
on line
183
42. What are the rules for checked exceptions in overriding a method?
It cannot be more restrictive. It CAN be less restrictive than the supertype method.
The override cannot throw BROADER exceptions nor NEW exceptions. If an exception is a subclass of the original exception - it can be thrown and still be an override. The override can also throw less exceptions.
final (cannot use static - final - abstract - volatile or transient)
On either side of the variable name - e.g.: String [] var; String var [];
43. A class is access modified as default. It's methods are access modified as 'public'. What other class files can access the methods in this class?
Yes - as long as the final method has code in curly braces.
Yes - technically speaking.
Only classes in the same package. The public methods are restricted by the default class level access.
The abstract class can never be instantiated. It must be extended to be used.
44. If a class's public class declaration is something like - 'public class HiThereSally {' - what must the source code file be named? Why?
At compilation
HiThereSally.java because the file name must exactly match the public class name (excepting the .java extension).
Either the same or a SUBTYPE of the original method's return type.
The argument cannot be reassigned to a different object/value within the method.
45. How many bits does a primitive 'float' hold?
abstract
equals(Object) - clone() - notify() - wait(empty/long/long - int) - finalize() - getClass() - hashCode() - toString() - & notifyAll()
Yes - it is. Identifiers can begin with currency symbols.
32 bits.
46. What is the length in bytes of type 'long' - and what is it's maximum size?
8 bytes - 2^63 -1.
Public and Abstract
No - they can be their own file.
final - abstract - static - synchronized - native - & strictfp
47. Can a file have no public classes?
Subtype.
Yes - technically speaking.
2 Bytes - 2^15 - 1.
Only one public class
48. If a class is abstract - do the methods which ares supposed to be abstract too need to be marked 'abstract'?
Warning
: Invalid argument supplied for foreach() in
/var/www/html/basicversity.com/show_quiz.php
on line
183
49. Local ________ can be marked final
Compile and Run time. It will normally happen at compilation - but in case the 'private' method class was changed to private/default/protected after the calling class was compiled - it will be a Run Time 'IllegalAccessError' exception.
variables
No - Identifiers cannot begin with numbers - further more identifiers may not contain hyphens.
Technically no. A 'fresh' method with the same name - return type and signature could be made in the subclass - but there is complete separation between the one in the superclass and subclass.
50. Can multiple non-primitive variables be defined in one line?
No limit.
Yes. Abstract methods must be marked as abstract - even if the class is abstract. However this isn't true with Interfaces: all methods in an interface are by default abstract as no non-abstract methods can exist in an Interface.
The argument cannot be reassigned to a different object/value within the method.
Yes. Beware though that they point to the same object on the heap - whereas primitives maintain separate values.
Can you answer 50 questions in 15 minutes?
Let me suggest you:
Browse all subjects
Browse all tests
Most popular tests
Major Subjects
Tests & Exams
AP
CLEP
DSST
GRE
SAT
GMAT
Certifications
CISSP go to https://www.isc2.org/
PMP
ITIL
RHCE
MCTS
More...
IT Skills
Android Programming
Data Modeling
Objective C Programming
Basic Python Programming
Adobe Illustrator
More...
Business Skills
Advertising Techniques
Business Accounting Basics
Business Strategy
Human Resource Management
Marketing Basics
More...
Soft Skills
Body Language
People Skills
Public Speaking
Persuasion
Job Hunting And Resumes
More...
Vocabulary
GRE Vocab
SAT Vocab
TOEFL Essential Vocab
Basic English Words For All
Global Words You Should Know
Business English
More...
Languages
AP German Vocab
AP Latin Vocab
SAT Subject Test: French
Italian Survival
Norwegian Survival
More...
Engineering
Audio Engineering
Computer Science Engineering
Aerospace Engineering
Chemical Engineering
Structural Engineering
More...
Health Sciences
Basic Nursing Skills
Health Science Language Fundamentals
Veterinary Technology Medical Language
Cardiology
Clinical Surgery
More...
English
Grammar Fundamentals
Literary And Rhetorical Vocab
Elements Of Style Vocab
Introduction To English Major
Complete Advanced Sentences
Literature
Homonyms
More...
Math
Algebra Formulas
Basic Arithmetic: Measurements
Metric Conversions
Geometric Properties
Important Math Facts
Number Sense Vocab
Business Math
More...
Other Major Subjects
Science
Economics
History
Law
Performing-arts
Cooking
Logic & Reasoning
Trivia
Browse all subjects
Browse all tests
Most popular tests