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. 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
2. What is the most basic construction for an Enum?
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.
enum EnumName { VALUE1 - VALUE 2 - VALUEX }; Take special note of the ending semicolon - which is optional.
Yes. Beware though that they point to the same object on the heap - whereas primitives maintain separate values.
3. What must you do when extending an abstract class or implementing any interface?
No - the enum only calls it within itself.
No limit.
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.
4. Where can the brackets for an array declaration go?
On either side of the variable name - e.g.: String [] var; String var [];
EnumName.VALUE;
At the end of the list.
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.
5. At what point will you get an error if an interface method is 'protected' or 'private'?
It prevents the field from being serialized as the JVM will skip it.
2 Bytes - 2^15 - 1.
variables
Compilation.
6. What is the code format for an abstract method?
No. It can throw less or no exceptions.
Compilation.
Subtype.
access modifiers - abstract modifier - other non-access modifiers - return type - method name - parenthesis - semi-colon. e.g.: public abstract String getName();
7. What is the purpose of making a method 'native'?
To limit values to a predetermined set.
It allows platform-dependent code - like C. It can only be used to modify a method (not a class or field).
No - Identifiers cannot begin with numbers - further more identifiers may not contain hyphens.
enum EnumName { VALUE1 - VALUE 2 - VALUEX }; Take special note of the ending semicolon - which is optional.
8. Putting abstract and final in the class declaration will give you a run-time or compile time error?
At compilation
Compilation.
final - abstract - static - synchronized - native - & strictfp
No - Identifiers cannot begin with numbers - further more identifiers may not contain hyphens.
9. What are the eight primitive types in Java?
byte - short - int - long - float - double - boolean - and char
final (cannot use static - final - abstract - volatile or transient)
equals(Object) - clone() - notify() - wait(empty/long/long - int) - finalize() - getClass() - hashCode() - toString() - & notifyAll()
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.
10. 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
11. What are the rules for checked exceptions in overriding a method?
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. ...
strictfp - final - and abstract
The very first line - excepting any comments.
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.
12. What Java version began allowing an Enum type?
equals(Object) - clone() - notify() - wait(empty/long/long - int) - finalize() - getClass() - hashCode() - toString() - & notifyAll()
5.0
IEEE 754
public - final - and static. However - these modifiers are implicit and do not have to be typed. Interfaces only have Constants.
13. An interface method cannot be...
Volatile forces the JVM to reconcile the private field with the one in master memory. Won't generally be covered on test.
modified with strictfp
Subtype.
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.
14. Does an override have to throw all the exceptions of the original method?
It prevents the field from being serialized as the JVM will skip it.
Subtype.
Only classes in the same package. The public methods are restricted by the default class level access.
No. It can throw less or no exceptions.
15. Do Enums have to be within an existing class?
Yes - it is. Identifiers can begin with currency symbols.
4 bytes - 2^31 - 1.
No - they can be their own file.
Just one.
16. 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
17. When are class instance variables instantiated?
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.
modified with strictfp
access modifiers - abstract modifier - other non-access modifiers - return type - method name - parenthesis - semi-colon. e.g.: public abstract String getName();
When the class is instantiated (not at compile or run time).
18. Where in the source code must a 'package' statement be?
Compilation
The very first line - excepting any comments.
No. It can throw less or no exceptions.
No - the type cannot change - only the object to which it points can change.
19. How many bits does a primitive 'double' hold?
No - they can be their own file.
Compilation.
At the end of the list.
64 bits.
20. How many arguments can an Enum constructor have?
Object a - b - c; or Object a -b -c = new Object();
Yes. Beware though that they point to the same object on the heap - whereas primitives maintain separate values.
No limit.
In the same <i>package</i> it can be public - protected - or default and cannot be final or private.
21. What is the length in bytes of type 'long' - and what is it's maximum size?
It cannot be more restrictive. It CAN be less restrictive than the supertype method.
8 bytes - 2^63 -1.
the same file
The abstract class can never be instantiated. It must be extended to be used.
22. What is the purpose of making a method 'synchronized'?
In the same <i>package</i> it can be public - protected - or default and cannot be final or private.
It indicates that a method can only be accessed by one thread at a time.
Yes - it is. Identifiers can begin with currency symbols.
equals(Object) - clone() - notify() - wait(empty/long/long - int) - finalize() - getClass() - hashCode() - toString() - & notifyAll()
23. 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.
No limit.
At compilation
strictfp and final are legal - strictfp and abstract are legal - but you can't put final and abstract together.
24. Can you make an overriding method more access restrictive (public to private) or less restrictive (private to public)?
In the same <i>package</i> it can be public - protected - or default and cannot be final or private.
It indicates that a method can only be accessed by one thread at a time.
It cannot be more restrictive. It CAN be less restrictive than the supertype method.
2 Bytes - 2^15 - 1.
25. What is the syntax for declaring multiple variables on one line?
HiThereSally.java because the file name must exactly match the public class name (excepting the .java extension).
Object a - b - c; or Object a -b -c = new Object();
instance
The class must be abstract in order to have any abstract methods (or it could be an interface rather than a class).
26. How many non public classes can be in any one file?
No limit.
strictfp and final are legal - strictfp and abstract are legal - but you can't put final and abstract together.
Either the same or a SUBTYPE of the original method's return type.
abstract
27. What three non-access modifiers can be used with a class declaration?
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.
strictfp - final - and abstract
enum EnumName { VALUE1 - VALUE 2 - VALUEX }; Take special note of the ending semicolon - which is optional.
Yes - as long as the final method has code in curly braces.
28. Can an abstract class have a final method?
Volatile forces the JVM to reconcile the private field with the one in master memory. Won't generally be covered on test.
Compilation
Yes - as long as the final method has code in curly braces.
On either side of the variable name - e.g.: String [] var; String var [];
29. For any method to be abstract - what must also be true about the class?
Object type - ellipsis - object reference variable. e.g. doStuff(String ... necklace) { }
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).
Yes - technically speaking.
30. You cannot _____ a static method
It indicates that a method can only be accessed by one thread at a time.
In the same <i>package</i> it can be public - protected - or default and cannot be final or private.
override
Only one public class
31. What are the built-in methods for class Object?
'native'
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.
Object a - b - c; or Object a -b -c = new Object();
32. When overriding a method - the argument list (i.e. signature) must be what?
Exactly the same as the original method.
variables
.values()
The field 'aNumber' is public - static and final. The value cannot be changed -- it is a constant.
33. Local ________ can be marked final
Exactly the same as the original method.
Yes - it is. Identifiers can begin with currency symbols.
It indicates that a method can only be accessed by one thread at a time.
variables
34. Enums cannot be declared inside...
final (cannot use static - final - abstract - volatile or transient)
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.
a method?
Yes. Beware though that they point to the same object on the heap - whereas primitives maintain separate values.
35. How many bits does a primitive 'float' hold?
32 bits.
extend another interface
Yes - it is. Identifiers can begin with currency symbols.
No other class can extend it.
36. An ________cannot be static?
EnumName.VALUE;
It allows platform-dependent code - like C. It can only be used to modify a method (not a class or field).
IEEE 754
interface method
37. Once a reference variable is defined - can it's object type be changed?
No limit.
instance
No - the type cannot change - only the object to which it points can change.
When the class is instantiated (not at compile or run time).
38. What is the purpose of making a class 'abstract'?
4 bytes - 2^31 - 1.
Compilation.
The abstract class can never be instantiated. It must be extended to be used.
When the class is instantiated (not at compile or run time).
39. What IEEE standard does using strictfp conform to?
The field 'aNumber' is public - static and final. The value cannot be changed -- it is a constant.
Exactly the same as the original method.
32 bits.
IEEE 754
40. 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.
No - the type cannot change - only the object to which it points can change.
Only one public class
enum EnumName { VALUE1 - VALUE 2 - VALUEX }; Take special note of the ending semicolon - which is optional.
41. 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
42. What is the effect of making a method argument final?
final - abstract - static - synchronized - native - & strictfp
The argument cannot be reassigned to a different object/value within the method.
Object type - ellipsis - object reference variable. e.g. doStuff(String ... necklace) { }
Either the same or a SUBTYPE of the original method's return type.
43. If an Enum has a constructor - can you call that constructor?
No other class can extend it.
No - the enum only calls it within itself.
It prevents the field from being serialized as the JVM will skip it.
No. It can throw less or no exceptions.
44. 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'?
Compilation
Compilation. Classes can't be modified as protected (or private).
It prevents the field from being serialized as the JVM will skip it.
In the same <i>package</i> it can be public - protected - or default and cannot be final or private.
45. What is the purpose of an Enum?
To limit values to a predetermined set.
final (cannot use static - final - abstract - volatile or transient)
instance
An unchecked exceptions.
46. Is this identifier name valid? Why or why not? int $_myVar;
inside a Class
Public and Abstract
Yes - it is. Identifiers can begin with currency symbols.
byte - short - int - long - float - double - boolean - and char
47. What modifiers can you use with method parameters?
byte - short - int - long - float - double - boolean - and char
'native'
final (cannot use static - final - abstract - volatile or transient)
a method?
48. How many classes can a class extend?
Only one
Exactly the same as the original method.
It indicates that a method can only be accessed by one thread at a time.
.values()
49. An ________ variable cannot be marked strictfp
instance
An unchecked exceptions.
Only one public class
No - the enum only calls it within itself.
50. 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).
64 bits.
Yes - as long as the final method has code in curly braces.
byte - short - int - long - float - double - boolean - and char
Sorry!:) No result found.
Can you answer 50 questions in 15 minutes?
Let me suggest you:
Browse all subjects
Browse all tests
Most popular tests
Major Subjects
Tests & Exams
AP
CLEP
DSST
GRE
SAT
GMAT
Certifications
CISSP go to https://www.isc2.org/
PMP
ITIL
RHCE
MCTS
More...
IT Skills
Android Programming
Data Modeling
Objective C Programming
Basic Python Programming
Adobe Illustrator
More...
Business Skills
Advertising Techniques
Business Accounting Basics
Business Strategy
Human Resource Management
Marketing Basics
More...
Soft Skills
Body Language
People Skills
Public Speaking
Persuasion
Job Hunting And Resumes
More...
Vocabulary
GRE Vocab
SAT Vocab
TOEFL Essential Vocab
Basic English Words For All
Global Words You Should Know
Business English
More...
Languages
AP German Vocab
AP Latin Vocab
SAT Subject Test: French
Italian Survival
Norwegian Survival
More...
Engineering
Audio Engineering
Computer Science Engineering
Aerospace Engineering
Chemical Engineering
Structural Engineering
More...
Health Sciences
Basic Nursing Skills
Health Science Language Fundamentals
Veterinary Technology Medical Language
Cardiology
Clinical Surgery
More...
English
Grammar Fundamentals
Literary And Rhetorical Vocab
Elements Of Style Vocab
Introduction To English Major
Complete Advanced Sentences
Literature
Homonyms
More...
Math
Algebra Formulas
Basic Arithmetic: Measurements
Metric Conversions
Geometric Properties
Important Math Facts
Number Sense Vocab
Business Math
More...
Other Major Subjects
Science
Economics
History
Law
Performing-arts
Cooking
Logic & Reasoning
Trivia
Browse all subjects
Browse all tests
Most popular tests