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