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