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