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 you try to use a method that you don't have access to (due to 'private' etc) - when do you get an error?
the same file
At compilation.
No other class can extend it.
The argument cannot be reassigned to a different object/value within the method.
2. Where can the brackets for an array declaration go?
Either the same or a SUBTYPE of the original method's return type.
On either side of the variable name - e.g.: String [] var; String var [];
The abstract class can never be instantiated. It must be extended to be used.
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.
3. An interface method cannot be...
modified with strictfp
Only one public class
Yes - as long as the final method has code in curly braces.
'native'
4. What is the purpose of making a field 'transient'?
It prevents the field from being serialized as the JVM will skip it.
It indicates that a method can only be accessed by one thread at a time.
Compilation
Public and Abstract
5. What are the only two access modifiers valid for a Class?
.values()
No. It can throw less or no exceptions.
default and public. Protected and private modifiers are not permissible and will give a compile time error.
Yes - as long as the final method has code in curly braces.
6. What is the purpose of making a class 'abstract'?
instance
final - abstract - static - synchronized - native - & strictfp
The original can be overriden if is public or protected and not final.
The abstract class can never be instantiated. It must be extended to be used.
7. What is the length in bytes of type 'short' - and what is it's maximum size?
Yes - it is. Identifiers can begin with currency symbols.
Subtype.
Yes - as long as the final method has code in curly braces.
2 Bytes - 2^15 - 1.
8. An ________cannot be static?
interface method
8 bytes - 2^63 -1.
The argument cannot be reassigned to a different object/value within the method.
byte - short - int - long - float - double - boolean - and char
9. What is the code format for an abstract method?
override
a method?
access modifiers - abstract modifier - other non-access modifiers - return type - method name - parenthesis - semi-colon. e.g.: public abstract String getName();
strictfp - final - and abstract
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. Local ________ can be marked final
variables
Only classes in the same package. The public methods are restricted by the default class level access.
5.0
extend another interface
12. 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.
An unchecked exceptions.
Object a - b - c; or Object a -b -c = new Object();
.values()
13. At what point will you get an error if an interface method is 'protected' or 'private'?
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.
Compilation.
32 bits.
instance
14. Is this identifier name valid? Why or why not? int $_myVar;
Yes - it is. Identifiers can begin with currency symbols.
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.
'native'
public - final - and static. However - these modifiers are implicit and do not have to be typed. Interfaces only have Constants.
15. An instance variable cannot be marked...
No. Only the parent (superclass) can access it's own private methods and fields.
synchronized - or - native
No - the enum only calls it within itself.
instance
16. What is a 'constant specific class body' and where can you use it?
Public and Abstract
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.
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.
17. Putting abstract and final in the class declaration will give you a run-time or compile time error?
At compilation
Only one public class
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.
the same file
18. 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?
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.
At the end of the list.
Only classes in the same package. The public methods are restricted by the default class level access.
19. What are the rules for checked exceptions in overriding a method?
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.
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 methods are always public. A lack of modifier does not make this 'default' in the typical sense of a package-only default access modifier.
No - they can be their own file.
20. What is the proper syntax for declaring a var-arg in a method signature?
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 - final - and abstract
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 type - ellipsis - object reference variable. e.g. doStuff(String ... necklace) { }
21. Is this identifier name valid? Why or why not? int 34myVar-Yes;
No - the enum only calls it within itself.
Java SE 5.0
Yes - it is. Identifiers can begin with currency symbols.
No - Identifiers cannot begin with numbers - further more identifiers may not contain hyphens.
22. Var-args have been possible since what Java version?
strictfp - final - and abstract
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.
Java SE 5.0
Only classes in the same package. The public methods are restricted by the default class level access.
23. How many classes can a class extend?
Only one public class
Exactly the same as the original method.
Only one
equals(Object) - clone() - notify() - wait(empty/long/long - int) - finalize() - getClass() - hashCode() - toString() - & notifyAll()
24. 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'?
No other class can extend it.
The original can be overriden if is public or protected and not final.
No. It can throw less or no exceptions.
Compilation.
25. How many arguments can an Enum constructor have?
a method?
Either the same or a SUBTYPE of the original method's return type.
When the class is instantiated (not at compile or run time).
No limit.
26. If a class's public class declaration is something like - 'public class HiThereSally {' - what must the source code file be named? Why?
HiThereSally.java because the file name must exactly match the public class name (excepting the .java extension).
At the end of the list.
Object a - b - c; or Object a -b -c = new Object();
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.
27. How many public classes can be defined in one source code file?
access modifiers - abstract modifier - other non-access modifiers - return type - method name - parenthesis - semi-colon. e.g.: public abstract String getName();
Yes. Beware though that they point to the same object on the heap - whereas primitives maintain separate values.
Only one public class
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.
28. 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
29. An instance variable cannot be...
No - Identifiers cannot begin with numbers - further more identifiers may not contain hyphens.
abstract
public - final - and static. However - these modifiers are implicit and do not have to be typed. Interfaces only have Constants.
At compilation.
30. When overriding a method - the argument list (i.e. signature) must be what?
4 bytes - 2^31 - 1.
No - the enum only calls it within itself.
Exactly the same as the original method.
No. It can throw less or no exceptions.
31. What is the purpose of an Enum?
In the same <i>package</i> it can be public - protected - or default and cannot be final or private.
To limit values to a predetermined set.
No limit.
.values()
32. Enums cannot be declared inside...
the same file
a method?
No limit.
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.
33. Can a file have no public classes?
modified with strictfp
Java SE 5.0
Yes - technically speaking.
The class must be abstract in order to have any abstract methods (or it could be an interface rather than a class).
34. What modifiers can you use with method parameters?
a method?
final (cannot use static - final - abstract - volatile or transient)
Compilation.
The abstract class can never be instantiated. It must be extended to be used.
35. Do Enums have to be within an existing class?
No - they can be their own file.
public - final - and static. However - these modifiers are implicit and do not have to be typed. Interfaces only have Constants.
abstract
extend another interface
36. What kind of error (run-time or compile) do you get when trying to extend a final class?
Compilation. Classes can't be modified as protected (or private).
Compilation
No limit.
2 Bytes - 2^15 - 1.
37. An interface cannot extend any extendable (non-final) class - can only...
inside a Class
extend another interface
final (cannot use static - final - abstract - volatile or transient)
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.
38. Once a reference variable is defined - can it's object type be changed?
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.
Compilation
No - the type cannot change - only the object to which it points can change.
Yes - it is. Identifiers can begin with currency symbols.
39. What Java version began allowing an Enum type?
Yes - it is. Identifiers can begin with currency symbols.
the same file
enum EnumName { VALUE1 - VALUE 2 - VALUEX }; Take special note of the ending semicolon - which is optional.
5.0
40. What are the seven non-access modifiers for methods?
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.
final - abstract - static - synchronized - native - & strictfp
Exactly the same as the original method.
No. It can throw less or no exceptions.
41. How many bits does a primitive 'float' hold?
a method?
EnumName.VALUE;
32 bits.
Compilation. Classes can't be modified as protected (or private).
42. You cannot _____ a static method
Object type - ellipsis - object reference variable. e.g. doStuff(String ... necklace) { }
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.
final (cannot use static - final - abstract - volatile or transient)
override
43. How many non public classes can be in any one file?
No limit.
No other class can extend it.
Compilation. Classes can't be modified as protected (or private).
modified with strictfp
44. If an Enum has a constructor - can you call that constructor?
No. Only the parent (superclass) can access it's own private methods and fields.
2 Bytes - 2^15 - 1.
final - abstract - static - synchronized - native - & strictfp
No - the enum only calls it within itself.
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. For any method to be abstract - what must also be true about the class?
2 Bytes - 2^15 - 1.
Compilation.
The class must be abstract in order to have any abstract methods (or it could be an interface rather than a class).
An unchecked exceptions.
47. When are class instance variables instantiated?
When the class is instantiated (not at compile or run time).
It prevents the field from being serialized as the JVM will skip it.
Yes - as long as the final method has code in curly braces.
The very first line - excepting any comments.
48. What is the length in bytes of type 'long' - and what is it's maximum size?
Public and Abstract
8 bytes - 2^63 -1.
The class must be abstract in order to have any abstract methods (or it could be an interface rather than a class).
Yes - it is. Identifiers can begin with currency symbols.
49. What three non-access modifiers can be used with a class declaration?
On either side of the variable name - e.g.: String [] var; String var [];
byte - short - int - long - float - double - boolean - and char
8 bytes - 2^63 -1.
strictfp - final - and abstract
50. What is the most basic construction for an Enum?
instance
enum EnumName { VALUE1 - VALUE 2 - VALUEX }; Take special note of the ending semicolon - which is optional.
The abstract class can never be instantiated. It must be extended to be used.
the same file