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