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