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. What modifiers can you use with method parameters?
final (cannot use static - final - abstract - volatile or transient)
Object a - b - c; or Object a -b -c = new Object();
In the same <i>package</i> it can be public - protected - or default and cannot be final or private.
Subtype.
2. How many bits does a primitive 'double' hold?
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.
Compilation
final - abstract - static - synchronized - native - & strictfp
64 bits.
3. 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
At compilation.
5.0
4. An interface method cannot be modified as...
5. An instance variable cannot be marked...
8 bytes - 2^63 -1.
In the same <i>package</i> it can be public - protected - or default and cannot be final or private.
synchronized - or - native
On either side of the variable name - e.g.: String [] var; String var [];
6. What is the purpose of making a class 'abstract'?
The abstract class can never be instantiated. It must be extended to be used.
5.0
extend another interface
EnumName.VALUE;
7. How many interfaces can a class implement?
8. When you try to use a method that you don't have access to (due to 'private' etc) - when do you get an error?
synchronized - or - native
instance
At compilation.
variables
9. At what point will you get an error if an interface method is 'protected' or 'private'?
Subtype.
On either side of the variable name - e.g.: String [] var; String var [];
Compilation.
No - the enum only calls it within itself.
10. An ________ variable cannot be marked strictfp
instance
No other class can extend it.
In the same <i>package</i> it can be public - protected - or default and cannot be final or private.
Java SE 5.0
11. What is the effect of making a method argument final?
No. Only the parent (superclass) can access it's own private methods and fields.
No - the type cannot change - only the object to which it points can change.
EnumName.VALUE;
The argument cannot be reassigned to a different object/value within the method.
12. What three non-access modifiers can be used with a class declaration?
Compilation.
2 Bytes - 2^15 - 1.
At the end of the list.
strictfp - final - and abstract
13. How many arguments can an Enum constructor have?
No limit.
HiThereSally.java because the file name must exactly match the public class name (excepting the .java extension).
No. It can throw less or no exceptions.
EnumName.VALUE;
14. Does an override have to throw all the exceptions of the original method?
No - Identifiers cannot begin with numbers - further more identifiers may not contain hyphens.
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. ...
No - the type cannot change - only the object to which it points can change.
No. It can throw less or no exceptions.
15. 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?
16. Do Enums have to be within an existing class?
No - they can be their own file.
Only one public class
IEEE 754
5.0
17. Enums can be declared...
inside a Class
Java SE 5.0
To limit values to a predetermined set.
Subtype.
18. If a class's public class declaration is something like - 'public class HiThereSally {' - what must the source code file be named? Why?
enum EnumName { VALUE1 - VALUE 2 - VALUEX }; Take special note of the ending semicolon - which is optional.
Object a - b - c; or Object a -b -c = new Object();
HiThereSally.java because the file name must exactly match the public class name (excepting the .java extension).
interface method
19. How many var-arg's can you have in a method signature?
Just one.
Yes - as long as the final method has code in curly braces.
IEEE 754
No other class can extend it.
20. What access level does the following interface method have? void getSomething(); public.
21. Can a subclass see and use inherited 'private' methods and fields?
22. 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'?
64 bits.
In the same <i>package</i> it can be public - protected - or default and cannot be final or private.
default and public. Protected and private modifiers are not permissible and will give a compile time error.
No - the enum only calls it within itself.
23. What is the purpose of making a field 'volatile'?
24. If an Enum has a constructor - can you call that constructor?
No. It can throw less or no exceptions.
Compilation
No - the enum only calls it within itself.
strictfp - final - and abstract
25. How many classes can a class extend?
No. It can throw less or no exceptions.
final - abstract - static - synchronized - native - & strictfp
Only one
4 bytes - 2^31 - 1.
26. When overriding a method - the argument list (i.e. signature) must be what?
Exactly the same as the original method.
abstract
Compilation.
No - they can be their own file.
27. 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()
At compilation
Only classes in the same package. The public methods are restricted by the default class level access.
No limit.
28. Is this identifier name valid? Why or why not? int 34myVar-Yes;
No - the enum only calls it within itself.
EnumName.VALUE;
No - Identifiers cannot begin with numbers - further more identifiers may not contain hyphens.
The class must be abstract in order to have any abstract methods (or it could be an interface rather than a class).
29. Putting abstract and final in the class declaration will give you a run-time or compile time error?
variables
a method?
At compilation
When the class is instantiated (not at compile or run time).
30. Which of the three non-access modifiers (strictfp - final - abstract) can and can't be used together in a class declaration?
31. An instance variable cannot be...
It allows platform-dependent code - like C. It can only be used to modify a method (not a class or field).
abstract
strictfp - final - and abstract
a method?
32. Can you make an overriding method more access restrictive (public to private) or less restrictive (private to public)?
The very first line - excepting any comments.
The class must be abstract in order to have any abstract methods (or it could be an interface rather than a class).
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.
33. What occurs when a class is marked as 'final'?
2 Bytes - 2^15 - 1.
enum EnumName { VALUE1 - VALUE 2 - VALUEX }; Take special note of the ending semicolon - which is optional.
No other class can extend it.
instance
34. What are the rules for checked exceptions in overriding a method?
Volatile forces the JVM to reconcile the private field with the one in master memory. Won't generally be covered on test.
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.
Compilation
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?
Either the same or a SUBTYPE of the original method's return type.
When the class is instantiated (not at compile or run time).
Subtype.
No - the enum only calls it within itself.
36. When overriding a method - the return type must be what?
37. What is the syntax for declaring multiple variables on one line?
Yes - as long as the final method has code in curly braces.
Compilation
Object a - b - c; or Object a -b -c = new Object();
default and public. Protected and private modifiers are not permissible and will give a compile time error.
38. An interface cannot extend any extendable (non-final) class - can only...
At the end of the list.
extend another interface
Compilation.
byte - short - int - long - float - double - boolean - and char
39. Can an abstract class have a final method?
No - the enum only calls it within itself.
synchronized - or - native
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.
Yes - as long as the final method has code in curly braces.
40. Enums can be declared outside a Class - but in...
the same file
a method?
Volatile forces the JVM to reconcile the private field with the one in master memory. Won't generally be covered on test.
An unchecked exceptions.
41. Where in the source code must a 'package' statement be?
Public and Abstract
The class must be abstract in order to have any abstract methods (or it could be an interface rather than a class).
No - they can be their own file.
The very first line - excepting any comments.
42. When would you get an error for a class declaration as follows and why? - protected class Me { }
43. Local ________ can be marked final
variables
An unchecked exceptions.
interface method
override
44. Can a file have no public classes?
No limit.
No other class can extend 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 - technically speaking.
45. What must you do when extending an abstract class or implementing any interface?
Compilation
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.
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.
Subtype.
46. An ________cannot be static?
IEEE 754
interface method
instance
abstract
47. What is the purpose of making a field 'transient'?
The very first line - excepting any comments.
5.0
a method?
It prevents the field from being serialized as the JVM will skip it.
48. How many bits does a primitive 'float' hold?
32 bits.
Public and Abstract
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
49. What is the length in bytes of type 'long' - and what is it's maximum size?
strictfp and final are legal - strictfp and abstract are legal - but you can't put final and abstract together.
It cannot be more restrictive. It CAN be less restrictive than the supertype method.
the same file
8 bytes - 2^63 -1.
50. What is the purpose of making a method 'native'?
The abstract class can never be instantiated. It must be extended to be used.
final - abstract - static - synchronized - native - & strictfp
It allows platform-dependent code - like C. It can only be used to modify a method (not a class or field).
Object a - b - c; or Object a -b -c = new Object();