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. How many interfaces can a class implement?
2. When would you get an error for a class declaration as follows and why? - protected class Me { }
3. For any method to be abstract - what must also be true about the class?
The very first line - excepting any comments.
The class must be abstract in order to have any abstract methods (or it could be an interface rather than a class).
At compilation.
Just one.
4. Does an override have to throw all the exceptions of the original method?
the same file
The class must be abstract in order to have any abstract methods (or it could be an interface rather than a class).
No. It can throw less or no exceptions.
It indicates that a method can only be accessed by one thread at a time.
5. Can a private method be overriden by a subclass?
6. What are the built-in methods for class Object?
equals(Object) - clone() - notify() - wait(empty/long/long - int) - finalize() - getClass() - hashCode() - toString() - & notifyAll()
On either side of the variable name - e.g.: String [] var; String var [];
The original can be overriden if is public or protected and not final.
Yes - as long as the final method has code in curly braces.
7. What is the length in bytes of type 'short' - and what is it's maximum size?
2 Bytes - 2^15 - 1.
default and public. Protected and private modifiers are not permissible and will give a compile time error.
Compilation
Only one public class
8. How many non public classes can be in any one file?
No limit.
On either side of the variable name - e.g.: String [] var; String var [];
IEEE 754
An unchecked exceptions.
9. What modifiers can you use with method parameters?
equals(Object) - clone() - notify() - wait(empty/long/long - int) - finalize() - getClass() - hashCode() - toString() - & notifyAll()
final (cannot use static - final - abstract - volatile or transient)
It allows platform-dependent code - like C. It can only be used to modify a method (not a class or field).
64 bits.
10. What is the purpose of making a method 'synchronized'?
Compilation. Classes can't be modified as protected (or private).
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.
Either the same or a SUBTYPE of the original method's return type.
It indicates that a method can only be accessed by one thread at a time.
11. You cannot _____ a static method
No - the enum only calls it within itself.
override
IEEE 754
The original can be overriden if is public or protected and not final.
12. Calling what method will return an Array of Enum values?
EnumName.VALUE;
.values()
No other class can extend it.
32 bits.
13. Enums cannot be declared inside...
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.
No limit.
a method?
14. What is the purpose of making a class 'abstract'?
.values()
No - the type cannot change - only the object to which it points can change.
The abstract class can never be instantiated. It must be extended to be used.
No limit.
15. Do Enums have to be within an existing class?
extend another interface
abstract
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. ...
16. 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'?
When the class is instantiated (not at compile or run time).
The very first line - excepting any comments.
The original can be overriden if is public or protected and not final.
final - abstract - static - synchronized - native - & strictfp
17. What Java version began allowing an Enum type?
EnumName.VALUE;
4 bytes - 2^31 - 1.
5.0
No - Identifiers cannot begin with numbers - further more identifiers may not contain hyphens.
18. What are the eight primitive types in Java?
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.
.values()
The abstract class can never be instantiated. It must be extended to be used.
byte - short - int - long - float - double - boolean - and char
19. What three non-access modifiers can be used with a class declaration?
8 bytes - 2^63 -1.
strictfp - final - and abstract
override
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.
20. Is this identifier name valid? Why or why not? int 34myVar-Yes;
final (cannot use static - final - abstract - volatile or transient)
modified with strictfp
No - Identifiers cannot begin with numbers - further more identifiers may not contain hyphens.
synchronized - or - native
21. An ________cannot be static?
Java SE 5.0
EnumName.VALUE;
interface method
At compilation
22. Var-args have been possible since what Java version?
The abstract class can never be instantiated. It must be extended to be used.
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. ...
Java SE 5.0
In the same <i>package</i> it can be public - protected - or default and cannot be final or private.
23. An interface method cannot be...
Exactly the same as the original method.
No - Identifiers cannot begin with numbers - further more identifiers may not contain hyphens.
Subtype.
modified with strictfp
24. All fields in an interface must have what three access & non-access modifiers?
'native'
public - final - and static. However - these modifiers are implicit and do not have to be typed. Interfaces only have Constants.
instance
.values()
25. What are the seven non-access modifiers for methods?
An unchecked exceptions.
At compilation
No limit.
final - abstract - static - synchronized - native - & strictfp
26. How many var-arg's can you have in a method signature?
Compilation.
Just one.
variables
5.0
27. Is this identifier name valid? Why or why not? int $_myVar;
Yes - it is. Identifiers can begin with currency symbols.
No limit.
final (cannot use static - final - abstract - volatile or transient)
No - the type cannot change - only the object to which it points can change.
28. What must you do when extending an abstract class or implementing any interface?
On either side of the variable name - e.g.: String [] var; String var [];
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.
64 bits.
29. An instance variable cannot be...
It indicates that a method can only be accessed by one thread at a time.
abstract
2 Bytes - 2^15 - 1.
In the same <i>package</i> it can be public - protected - or default and cannot be final or private.
30. What access level does the following interface method have? void getSomething(); public.
31. What is the basic construction for calling an Enum value?
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.
EnumName.VALUE;
Volatile forces the JVM to reconcile the private field with the one in master memory. Won't generally be covered on test.
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. Can multiple non-primitive variables be defined in one line?
The abstract class can never be instantiated. It must be extended to be used.
No - they can be their own file.
Yes. Beware though that they point to the same object on the heap - whereas primitives maintain separate values.
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.
33. What is the purpose of making a field 'volatile'?
34. What occurs when a class is marked as 'final'?
Just one.
No other class can extend it.
Yes - as long as the final method has code in curly braces.
EnumName.VALUE;
35. How many bits does a primitive 'float' hold?
IEEE 754
32 bits.
No limit.
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.
36. All methods in an Interface are what by default?
Only one
No - Identifiers cannot begin with numbers - further more identifiers may not contain hyphens.
Public and Abstract
extend another interface
37. What is the length in bytes of type 'int' - and what is it's maximum size?
Yes - technically speaking.
4 bytes - 2^31 - 1.
Either the same or a SUBTYPE of the original method's return type.
At compilation.
38. Can you make an overriding method more access restrictive (public to private) or less restrictive (private to public)?
It cannot be more restrictive. It CAN be less restrictive than the supertype method.
a method?
strictfp and final are legal - strictfp and abstract are legal - but you can't put final and abstract together.
2 Bytes - 2^15 - 1.
39. 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.
public - final - and static. However - these modifiers are implicit and do not have to be typed. Interfaces only have Constants.
Only classes in the same package. The public methods are restricted by the default class level access.
It indicates that a method can only be accessed by one thread at a time.
40. What kind of error (run-time or compile) do you get when trying to extend a final class?
'native'
Compilation
Only one public class
.values()
41. What is the purpose of making a method 'native'?
access modifiers - abstract modifier - other non-access modifiers - return type - method name - parenthesis - semi-colon. e.g.: public abstract String getName();
It allows platform-dependent code - like C. It can only be used to modify a method (not a class or field).
Java SE 5.0
At the end of the list.
42. Putting abstract and final in the class declaration will give you a run-time or compile time error?
2 Bytes - 2^15 - 1.
modified with strictfp
final - abstract - static - synchronized - native - & strictfp
At compilation
43. Can a subclass see and use inherited 'private' methods and fields?
44. 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.
strictfp and final are legal - strictfp and abstract are legal - but you can't put final and abstract together.
32 bits.
The very first line - excepting any comments.
45. What is the code format for an abstract method?
It allows platform-dependent code - like C. It can only be used to modify a method (not a class or field).
Compilation
byte - short - int - long - float - double - boolean - and char
access modifiers - abstract modifier - other non-access modifiers - return type - method name - parenthesis - semi-colon. e.g.: public abstract String getName();
46. Can an abstract class have a final method?
Yes - as long as the final method has code in curly braces.
access modifiers - abstract modifier - other non-access modifiers - return type - method name - parenthesis - semi-colon. e.g.: public abstract String getName();
It cannot be more restrictive. It CAN be less restrictive than the supertype method.
At compilation
47. An interface method cannot be modified as...
48. 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?
No - the enum only calls it within itself.
Just one.
Only classes in the same package. The public methods are restricted by the default class level access.
64 bits.
49. Local ________ can be marked final
At the end of the list.
variables
Exactly the same as the original method.
Object a - b - c; or Object a -b -c = new Object();
50. What is the length in bytes of type 'long' - and what is it's maximum size?
the same file
8 bytes - 2^63 -1.
Compilation. Classes can't be modified as protected (or private).
Subtype.