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