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