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