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. An ________cannot be static?
interface method
override
No. It can throw less or no exceptions.
Public and Abstract
2. How many bits does a primitive 'float' hold?
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.
32 bits.
Either the same or a SUBTYPE of the original method's return type.
Yes - as long as the final method has code in curly braces.
3. What is the purpose of making a field 'volatile'?
4. An ________ variable cannot be marked strictfp
interface method
Yes - as long as the final method has code in curly braces.
instance
abstract
5. Is this identifier name valid? Why or why not? int $_myVar;
variables
inside a Class
final (cannot use static - final - abstract - volatile or transient)
Yes - it is. Identifiers can begin with currency symbols.
6. Can a subclass see and use inherited 'private' methods and fields?
7. What occurs when a class is marked as 'final'?
inside a Class
.values()
No other class can extend it.
To limit values to a predetermined set.
8. What Java version began allowing an Enum type?
IEEE 754
5.0
No - the type cannot change - only the object to which it points can change.
Yes. Beware though that they point to the same object on the heap - whereas primitives maintain separate values.
9. 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?
10. Local ________ can be marked final
variables
At compilation.
Public and Abstract
Exactly the same as the original method.
11. Can multiple non-primitive variables be defined in one line?
Yes. Beware though that they point to the same object on the heap - whereas primitives maintain separate values.
Yes - it is. Identifiers can begin with currency symbols.
On either side of the variable name - e.g.: String [] var; String var [];
a method?
12. How many public classes can be defined in one source code file?
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.
Only one public class
Yes. Beware though that they point to the same object on the heap - whereas primitives maintain separate values.
The class must be abstract in order to have any abstract methods (or it could be an interface rather than a class).
13. What is the purpose of making a class 'abstract'?
At compilation
The very first line - excepting any comments.
8 bytes - 2^63 -1.
The abstract class can never be instantiated. It must be extended to be used.
14. Does an override have to throw all the exceptions of the original method?
No. It can throw less or no exceptions.
In the same <i>package</i> it can be public - protected - or default and cannot be final or private.
Compilation
The abstract class can never be instantiated. It must be extended to be used.
15. What must you do when extending an abstract class or implementing any interface?
No other class can extend it.
No - the enum only calls it within itself.
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.
Public and Abstract
16. What is a 'constant specific class body' and where can you use it?
instance
Yes - technically speaking.
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.
final (cannot use static - final - abstract - volatile or transient)
17. You cannot _____ a static method
8 bytes - 2^63 -1.
override
interface method
variables
18. Once a reference variable is defined - can it's object type be changed?
At compilation
The original can be overriden if is public or protected and not final.
No - the type cannot change - only the object to which it points can change.
.values()
19. Can a file have no public classes?
Yes - technically speaking.
The argument cannot be reassigned to a different object/value within the method.
Java SE 5.0
On either side of the variable name - e.g.: String [] var; String var [];
20. 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?
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.
No. Only the parent (superclass) can access it's own private methods and fields.
Only classes in the same package. The public methods are restricted by the default class level access.
8 bytes - 2^63 -1.
21. What kind of error (run-time or compile) do you get when trying to extend a final class?
Compilation
default and public. Protected and private modifiers are not permissible and will give a compile time error.
The argument cannot be reassigned to a different object/value within the method.
Either the same or a SUBTYPE of the original method's return type.
22. What is the purpose of making a field 'transient'?
.values()
Public and Abstract
It prevents the field from being serialized as the JVM will skip it.
Only one public class
23. What is the proper syntax for declaring a var-arg in a method signature?
equals(Object) - clone() - notify() - wait(empty/long/long - int) - finalize() - getClass() - hashCode() - toString() - & notifyAll()
Java SE 5.0
No limit.
Object type - ellipsis - object reference variable. e.g. doStuff(String ... necklace) { }
24. What is the purpose of making a method 'synchronized'?
It indicates that a method can only be accessed by one thread at a time.
enum EnumName { VALUE1 - VALUE 2 - VALUEX }; Take special note of the ending semicolon - which is optional.
The abstract class can never be instantiated. It must be extended to be used.
The original can be overriden if is public or protected and not final.
25. When overriding a method - the argument list (i.e. signature) must be what?
No - the enum only calls it within itself.
synchronized - or - native
Exactly the same as the original method.
Either the same or a SUBTYPE of the original method's return type.
26. Can you make an overriding method more access restrictive (public to private) or less restrictive (private to public)?
No other class can extend it.
It cannot be more restrictive. It CAN be less restrictive than the supertype method.
interface method
a method?
27. If a class is abstract - do the methods which ares supposed to be abstract too need to be marked 'abstract'?
28. An instance variable cannot be marked...
synchronized - or - native
The class must be abstract in order to have any abstract methods (or it could be an interface rather than a class).
final - abstract - static - synchronized - native - & strictfp
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.
29. What is the basic construction for calling an Enum value?
No - the type cannot change - only the object to which it points can change.
EnumName.VALUE;
access modifiers - abstract modifier - other non-access modifiers - return type - method name - parenthesis - semi-colon. e.g.: public abstract String getName();
Subtype.
30. What is the purpose of making a method 'native'?
final (cannot use static - final - abstract - volatile or transient)
No other class can extend it.
It allows platform-dependent code - like C. It can only be used to modify a method (not a class or field).
HiThereSally.java because the file name must exactly match the public class name (excepting the .java extension).
31. When would you get an error for a class declaration as follows and why? - protected class Me { }
32. An original method that will be overriden by a class in the same package as the original could have what access levels and still be considered an 'override'?
In the same <i>package</i> it can be public - protected - or default and cannot be final or private.
4 bytes - 2^31 - 1.
Only classes in the same package. The public methods are restricted by the default class level access.
5.0
33. Calling what method will return an Array of Enum values?
'native'
.values()
access modifiers - abstract modifier - other non-access modifiers - return type - method name - parenthesis - semi-colon. e.g.: public abstract String getName();
EnumName.VALUE;
34. An interface method cannot be modified as...
35. Can an abstract class have a final method?
The argument cannot be reassigned to a different object/value within the method.
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.
interface method
Yes - as long as the final method has code in curly braces.
36. All methods in an Interface are what by default?
No. Only the parent (superclass) can access it's own private methods and fields.
At compilation.
Public and Abstract
abstract
37. What is the most basic construction for an Enum?
final - abstract - static - synchronized - native - & strictfp
enum EnumName { VALUE1 - VALUE 2 - VALUEX }; Take special note of the ending semicolon - which is optional.
instance
Exactly the same as the original method.
38. If a class's public class declaration is something like - 'public class HiThereSally {' - what must the source code file be named? Why?
equals(Object) - clone() - notify() - wait(empty/long/long - int) - finalize() - getClass() - hashCode() - toString() - & notifyAll()
It cannot be more restrictive. It CAN be less restrictive than the supertype method.
HiThereSally.java because the file name must exactly match the public class name (excepting the .java extension).
final - abstract - static - synchronized - native - & strictfp
39. Putting abstract and final in the class declaration will give you a run-time or compile time error?
synchronized - or - native
32 bits.
At compilation
IEEE 754
40. When overriding a method - the return type must be what?
41. 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?
Only classes in the same package. The public methods are restricted by the default class level access.
Subtype.
variables
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.
42. What is the effect of making a method argument final?
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.
64 bits.
Just one.
43. Where can the brackets for an array declaration go?
variables
On either side of the variable name - e.g.: String [] var; String var [];
strictfp and final are legal - strictfp and abstract are legal - but you can't put final and abstract together.
enum EnumName { VALUE1 - VALUE 2 - VALUEX }; Take special note of the ending semicolon - which is optional.
44. An interface method cannot be...
instance
modified with strictfp
Either the same or a SUBTYPE of the original method's return type.
The very first line - excepting any comments.
45. How many bits does a primitive 'double' hold?
64 bits.
variables
inside a Class
It prevents the field from being serialized as the JVM will skip it.
46. When are class instance variables instantiated?
instance
When the class is instantiated (not at compile or run time).
EnumName.VALUE;
Compilation
47. What access level does the following interface method have? void getSomething(); public.
48. Which of the three non-access modifiers (strictfp - final - abstract) can and can't be used together in a class declaration?
49. Do Enums have to be within an existing class?
IEEE 754
At compilation.
No - they can be their own file.
Object a - b - c; or Object a -b -c = new Object();
50. Enums can be declared outside a Class - but in...
.values()
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.
No limit. Notice: Only overriden instance methods are dynamically invoked based on the real object's type. This does not apply to static methods nor instance variables. ...
the same file