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. How many interfaces can a class implement?
2. Putting abstract and final in the class declaration will give you a run-time or compile time error?
At compilation.
At compilation
64 bits.
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.
3. Enums cannot be declared inside...
The argument cannot be reassigned to a different object/value within the method.
Yes. Beware though that they point to the same object on the heap - whereas primitives maintain separate values.
Exactly the same as the original method.
a method?
4. What are the rules for checked exceptions in overriding a method?
strictfp and final are legal - strictfp and abstract are legal - but you can't put final and abstract together.
variables
At the end of the list.
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.
5. What is the length in bytes of type 'short' - and what is it's maximum size?
a method?
In the same <i>package</i> it can be public - protected - or default and cannot be final or private.
abstract
2 Bytes - 2^15 - 1.
6. Var-args have been possible since what Java version?
Volatile forces the JVM to reconcile the private field with the one in master memory. Won't generally be covered on test.
The argument cannot be reassigned to a different object/value within the method.
Java SE 5.0
4 bytes - 2^31 - 1.
7. What is the purpose of making a method 'native'?
No limit.
access modifiers - abstract modifier - other non-access modifiers - return type - method name - parenthesis - semi-colon. e.g.: public abstract String getName();
Only one
It allows platform-dependent code - like C. It can only be used to modify a method (not a class or field).
8. What modifiers can you use with method parameters?
EnumName.VALUE;
final (cannot use static - final - abstract - volatile or transient)
instance
Only classes in the same package. The public methods are restricted by the default class level access.
9. What is the purpose of making a field 'transient'?
It prevents the field from being serialized as the JVM will skip it.
IEEE 754
At compilation.
Yes - technically speaking.
10. 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?
strictfp - final - and abstract
IEEE 754
Only classes in the same package. The public methods are restricted by the default class level access.
Object a - b - c; or Object a -b -c = new Object();
11. What is the purpose of an Enum?
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.
To limit values to a predetermined set.
32 bits.
Only one public class
12. What is the most basic construction for an Enum?
instance
abstract
extend another interface
enum EnumName { VALUE1 - VALUE 2 - VALUEX }; Take special note of the ending semicolon - which is optional.
13. What are the seven non-access modifiers for methods?
It indicates that a method can only be accessed by one thread at a time.
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.
final - abstract - static - synchronized - native - & strictfp
byte - short - int - long - float - double - boolean - and char
14. Can a file have no public classes?
IEEE 754
The very first line - excepting any comments.
Yes - technically speaking.
At compilation
15. How many arguments can an Enum constructor have?
No - they can be their own file.
Only one
It indicates that a method can only be accessed by one thread at a time.
No limit.
16. Where do var-args have to appear on the method parameter list?
At the end of the list.
access modifiers - abstract modifier - other non-access modifiers - return type - method name - parenthesis - semi-colon. e.g.: public abstract String getName();
Subtype.
Object a - b - c; or Object a -b -c = new Object();
17. How many classes can a class extend?
abstract
Only one
2 Bytes - 2^15 - 1.
final - abstract - static - synchronized - native - & strictfp
18. Which of the three non-access modifiers (strictfp - final - abstract) can and can't be used together in a class declaration?
19. What is the length in bytes of type 'long' - and what is it's maximum size?
Just one.
variables
An unchecked exceptions.
8 bytes - 2^63 -1.
20. If a class's public class declaration is something like - 'public class HiThereSally {' - what must the source code file be named? Why?
The original can be overriden if is public or protected and not final.
HiThereSally.java because the file name must exactly match the public class name (excepting the .java extension).
The abstract class can never be instantiated. It must be extended to be used.
When the class is instantiated (not at compile or run time).
21. What kind of error (run-time or compile) do you get when trying to extend a final class?
.values()
synchronized - or - native
Object a - b - c; or Object a -b -c = new Object();
Compilation
22. 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?
2 Bytes - 2^15 - 1.
Compilation. Classes can't be modified as protected (or private).
Subtype.
Yes - technically speaking.
23. How many bits does a primitive 'float' hold?
No - they can be their own file.
Public and Abstract
Just one.
32 bits.
24. 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?
25. All fields in an interface must have what three access & non-access modifiers?
public - final - and static. However - these modifiers are implicit and do not have to be typed. Interfaces only have Constants.
No limit.
modified with strictfp
5.0
26. Do Enums have to be within an existing class?
public - final - and static. However - these modifiers are implicit and do not have to be typed. Interfaces only have Constants.
No - they can be their own file.
final - abstract - static - synchronized - native - & strictfp
Java SE 5.0
27. Can an abstract class have a final method?
Yes - as long as the final method has code in curly braces.
Either the same or a SUBTYPE of the original method's return type.
Object a - b - c; or Object a -b -c = new Object();
Only classes in the same package. The public methods are restricted by the default class level access.
28. Does an override have to throw all the exceptions of the original 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.
No. It can throw less or no exceptions.
The field 'aNumber' is public - static and final. The value cannot be changed -- it is a constant.
At compilation
29. What is the basic construction for calling an Enum value?
64 bits.
Public and Abstract
strictfp and final are legal - strictfp and abstract are legal - but you can't put final and abstract together.
EnumName.VALUE;
30. 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'?
In the same <i>package</i> it can be public - protected - or default and cannot be final or private.
The original can be overriden if is public or protected and not final.
abstract
Object a - b - c; or Object a -b -c = new Object();
31. Can a subclass see and use inherited 'private' methods and fields?
32. What is the purpose of making a method 'synchronized'?
No - they can be their own file.
the same file
The argument cannot be reassigned to a different object/value within the method.
It indicates that a method can only be accessed by one thread at a time.
33. How many public classes can be defined in one source code file?
Only one public class
synchronized - or - native
The very first line - excepting any comments.
override
34. What is the length in bytes of type 'int' - and what is it's maximum size?
4 bytes - 2^31 - 1.
a method?
32 bits.
In the same <i>package</i> it can be public - protected - or default and cannot be final or private.
35. What access level does the following interface method have? void getSomething(); public.
36. Enums can be declared...
At the end of the list.
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.
inside a Class
access modifiers - abstract modifier - other non-access modifiers - return type - method name - parenthesis - semi-colon. e.g.: public abstract String getName();
37. You cannot _____ a static method
32 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.
When the class is instantiated (not at compile or run time).
override
38. An ________cannot be static?
abstract
interface method
It prevents the field from being serialized as the JVM will skip it.
modified with strictfp
39. Enums can be declared outside a Class - but in...
the same file
It allows platform-dependent code - like C. It can only be used to modify a method (not a class or field).
An unchecked exceptions.
It prevents the field from being serialized as the JVM will skip it.
40. What are the only two access modifiers valid for a Class?
instance
strictfp - final - and abstract
No - they can be their own file.
default and public. Protected and private modifiers are not permissible and will give a compile time error.
41. Can multiple non-primitive variables be defined in one line?
At compilation.
Yes - it is. Identifiers can begin with currency symbols.
extend another interface
Yes. Beware though that they point to the same object on the heap - whereas primitives maintain separate values.
42. If a class is abstract - do the methods which ares supposed to be abstract too need to be marked 'abstract'?
43. An interface method cannot be modified as...
44. When you try to use a method that you don't have access to (due to 'private' etc) - when do you get an error?
strictfp - final - and abstract
variables
At compilation.
instance
45. What are the eight primitive types in Java?
At compilation.
byte - short - int - long - float - double - boolean - and char
synchronized - or - native
Only one
46. An instance variable cannot be...
32 bits.
At compilation
abstract
inside a Class
47. Can a private method be overriden by a subclass?
48. What must you do when extending an abstract class or implementing any interface?
a 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.
No - they can be their own 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.
49. How many bits does a primitive 'double' hold?
64 bits.
It cannot be more restrictive. It CAN be less restrictive than the supertype method.
instance
32 bits.
50. What IEEE standard does using strictfp conform to?
No. Only the parent (superclass) can access it's own private methods and fields.
Exactly the same as the original method.
IEEE 754
override