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?
No - they can be their own file.
No - Identifiers cannot begin with numbers - further more identifiers may not contain hyphens.
Java SE 5.0
It prevents the field from being serialized as the JVM will skip it.
2. Can you make an overriding method more access restrictive (public to private) or less restrictive (private to public)?
inside a Class
It cannot be more restrictive. It CAN be less restrictive than the supertype method.
64 bits.
Compilation.
3. What is the purpose of making a field 'volatile'?
Warning
: Invalid argument supplied for foreach() in
/var/www/html/basicversity.com/show_quiz.php
on line
183
4. An interface method cannot be...
Just one.
modified with strictfp
Yes. Beware though that they point to the same object on the heap - whereas primitives maintain separate values.
The original can be overriden if is public or protected and not final.
5. What is the purpose of making a method 'synchronized'?
It indicates that a method can only be accessed by one thread at a time.
enum EnumName { VALUE1 - VALUE 2 - VALUEX }; Take special note of the ending semicolon - which is optional.
When the class is instantiated (not at compile or run time).
Only classes in the same package. The public methods are restricted by the default class level access.
6. What are the only two access modifiers valid for a Class?
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
default and public. Protected and private modifiers are not permissible and will give a compile time error.
At compilation.
7. Putting abstract and final in the class declaration will give you a run-time or compile time error?
No limit.
No other class can extend it.
At compilation
Only classes in the same package. The public methods are restricted by the default class level access.
8. Can a private method be overriden by a subclass?
Warning
: Invalid argument supplied for foreach() in
/var/www/html/basicversity.com/show_quiz.php
on line
183
9. What is the effect of making a method argument final?
abstract
The argument cannot be reassigned to a different object/value within the method.
No - they can be their own file.
It indicates that a method can only be accessed by one thread at a time.
10. An instance variable cannot be marked...
equals(Object) - clone() - notify() - wait(empty/long/long - int) - finalize() - getClass() - hashCode() - toString() - & notifyAll()
When the class is instantiated (not at compile or run time).
4 bytes - 2^31 - 1.
synchronized - or - native
11. 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
12. What occurs when a class is marked as 'final'?
No other class can extend it.
override
The class must be abstract in order to have any abstract methods (or it could be an interface rather than a class).
Volatile forces the JVM to reconcile the private field with the one in master memory. Won't generally be covered on test.
13. What are the built-in methods for class Object?
Java SE 5.0
inside a Class
equals(Object) - clone() - notify() - wait(empty/long/long - int) - finalize() - getClass() - hashCode() - toString() - & notifyAll()
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.
14. 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();
When the class is instantiated (not at compile or run time).
Object a - b - c; or Object a -b -c = new Object();
To limit values to a predetermined set.
15. What is the length in bytes of type 'long' - and what is it's maximum size?
8 bytes - 2^63 -1.
On either side of the variable name - e.g.: String [] var; String var [];
equals(Object) - clone() - notify() - wait(empty/long/long - int) - finalize() - getClass() - hashCode() - toString() - & notifyAll()
It allows platform-dependent code - like C. It can only be used to modify a method (not a class or field).
16. What is the purpose of making a class 'abstract'?
The abstract class can never be instantiated. It must be extended to be used.
Only one public class
No other class can extend it.
EnumName.VALUE;
17. How many classes can a class extend?
At the end of the list.
Compilation. Classes can't be modified as protected (or private).
Only one
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. ...
18. What kinds of exceptions can an overriding method throw that the original does not have?
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 very first line - excepting any comments.
An unchecked exceptions.
strictfp - final - and abstract
19. If a class's public class declaration is something like - 'public class HiThereSally {' - what must the source code file be named? Why?
HiThereSally.java because the file name must exactly match the public class name (excepting the .java extension).
When the class is instantiated (not at compile or run time).
final (cannot use static - final - abstract - volatile or transient)
enum EnumName { VALUE1 - VALUE 2 - VALUEX }; Take special note of the ending semicolon - which is optional.
20. All fields in an interface must have what three access & non-access modifiers?
To limit values to a predetermined set.
access modifiers - abstract modifier - other non-access modifiers - return type - method name - parenthesis - semi-colon. e.g.: public abstract String getName();
final (cannot use static - final - abstract - volatile or transient)
public - final - and static. However - these modifiers are implicit and do not have to be typed. Interfaces only have Constants.
21. Does an override have to throw all the exceptions of the original method?
instance
To limit values to a predetermined set.
extend another interface
No. It can throw less or no exceptions.
22. What are the eight primitive types in Java?
No. Only the parent (superclass) can access it's own private methods and fields.
byte - short - int - long - float - double - boolean - and char
Compilation. Classes can't be modified as protected (or private).
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.
23. Can multiple non-primitive variables be defined in one line?
Yes - as long as the final method has code in curly braces.
'native'
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. ...
Yes. Beware though that they point to the same object on the heap - whereas primitives maintain separate values.
24. Local ________ can be marked final
Yes - technically speaking.
byte - short - int - long - float - double - boolean - and char
variables
The class must be abstract in order to have any abstract methods (or it could be an interface rather than a class).
25. When overriding a method - the argument list (i.e. signature) must be what?
The argument cannot be reassigned to a different object/value within the method.
Exactly the same as the original method.
Only one public class
interface method
26. Can a file have no public classes?
Subtype.
Yes - technically speaking.
No - the type cannot change - only the object to which it points can change.
Only one
27. Enums can be declared...
In the same <i>package</i> it can be public - protected - or default and cannot be final or private.
inside a Class
No - the type cannot change - only the object to which it points can change.
a method?
28. What must you do when extending an abstract class or implementing any interface?
No limit.
the same 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.
inside a Class
29. 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
30. What IEEE standard does using strictfp conform to?
Only classes in the same package. The public methods are restricted by the default class level access.
Compilation. Classes can't be modified as protected (or private).
IEEE 754
extend another interface
31. For any method to be abstract - what must also be true about the class?
An unchecked exceptions.
byte - short - int - long - float - double - boolean - and char
The class must be abstract in order to have any abstract methods (or it could be an interface rather than a class).
Volatile forces the JVM to reconcile the private field with the one in master memory. Won't generally be covered on test.
32. 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?
Warning
: Invalid argument supplied for foreach() in
/var/www/html/basicversity.com/show_quiz.php
on line
183
33. What is the most basic construction for an Enum?
Yes - as long as the final method has code in curly braces.
synchronized - or - native
enum EnumName { VALUE1 - VALUE 2 - VALUEX }; Take special note of the ending semicolon - which is optional.
Object a - b - c; or Object a -b -c = new Object();
34. What modifiers can you use with method parameters?
No limit.
Public and Abstract
The class must be abstract in order to have any abstract methods (or it could be an interface rather than a class).
final (cannot use static - final - abstract - volatile or transient)
35. 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 - Identifiers cannot begin with numbers - further more identifiers may not contain hyphens.
4 bytes - 2^31 - 1.
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.
At compilation.
36. What is the purpose of making a method 'native'?
HiThereSally.java because the file name must exactly match the public class name (excepting the .java extension).
No limit.
Yes - as long as the final method has code in curly braces.
It allows platform-dependent code - like C. It can only be used to modify a method (not a class or field).
37. 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
38. What is the purpose of an Enum?
To limit values to a predetermined set.
Public and Abstract
No. Only the parent (superclass) can access it's own private methods and fields.
Java SE 5.0
39. 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
40. What three non-access modifiers can be used with a class declaration?
The original can be overriden if is public or protected and not final.
It cannot be more restrictive. It CAN be less restrictive than the supertype method.
2 Bytes - 2^15 - 1.
strictfp - final - and abstract
41. How many bits does a primitive 'double' hold?
No. Only the parent (superclass) can access it's own private methods and fields.
At compilation.
64 bits.
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.
42. 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?
Compilation
Subtype.
When the class is instantiated (not at compile or run time).
Public and Abstract
43. 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'?
The original can be overriden if is public or protected and not final.
No limit.
No - Identifiers cannot begin with numbers - further more identifiers may not contain hyphens.
synchronized - or - native
44. Where can the brackets for an array declaration go?
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.
On either side of the variable name - e.g.: String [] var; String var [];
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.
Only one
45. Can an abstract class have a final method?
It prevents the field from being serialized as the JVM will skip it.
'native'
Yes - as long as the final method has code in curly braces.
32 bits.
46. What is the syntax for declaring multiple variables on one line?
Object a - b - c; or Object a -b -c = new Object();
Volatile forces the JVM to reconcile the private field with the one in master memory. Won't generally be covered on test.
Only classes in the same package. The public methods are restricted by the default class level access.
At the end of the list.
47. What is the basic construction for calling an Enum value?
Yes - it is. Identifiers can begin with currency symbols.
No limit.
Subtype.
EnumName.VALUE;
48. Enums cannot be declared inside...
HiThereSally.java because the file name must exactly match the public class name (excepting the .java extension).
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. It can throw less or no exceptions.
a method?
49. What is the length in bytes of type 'int' - and what is it's maximum size?
4 bytes - 2^31 - 1.
abstract
access modifiers - abstract modifier - other non-access modifiers - return type - method name - parenthesis - semi-colon. e.g.: public abstract String getName();
No. Only the parent (superclass) can access it's own private methods and fields.
50. When are class instance variables instantiated?
When the class is instantiated (not at compile or run time).
instance
It prevents the field from being serialized as the JVM will skip it.
Just one.