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