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