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