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