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