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