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