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