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. What are the only two access modifiers valid for a Class?
default and public. Protected and private modifiers are not permissible and will give a compile time error.
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.
The class must be abstract in order to have any abstract methods (or it could be an interface rather than a class).
When the class is instantiated (not at compile or run time).
2. What IEEE standard does using strictfp conform to?
enum EnumName { VALUE1 - VALUE 2 - VALUEX }; Take special note of the ending semicolon - which is optional.
On either side of the variable name - e.g.: String [] var; String var [];
The field 'aNumber' is public - static and final. The value cannot be changed -- it is a constant.
IEEE 754
3. What is the length in bytes of type 'long' - and what is it's maximum size?
Compilation. Classes can't be modified as protected (or private).
No - the type cannot change - only the object to which it points can change.
On either side of the variable name - e.g.: String [] var; String var [];
8 bytes - 2^63 -1.
4. Can an abstract class have a final method?
enum EnumName { VALUE1 - VALUE 2 - VALUEX }; Take special note of the ending semicolon - which is optional.
public - final - and static. However - these modifiers are implicit and do not have to be typed. Interfaces only have Constants.
Yes - as long as the final method has code in curly braces.
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.
5. What access level does the following interface method have? void getSomething(); public.
6. Do Enums have to be within an existing class?
No limit.
Yes - as long as the final method has code in curly braces.
No - they can be their own file.
8 bytes - 2^63 -1.
7. Which of the three non-access modifiers (strictfp - final - abstract) can and can't be used together in a class declaration?
8. What is the length in bytes of type 'int' - and what is it's maximum size?
The argument cannot be reassigned to a different object/value within the method.
4 bytes - 2^31 - 1.
The field 'aNumber' is public - static and final. The value cannot be changed -- it is a constant.
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.
9. What is the effect of making a method argument final?
EnumName.VALUE;
Object type - ellipsis - object reference variable. e.g. doStuff(String ... necklace) { }
2 Bytes - 2^15 - 1.
The argument cannot be reassigned to a different object/value within the method.
10. If a class is abstract - do the methods which ares supposed to be abstract too need to be marked 'abstract'?
11. 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'?
HiThereSally.java because the file name must exactly match the public class name (excepting the .java extension).
strictfp - final - and abstract
No limit.
The original can be overriden if is public or protected and not final.
12. Local ________ can be marked final
4 bytes - 2^31 - 1.
Either the same or a SUBTYPE of the original method's return type.
variables
The field 'aNumber' is public - static and final. The value cannot be changed -- it is a constant.
13. At what point will you get an error if an interface method is 'protected' or 'private'?
64 bits.
At the end of the list.
Compilation.
Public and Abstract
14. 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'?
strictfp and final are legal - strictfp and abstract are legal - but you can't put final and abstract together.
In the same <i>package</i> it can be public - protected - or default and cannot be final or private.
EnumName.VALUE;
Subtype.
15. You cannot _____ a static method
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.
byte - short - int - long - float - double - boolean - and char
modified with strictfp
override
16. 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?
byte - short - int - long - float - double - boolean - and char
Subtype.
final - abstract - static - synchronized - native - & strictfp
Public and Abstract
17. What kinds of exceptions can an overriding method throw that the original does not have?
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.
An unchecked exceptions.
the same file
At compilation.
18. How many public classes can be defined in one source code file?
Only one public class
public - final - and static. However - these modifiers are implicit and do not have to be typed. Interfaces only have Constants.
On either side of the variable name - e.g.: String [] var; String var [];
Volatile forces the JVM to reconcile the private field with the one in master memory. Won't generally be covered on test.
19. If a class's public class declaration is something like - 'public class HiThereSally {' - what must the source code file be named? Why?
HiThereSally.java because the file name must exactly match the public class name (excepting the .java extension).
32 bits.
strictfp and final are legal - strictfp and abstract are legal - but you can't put final and abstract together.
4 bytes - 2^31 - 1.
20. Calling what method will return an Array of Enum values?
.values()
synchronized - or - native
No limit.
At compilation.
21. Is this identifier name valid? Why or why not? int 34myVar-Yes;
Volatile forces the JVM to reconcile the private field with the one in master memory. Won't generally be covered on test.
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.
No - Identifiers cannot begin with numbers - further more identifiers may not contain hyphens.
No other class can extend it.
22. How many interfaces can a class implement?
23. What is the purpose of making a field 'volatile'?
24. How many non public classes can be in any one file?
No limit.
The argument cannot be reassigned to a different object/value within the method.
Object type - ellipsis - object reference variable. e.g. doStuff(String ... necklace) { }
'native'
25. What is a 'constant specific class body' and where can you use it?
The very first line - excepting any comments.
In the same <i>package</i> it can be public - protected - or default and cannot be final or private.
Java SE 5.0
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.
26. How many arguments can an Enum constructor have?
No - Identifiers cannot begin with numbers - further more identifiers may not contain hyphens.
At compilation
Volatile forces the JVM to reconcile the private field with the one in master memory. Won't generally be covered on test.
No limit.
27. Where can the brackets for an array declaration go?
instance
enum EnumName { VALUE1 - VALUE 2 - VALUEX }; Take special note of the ending semicolon - which is optional.
The class must be abstract in order to have any abstract methods (or it could be an interface rather than a class).
On either side of the variable name - e.g.: String [] var; String var [];
28. When are class instance variables instantiated?
The original can be overriden if is public or protected and not final.
The argument cannot be reassigned to a different object/value within the method.
5.0
When the class is instantiated (not at compile or run time).
29. How many bits does a primitive 'float' hold?
No - the type cannot change - only the object to which it points can change.
To limit values to a predetermined set.
32 bits.
Public and Abstract
30. Putting abstract and final in the class declaration will give you a run-time or compile time error?
The very first line - excepting any comments.
At compilation
64 bits.
The class must be abstract in order to have any abstract methods (or it could be an interface rather than a class).
31. What is the purpose of making a method 'native'?
It cannot be more restrictive. It CAN be less restrictive than the supertype method.
final (cannot use static - final - abstract - volatile or transient)
Object type - ellipsis - object reference variable. e.g. doStuff(String ... necklace) { }
It allows platform-dependent code - like C. It can only be used to modify a method (not a class or field).
32. Can a subclass see and use inherited 'private' methods and fields?
33. What are the rules for checked exceptions in overriding a 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.
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.
No - the enum only calls it within itself.
public - final - and static. However - these modifiers are implicit and do not have to be typed. Interfaces only have Constants.
34. What is the purpose of making a method 'synchronized'?
IEEE 754
It indicates that a method can only be accessed by one thread at a time.
32 bits.
access modifiers - abstract modifier - other non-access modifiers - return type - method name - parenthesis - semi-colon. e.g.: public abstract String getName();
35. What are the built-in methods for class Object?
equals(Object) - clone() - notify() - wait(empty/long/long - int) - finalize() - getClass() - hashCode() - toString() - & notifyAll()
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.
modified with strictfp
default and public. Protected and private modifiers are not permissible and will give a compile time error.
36. An interface cannot extend any extendable (non-final) class - can only...
It cannot be more restrictive. It CAN be less restrictive than the supertype method.
Yes. Beware though that they point to the same object on the heap - whereas primitives maintain separate values.
extend another interface
IEEE 754
37. An interface method cannot be...
modified with strictfp
abstract
override
Compilation.
38. Can you make an overriding method more access restrictive (public to private) or less restrictive (private to public)?
Exactly the same as the original method.
It cannot be more restrictive. It CAN be less restrictive than the supertype method.
strictfp and final are legal - strictfp and abstract are legal - but you can't put final and abstract together.
Object type - ellipsis - object reference variable. e.g. doStuff(String ... necklace) { }
39. How many classes can a class extend?
No - they can be their own file.
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. ...
Only one
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.
40. What is the basic construction for calling an Enum value?
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.
EnumName.VALUE;
Only classes in the same package. The public methods are restricted by the default class level access.
64 bits.
41. What is the code format for an abstract method?
.values()
instance
access modifiers - abstract modifier - other non-access modifiers - return type - method name - parenthesis - semi-colon. e.g.: public abstract String getName();
At compilation
42. All methods in an Interface are what by default?
enum EnumName { VALUE1 - VALUE 2 - VALUEX }; Take special note of the ending semicolon - which is optional.
a method?
Public and Abstract
override
43. When would you get an error for a class declaration as follows and why? - protected class Me { }
44. What modifiers can you use with method parameters?
instance
final (cannot use static - final - abstract - volatile or transient)
No limit.
.values()
45. Where in the source code must a 'package' statement be?
The very first line - excepting any comments.
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.
Compilation.
strictfp and final are legal - strictfp and abstract are legal - but you can't put final and abstract together.
46. What kind of error (run-time or compile) do you get when trying to extend a final class?
Yes - it is. Identifiers can begin with currency symbols.
default and public. Protected and private modifiers are not permissible and will give a compile time error.
To limit values to a predetermined set.
Compilation
47. What are the seven non-access modifiers for methods?
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.
final - abstract - static - synchronized - native - & strictfp
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.
synchronized - or - native
48. Enums can be declared...
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).
strictfp and final are legal - strictfp and abstract are legal - but you can't put final and abstract together.
inside a Class
49. How many var-arg's can you have in a method signature?
synchronized - or - native
No other class can extend it.
byte - short - int - long - float - double - boolean - and char
Just one.
50. What Java version began allowing an Enum type?
Only one
No - the enum only calls it within itself.
5.0
Compilation