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 subclass see and use inherited 'private' methods and fields?
2. 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.
Either the same or a SUBTYPE of the original method's return type.
8 bytes - 2^63 -1.
The argument cannot be reassigned to a different object/value within the method.
3. An interface method cannot be modified as...
4. For any method to be abstract - what must also be true about the class?
Yes. Beware though that they point to the same object on the heap - whereas primitives maintain separate values.
The class must be abstract in order to have any abstract methods (or it could be an interface rather than a class).
When the class is instantiated (not at compile or run time).
No. Only the parent (superclass) can access it's own private methods and fields.
5. If a class's public class declaration is something like - 'public class HiThereSally {' - what must the source code file be named? Why?
Yes. Beware though that they point to the same object on the heap - whereas primitives maintain separate values.
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.
Volatile forces the JVM to reconcile the private field with the one in master memory. Won't generally be covered on test.
HiThereSally.java because the file name must exactly match the public class name (excepting the .java extension).
6. What is the purpose of an Enum?
To limit values to a predetermined set.
Only one
interface method
An unchecked exceptions.
7. How many arguments can an Enum constructor have?
No limit.
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.
No - they can be their own file.
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. ...
8. An instance variable cannot be marked...
extend another interface
IEEE 754
No - they can be their own file.
synchronized - or - native
9. 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'?
instance
The original can be overriden if is public or protected and not final.
Exactly the same as the original method.
final (cannot use static - final - abstract - volatile or transient)
10. If a class is abstract - do the methods which ares supposed to be abstract too need to be marked 'abstract'?
11. How many non public classes can be in any one file?
At the end of the list.
The very first line - excepting any comments.
No limit.
interface method
12. What is the code format for an abstract method?
interface method
It prevents the field from being serialized as the JVM will skip it.
Compilation
access modifiers - abstract modifier - other non-access modifiers - return type - method name - parenthesis - semi-colon. e.g.: public abstract String getName();
13. What modifiers can you use with method parameters?
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.
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)
14. How many var-arg's can you have in a method signature?
Yes. Beware though that they point to the same object on the heap - whereas primitives maintain separate values.
Subtype.
Only one
Just one.
15. All fields in an interface must have what three access & non-access modifiers?
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.
public - final - and static. However - these modifiers are implicit and do not have to be typed. Interfaces only have Constants.
At compilation
Compilation. Classes can't be modified as protected (or private).
16. What is the effect of making a method argument final?
No - they can be their own file.
The argument cannot be reassigned to a different object/value within the method.
In the same <i>package</i> it can be public - protected - or default and cannot be final or private.
It prevents the field from being serialized as the JVM will skip it.
17. What is the purpose of making a field 'volatile'?
18. When overriding a method - the argument list (i.e. signature) must be what?
Public and Abstract
default and public. Protected and private modifiers are not permissible and will give a compile time error.
Exactly the same as the original method.
Object a - b - c; or Object a -b -c = new Object();
19. What is a 'constant specific class body' and where can you use it?
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.
interface method
.values()
strictfp - final - and abstract
20. Can you make an overriding method more access restrictive (public to private) or less restrictive (private to public)?
At compilation.
An unchecked exceptions.
No. Only the parent (superclass) can access it's own private methods and fields.
It cannot be more restrictive. It CAN be less restrictive than the supertype method.
21. Once a reference variable is defined - can it's object type be changed?
No - the type cannot change - only the object to which it points can change.
The field 'aNumber' is public - static and final. The value cannot be changed -- it is a constant.
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.
synchronized - or - native
22. What is the syntax for declaring multiple variables on one line?
Only one public class
extend another interface
No. Only the parent (superclass) can access it's own private methods and fields.
Object a - b - c; or Object a -b -c = new Object();
23. Enums can be declared...
inside a Class
At compilation
32 bits.
2 Bytes - 2^15 - 1.
24. Can multiple non-primitive variables be defined in one line?
Java SE 5.0
5.0
Yes. Beware though that they point to the same object on the heap - whereas primitives maintain separate values.
Compilation
25. Where in the source code must a 'package' statement be?
The original can be overriden if is public or protected and not final.
The field 'aNumber' is public - static and final. The value cannot be changed -- it is a constant.
Only one
The very first line - excepting any comments.
26. An instance variable cannot be...
Compilation
abstract
No limit.
The argument cannot be reassigned to a different object/value within the method.
27. An interface method cannot be...
modified with strictfp
No limit.
Volatile forces the JVM to reconcile the private field with the one in master memory. Won't generally be covered on test.
Public and Abstract
28. When would you get an error for a class declaration as follows and why? - protected class Me { }
29. What are the rules for checked exceptions in overriding 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.
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 indicates that a method can only be accessed by one thread at a time.
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.
30. What is the length in bytes of type 'long' - and what is it's maximum size?
inside a Class
extend another interface
8 bytes - 2^63 -1.
The field 'aNumber' is public - static and final. The value cannot be changed -- it is a constant.
31. What is the purpose of making a method 'synchronized'?
It indicates that a method can only be accessed by one thread at a time.
byte - short - int - long - float - double - boolean - and char
HiThereSally.java because the file name must exactly match the public class name (excepting the .java extension).
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.
32. What kinds of exceptions can an overriding method throw that the original does not have?
An unchecked exceptions.
In the same <i>package</i> it can be public - protected - or default and cannot be final or private.
4 bytes - 2^31 - 1.
It cannot be more restrictive. It CAN be less restrictive than the supertype method.
33. An interface cannot extend any extendable (non-final) class - can only...
Just one.
public - final - and static. However - these modifiers are implicit and do not have to be typed. Interfaces only have Constants.
It prevents the field from being serialized as the JVM will skip it.
extend another interface
34. What three non-access modifiers can be used with a class declaration?
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.
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.
strictfp - final - and abstract
35. What are the eight primitive types in Java?
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. ...
In the same <i>package</i> it can be public - protected - or default and cannot be final or private.
Yes - technically speaking.
byte - short - int - long - float - double - boolean - and char
36. When overriding a method - the return type must be what?
37. If an Enum has a constructor - can you call that constructor?
Public and Abstract
8 bytes - 2^63 -1.
No - the enum only calls it within itself.
strictfp and final are legal - strictfp and abstract are legal - but you can't put final and abstract together.
38. 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.
An unchecked exceptions.
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.
final - abstract - static - synchronized - native - & strictfp
39. All methods in an Interface are what by default?
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.
final - abstract - static - synchronized - native - & strictfp
the same file
Public and Abstract
40. 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?
41. What are the built-in methods for class Object?
Yes - as long as the final method has code in curly braces.
The very first line - excepting any comments.
Compilation. Classes can't be modified as protected (or private).
equals(Object) - clone() - notify() - wait(empty/long/long - int) - finalize() - getClass() - hashCode() - toString() - & notifyAll()
42. What access level does the following interface method have? void getSomething(); public.
43. Var-args have been possible since what Java version?
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 - as long as the final method has code in curly braces.
Java SE 5.0
override
44. What is the length in bytes of type 'short' - and what is it's maximum size?
2 Bytes - 2^15 - 1.
public - final - and static. However - these modifiers are implicit and do not have to be typed. Interfaces only have Constants.
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 classes in the same package. The public methods are restricted by the default class level access.
45. How many bits does a primitive 'float' hold?
abstract
Object a - b - c; or Object a -b -c = new Object();
32 bits.
.values()
46. At what point will you get an error if an interface method is 'protected' or 'private'?
No. It can throw less or no exceptions.
inside a Class
Compilation.
It allows platform-dependent code - like C. It can only be used to modify a method (not a class or field).
47. Does an override have to throw all the exceptions of the original method?
Yes - technically speaking.
No. It can throw less or no exceptions.
The original can be overriden if is public or protected and not final.
final - abstract - static - synchronized - native - & strictfp
48. What are the seven non-access modifiers for methods?
final (cannot use static - final - abstract - volatile or transient)
Exactly the same as the original 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.
final - abstract - static - synchronized - native - & strictfp
49. Do Enums have to be within an existing class?
public - final - and static. However - these modifiers are implicit and do not have to be typed. Interfaces only have Constants.
No - they can be their own file.
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).
50. Local ________ can be marked final
Yes - technically speaking.
HiThereSally.java because the file name must exactly match the public class name (excepting the .java extension).
EnumName.VALUE;
variables