SUBJECTS
|
BROWSE
|
CAREER CENTER
|
POPULAR
|
JOIN
|
LOGIN
Business Skills
|
Soft Skills
|
Basic Literacy
|
Certifications
About
|
Help
|
Privacy
|
Terms
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. Is this identifier name valid? Why or why not? int $_myVar;
Yes - it is. Identifiers can begin with currency symbols.
synchronized - or - native
Yes. Beware though that they point to the same object on the heap - whereas primitives maintain separate values.
No - they can be their own file.
2. Calling what method will return an Array of Enum values?
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.
An unchecked exceptions.
instance
.values()
3. What IEEE standard does using strictfp conform to?
extend another interface
IEEE 754
instance
8 bytes - 2^63 -1.
4. What Java version began allowing an Enum type?
No limit.
Yes - it is. Identifiers can begin with currency symbols.
5.0
At compilation.
5. Does an override have to throw all the exceptions of the original method?
No. It can throw less or no exceptions.
Object type - ellipsis - object reference variable. e.g. doStuff(String ... necklace) { }
Subtype.
modified with strictfp
6. All fields in an interface must have what three access & non-access modifiers?
It allows platform-dependent code - like C. It can only be used to modify a method (not a class or field).
public - final - and static. However - these modifiers are implicit and do not have to be typed. Interfaces only have Constants.
Exactly the same as the original method.
final (cannot use static - final - abstract - volatile or transient)
7. What is the code format for an abstract method?
Compilation.
Object type - ellipsis - object reference variable. e.g. doStuff(String ... necklace) { }
IEEE 754
access modifiers - abstract modifier - other non-access modifiers - return type - method name - parenthesis - semi-colon. e.g.: public abstract String getName();
8. Can multiple non-primitive variables be defined in one line?
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.
equals(Object) - clone() - notify() - wait(empty/long/long - int) - finalize() - getClass() - hashCode() - toString() - & notifyAll()
Yes. Beware though that they point to the same object on the heap - whereas primitives maintain separate values.
It allows platform-dependent code - like C. It can only be used to modify a method (not a class or field).
9. Var-args have been possible since what Java version?
No limit.
No limit.
IEEE 754
Java SE 5.0
10. What access level does the following interface method have? void getSomething(); public.
11. Can an abstract class have a final method?
synchronized - or - native
2 Bytes - 2^15 - 1.
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.
Yes - as long as the final method has code in curly braces.
12. How many public classes can be defined in one source code file?
Just one.
Compilation. Classes can't be modified as protected (or private).
Only one public class
Volatile forces the JVM to reconcile the private field with the one in master memory. Won't generally be covered on test.
13. If an Enum has a constructor - can you call that constructor?
No - the enum only calls it within itself.
No. It can throw less or no exceptions.
a method?
Exactly the same as the original method.
14. What must you do when extending an abstract class or implementing any interface?
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.
In the same <i>package</i> it can be public - protected - or default and cannot be final or private.
No limit.
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.
15. Enums cannot be declared inside...
The class must be abstract in order to have any abstract methods (or it could be an interface rather than a class).
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 - the enum only calls it within itself.
a method?
16. What is the most basic construction for an Enum?
At compilation.
enum EnumName { VALUE1 - VALUE 2 - VALUEX }; Take special note of the ending semicolon - which is optional.
Public and Abstract
strictfp and final are legal - strictfp and abstract are legal - but you can't put final and abstract together.
17. Where do var-args have to appear on the method parameter list?
variables
Object type - ellipsis - object reference variable. e.g. doStuff(String ... necklace) { }
At the end of the list.
interface method
18. Local ________ can be marked final
Exactly the same as the original method.
extend another interface
variables
The field 'aNumber' is public - static and final. The value cannot be changed -- it is a constant.
19. What is the effect of making a method argument final?
Yes. Beware though that they point to the same object on the heap - whereas primitives maintain separate values.
Only one
The argument cannot be reassigned to a different object/value within the method.
access modifiers - abstract modifier - other non-access modifiers - return type - method name - parenthesis - semi-colon. e.g.: public abstract String getName();
20. How many bits does a primitive 'float' hold?
32 bits.
variables
No - the enum only calls it within itself.
Volatile forces the JVM to reconcile the private field with the one in master memory. Won't generally be covered on test.
21. How many arguments can an Enum constructor have?
Yes - as long as the final method has code in curly braces.
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. ...
4 bytes - 2^31 - 1.
No limit.
22. How many non public classes can be in any one file?
No limit.
64 bits.
In the same <i>package</i> it can be public - protected - or default and cannot be final or private.
32 bits.
23. Once a reference variable is defined - can it's object type be changed?
Just one.
'native'
final - abstract - static - synchronized - native - & strictfp
No - the type cannot change - only the object to which it points can change.
24. 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?
modified with strictfp
5.0
Subtype.
No. It can throw less or no exceptions.
25. 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?
26. What are the rules for checked exceptions in overriding a method?
No limit.
No. Only the parent (superclass) can access it's own private methods and fields.
public - final - and static. However - these modifiers are implicit and do not have to be typed. Interfaces only have Constants.
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.
27. How many bits does a primitive 'double' hold?
No other class can extend it.
64 bits.
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.
access modifiers - abstract modifier - other non-access modifiers - return type - method name - parenthesis - semi-colon. e.g.: public abstract String getName();
28. An original method that will be overriden by a class not in the same package as the original could have what access levels and still be considered an 'override'?
Only classes in the same package. The public methods are restricted by the default class level access.
The original can be overriden if is public or protected and not final.
The field 'aNumber' is public - static and final. The value cannot be changed -- it is a constant.
byte - short - int - long - float - double - boolean - and char
29. What are the eight primitive types in Java?
byte - short - int - long - float - double - boolean - and char
strictfp - final - and abstract
Compilation
At the end of the list.
30. 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?
Java SE 5.0
No - the type cannot change - only the object to which it points can change.
'native'
Only classes in the same package. The public methods are restricted by the default class level access.
31. When would you get an error for a class declaration as follows and why? - protected class Me { }
32. When overriding a method - the return type must be what?
33. Which of the three non-access modifiers (strictfp - final - abstract) can and can't be used together in a class declaration?
34. An interface method cannot be...
modified with strictfp
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.
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.
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.
35. When are class instance variables instantiated?
At compilation.
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.
modified with strictfp
When the class is instantiated (not at compile or run time).
36. An ________ variable cannot be marked strictfp
inside a Class
The abstract class can never be instantiated. It must be extended to be used.
5.0
instance
37. What is the length in bytes of type 'long' - and what is it's maximum size?
8 bytes - 2^63 -1.
final - abstract - static - synchronized - native - & strictfp
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.
No - they can be their own file.
38. What kinds of exceptions can an overriding method throw that the original does not have?
No limit.
When the class is instantiated (not at compile or run time).
a method?
An unchecked exceptions.
39. What is the proper syntax for declaring a var-arg in a method signature?
modified with strictfp
Object type - ellipsis - object reference variable. e.g. doStuff(String ... necklace) { }
.values()
The argument cannot be reassigned to a different object/value within the method.
40. What modifiers can you use with method parameters?
Yes - technically speaking.
final (cannot use static - final - abstract - volatile or transient)
default and public. Protected and private modifiers are not permissible and will give a compile time error.
The field 'aNumber' is public - static and final. The value cannot be changed -- it is a constant.
41. Enums can be declared...
access modifiers - abstract modifier - other non-access modifiers - return type - method name - parenthesis - semi-colon. e.g.: public abstract String getName();
Compilation.
IEEE 754
inside a Class
42. 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;
An unchecked exceptions.
At compilation.
43. What is the purpose of an Enum?
public - final - and static. However - these modifiers are implicit and do not have to be typed. Interfaces only have Constants.
No limit.
To limit values to a predetermined set.
modified with strictfp
44. What is the purpose of making a field 'volatile'?
45. An interface cannot extend any extendable (non-final) class - can only...
Only one
It indicates that a method can only be accessed by one thread at a time.
extend another interface
strictfp and final are legal - strictfp and abstract are legal - but you can't put final and abstract together.
46. An interface method cannot be modified as...
47. How many classes can a class extend?
At compilation
Only one
EnumName.VALUE;
Just one.
48. Can a subclass see and use inherited 'private' methods and fields?
49. Where in the source code must a 'package' statement be?
Only one public class
variables
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 very first line - excepting any comments.
50. You cannot _____ a static method
override
The class must be abstract in order to have any abstract methods (or it could be an interface rather than a class).
Subtype.
strictfp - final - and abstract