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