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