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