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