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