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