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