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