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