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