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