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'?
5.0
Yes. Beware though that they point to the same object on the heap - whereas primitives maintain separate values.
No other class can extend it.
Either the same or a SUBTYPE of the original method's return type.
2. What is the length in bytes of type 'long' - and what is it's maximum size?
the same file
Only one
5.0
8 bytes - 2^63 -1.
3. How many classes can a class extend?
32 bits.
No limit.
Only one
the same file
4. If an Enum has a constructor - can you call that constructor?
No - the enum only calls it within itself.
Object a - b - c; or Object a -b -c = new Object();
Only one public class
No limit.
5. Enums cannot be declared inside...
The abstract class can never be instantiated. It must be extended to be used.
a method?
4 bytes - 2^31 - 1.
public - final - and static. However - these modifiers are implicit and do not have to be typed. Interfaces only have Constants.
6. When overriding a method - the return type must be what?
7. Does an override have to throw all the exceptions of the original method?
Yes. Beware though that they point to the same object on the heap - whereas primitives maintain separate values.
The original can be overriden if is public or protected and not final.
No. It can throw less or no exceptions.
64 bits.
8. When overriding a method - the argument list (i.e. signature) must be what?
No limit.
Exactly the same as the original method.
4 bytes - 2^31 - 1.
.values()
9. What is the syntax for declaring multiple variables on one line?
In the same <i>package</i> it can be public - protected - or default and cannot be final or private.
Object a - b - c; or Object a -b -c = new Object();
enum EnumName { VALUE1 - VALUE 2 - VALUEX }; Take special note of the ending semicolon - which is optional.
Yes - technically speaking.
10. Do Enums have to be within an existing class?
It cannot be more restrictive. It CAN be less restrictive than the supertype method.
No - they can be their own file.
Subtype.
override
11. How many interfaces can a class implement?
12. 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.
The argument cannot be reassigned to a different object/value within the method.
synchronized - or - native
It cannot be more restrictive. It CAN be less restrictive than the supertype method.
13. What is the code format for an abstract method?
final - abstract - static - synchronized - native - & strictfp
32 bits.
No limit.
access modifiers - abstract modifier - other non-access modifiers - return type - method name - parenthesis - semi-colon. e.g.: public abstract String getName();
14. How many non public classes can be in any one file?
In the same <i>package</i> it can be public - protected - or default and cannot be final or private.
final - abstract - static - synchronized - native - & strictfp
Object a - b - c; or Object a -b -c = new Object();
No limit.
15. Can a private method be overriden by a subclass?
16. Calling what method will return an Array of Enum values?
The very first line - excepting any comments.
byte - short - int - long - float - double - boolean - and char
.values()
inside a Class
17. Local ________ can be marked final
Object type - ellipsis - object reference variable. e.g. doStuff(String ... necklace) { }
access modifiers - abstract modifier - other non-access modifiers - return type - method name - parenthesis - semi-colon. e.g.: public abstract String getName();
When the class is instantiated (not at compile or run time).
variables
18. 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'?
No - the type cannot change - only the object to which it points can change.
In the same <i>package</i> it can be public - protected - or default and cannot be final or private.
To limit values to a predetermined set.
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. ...
19. What access level does the following interface method have? void getSomething(); public.
20. Can a subclass see and use inherited 'private' methods and fields?
21. Where in the source code must a 'package' statement be?
The very first line - excepting any comments.
interface method
5.0
the same file
22. Can a file have no public classes?
Yes - it is. Identifiers can begin with currency symbols.
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 - technically speaking.
At compilation.
23. An interface method cannot be modified as...
24. What is the effect of making a method argument final?
Object a - b - c; or Object a -b -c = new Object();
5.0
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.
The argument cannot be reassigned to a different object/value within the method.
25. 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?
26. 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).
Exactly the same as the original method.
32 bits.
Only one public class
27. What is the basic construction for calling an Enum value?
Compilation.
strictfp and final are legal - strictfp and abstract are legal - but you can't put final and abstract together.
HiThereSally.java because the file name must exactly match the public class name (excepting the .java extension).
EnumName.VALUE;
28. An interface cannot extend any extendable (non-final) class - can only...
override
extend another interface
the same file
Compilation. Classes can't be modified as protected (or private).
29. You cannot _____ a static method
64 bits.
HiThereSally.java because the file name must exactly match the public class name (excepting the .java extension).
override
No - they can be their own file.
30. When are class instance variables instantiated?
It allows platform-dependent code - like C. It can only be used to modify a method (not a class or field).
When the class is instantiated (not at compile or run time).
No other class can extend it.
No - they can be their own file.
31. Putting abstract and final in the class declaration will give you a run-time or compile time error?
At compilation
final - abstract - static - synchronized - native - & strictfp
Only classes in the same package. The public methods are restricted by the default class level access.
In the same <i>package</i> it can be public - protected - or default and cannot be final or private.
32. All fields in an interface must have what three access & non-access modifiers?
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.
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 argument cannot be reassigned to a different object/value within the method.
public - final - and static. However - these modifiers are implicit and do not have to be typed. Interfaces only have Constants.
33. What is the purpose of making a method 'native'?
strictfp - final - and abstract
It indicates that a method can only be accessed by one thread at a time.
It allows platform-dependent code - like C. It can only be used to modify a method (not a class or field).
Subtype.
34. What is the length in bytes of type 'int' - and what is it's maximum size?
4 bytes - 2^31 - 1.
strictfp - final - and abstract
32 bits.
The abstract class can never be instantiated. It must be extended to be used.
35. Is this identifier name valid? Why or why not? int 34myVar-Yes;
The argument cannot be reassigned to a different object/value within the method.
Either the same or a SUBTYPE of the original method's return type.
No - Identifiers cannot begin with numbers - further more identifiers may not contain hyphens.
Yes - technically speaking.
36. Var-args have been possible since what Java version?
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.
enum EnumName { VALUE1 - VALUE 2 - VALUEX }; Take special note of the ending semicolon - which is optional.
It cannot be more restrictive. It CAN be less restrictive than the supertype method.
Java SE 5.0
37. What are the seven non-access modifiers for methods?
byte - short - int - long - float - double - boolean - and char
final - abstract - static - synchronized - native - & strictfp
strictfp and final are legal - strictfp and abstract are legal - but you can't put final and abstract together.
The class must be abstract in order to have any abstract methods (or it could be an interface rather than a class).
38. Once a reference variable is defined - can it's object type be changed?
EnumName.VALUE;
final - abstract - static - synchronized - native - & strictfp
Compilation. Classes can't be modified as protected (or private).
No - the type cannot change - only the object to which it points can change.
39. How many public classes can be defined in one source code file?
Only one public class
No limit.
It indicates that a method can only be accessed by one thread at a time.
An unchecked exceptions.
40. An ________ variable cannot be marked strictfp
instance
the same file
The class must be abstract in order to have any abstract methods (or it could be an interface rather than a class).
It cannot be more restrictive. It CAN be less restrictive than the supertype method.
41. What is the most basic construction for an Enum?
final (cannot use static - final - abstract - volatile or transient)
EnumName.VALUE;
enum EnumName { VALUE1 - VALUE 2 - VALUEX }; Take special note of the ending semicolon - which is optional.
To limit values to a predetermined set.
42. What is a 'constant specific class body' and where can you use it?
final - abstract - static - synchronized - native - & strictfp
2 Bytes - 2^15 - 1.
Compilation. Classes can't be modified as protected (or private).
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.
43. The following field is defined in an interface. What do we know about it's access and non-access modifiers? int aNumber = 59;
44. Enums can be declared outside a Class - but in...
The field 'aNumber' is public - static and final. The value cannot be changed -- it is a constant.
'native'
the same file
strictfp - final - and abstract
45. What modifiers can you use with method parameters?
HiThereSally.java because the file name must exactly match the public class name (excepting the .java extension).
final (cannot use static - final - abstract - volatile or transient)
.values()
Yes. Beware though that they point to the same object on the heap - whereas primitives maintain separate values.
46. What kinds of exceptions can an overriding method throw that the original does not have?
HiThereSally.java because the file name must exactly match the public class name (excepting the .java extension).
variables
An unchecked exceptions.
It indicates that a method can only be accessed by one thread at a time.
47. What are the eight primitive types in Java?
enum EnumName { VALUE1 - VALUE 2 - VALUEX }; Take special note of the ending semicolon - which is optional.
The field 'aNumber' is public - static and final. The value cannot be changed -- it is a constant.
The abstract class can never be instantiated. It must be extended to be used.
byte - short - int - long - float - double - boolean - and char
48. Can multiple non-primitive variables be defined in one line?
interface method
variables
Object type - ellipsis - object reference variable. e.g. doStuff(String ... necklace) { }
Yes. Beware though that they point to the same object on the heap - whereas primitives maintain separate values.
49. Is this identifier name valid? Why or why not? int $_myVar;
No - the type cannot change - only the object to which it points can change.
Yes - it is. Identifiers can begin with currency symbols.
modified with strictfp
4 bytes - 2^31 - 1.
50. What three non-access modifiers can be used with a class declaration?
At compilation.
strictfp - final - and abstract
Subtype.
modified with strictfp