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