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