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