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