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