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