Oracle Sun Certified Java Programmer MCQs

Oracle Sun Certified Java Programmer MCQs

These Oracle Sun Certified Java Programmer multiple-choice questions and their answers will help you strengthen your grip on the subject of Oracle Sun Certified Java Programmer. You can prepare for an upcoming exam or job interview with these 20 Oracle Sun Certified Java Programmer MCQs.
So scroll down and start answering.

1: What modifiers can you use with method parameters?

A.   HiThereSally.java because the file name must exactly match the public class name (excepting the .java extension).

B.   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.

C.   No - the enum only calls it within itself.

D.   Final (cannot use static - final - abstract - volatile or transient)

2: Where do var-args have to appear on the method parameter list?

A.   At the end of the list.

B.   Only classes in the same package. The public methods are restricted by the default class level access.

C.   Either the same or a SUBTYPE of the original method's return type.

D.   Public and Abstract

3: What kinds of exceptions can an overriding method throw that the original does not have?

A.   Abstract

B.   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.

C.   Subtype.

D.   An unchecked exceptions.

4: Does an override have to throw all the exceptions of the original method?

A.   No. It can throw less or no exceptions.

B.   Override

C.   Synchronized - or - native

D.   The field 'aNumber' is public - static and final. The value cannot be changed -- it is a constant.

5: What is the purpose of making a field 'transient'?

A.   EnumName.VALUE;

B.   32 bits.

C.   It prevents the field from being serialized as the JVM will skip it.

D.   It indicates that a method can only be accessed by one thread at a time.

6: Is this identifier name valid? Why or why not? int 34myVar-Yes;

A.   No - Identifiers cannot begin with numbers - further more identifiers may not contain hyphens.

B.   Either the same or a SUBTYPE of the original method's return type.

C.   Volatile forces the JVM to reconcile the private field with the one in master memory. Won't generally be covered on test.

D.   IEEE 754

7: What is a 'constant specific class body' and where can you use it?

A.   No - the enum only calls it within itself.

B.   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.

C.   No limit.

D.   Subtype.

8: All fields in an interface must have what three access & non-access modifiers?

A.   No - the type cannot change - only the object to which it points can change.

B.   Access modifiers - abstract modifier - other non-access modifiers - return type - method name - parenthesis - semi-colon. e.g.: public abstract String getName();

C.   Modified with strictfp

D.   Public - final - and static. However - these modifiers are implicit and do not have to be typed. Interfaces only have Constants.

9: What is the code format for an abstract method?

A.   At compilation

B.   Public - final - and static. However - these modifiers are implicit and do not have to be typed. Interfaces only have Constants.

C.   Access modifiers - abstract modifier - other non-access modifiers - return type - method name - parenthesis - semi-colon. e.g.: public abstract String getName();

D.   IEEE 754

10: What is the purpose of making a method 'synchronized'?

A.   No. Only the parent (superclass) can access it's own private methods and fields.

B.   Strictfp and final are legal - strictfp and abstract are legal - but you can't put final and abstract together.

C.   Instance

D.   It indicates that a method can only be accessed by one thread at a time.

11: What must you do when extending an abstract class or implementing any interface?

A.   Compilation.

B.   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.

C.   Strictfp - final - and abstract

D.   Volatile forces the JVM to reconcile the private field with the one in master memory. Won't generally be covered on test.

12: What occurs when a class is marked as 'final'?

A.   HiThereSally.java because the file name must exactly match the public class name (excepting the .java extension).

B.   Only one public class

C.   No other class can extend it.

D.   Public and Abstract

13: What is the purpose of an Enum?

A.   To limit values to a predetermined set.

B.   Object a - b - c; or Object a -b -c = new Object();

C.   No - the type cannot change - only the object to which it points can change.

D.   No. Only the parent (superclass) can access it's own private methods and fields.

14: Where in the source code must a 'package' statement be?

A.   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.

B.   When the class is instantiated (not at compile or run time).

C.   Just one.

D.   The very first line - expecting any comments.

15: What is the effect of making a method argument final?

A.   It allows platform-dependent code - like C. It can only be used to modify a method (not a class or field).

B.   4 bytes - 2^31 - 1.

C.   64 bits.

D.   The argument cannot be reassigned to a different object/value within the method.

16: What are the rules for checked exceptions in overriding a method?

A.   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.

B.   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.

C.   .values()

D.   Access modifiers - abstract modifier - other non-access modifiers - return type - method name - parenthesis - semi-colon. e.g.: public abstract String getName();

17: 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?

A.   To limit values to a predetermined set.

B.   'native'

C.   Only classes in the same package. The public methods are restricted by the default class level access.

D.   Equals(Object) - clone() - notify() - wait(empty/long/long - int) - finalize() - getClass() - hashCode() - toString() - & notifyAll()

18: What is the length in bytes of type 'long' - and what is it's maximum size?

A.   Compilation. Classes can't be modified as protected (or private).

B.   At compilation.

C.   8 bytes - 2^63 -1.

D.   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.

19: What IEEE standard does using strictfp conform to?

A.   Equals(Object) - clone() - notify() - wait(empty/long/long - int) - finalize() - getClass() - hashCode() - toString() - & notifyAll()

B.   IEEE 754

C.   Inside a Class

D.   No - Identifiers cannot begin with numbers - further more identifiers may not contain hyphens.

20: An interface cannot extend any extendable (non-final) class - can only...

A.   Yes - it is. Identifiers can begin with currency symbols.

B.   HiThereSally.java because the file name must exactly match the public class name (excepting the .java extension).

C.   Extend another interface

D.   Interface method

21: Var-args have been possible since what Java version?

A.   At the end of the list.

B.   Byte - short - int - long - float - double - boolean - and char

C.   Java SE 5.0

D.   At compilation

22: What is the length in bytes of type 'short' - and what is it's maximum size?

A.   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.

B.   2 Bytes - 2^15 - 1.

C.   Volatile forces the JVM to reconcile the private field with the one in master memory. Won't generally be covered on test.

D.   In the same package it can be public - protected - or default and cannot be final or private.

23: Enums can be declared...

A.   Inside a Class

B.   8 bytes - 2^63 -1.

C.   The same file

D.   Only classes in the same package. The public methods are restricted by the default class level access.

24: Putting abstract and final in the class declaration will give you a run-time or compile time error?

A.   Object type - ellipsis - object reference variable. e.g. doStuff(String ... necklace) { }

B.   Yes - it is. Identifiers can begin with currency symbols.

C.   In the same package it can be public - protected - or default and cannot be final or private.

D.   At compilation

25: Is this identifier name valid? Why or why not? int $_myVar;

A.   No other class can extend it.

B.   2 Bytes - 2^15 - 1.

C.   Yes - it is. Identifiers can begin with currency symbols.

D.   Strictfp and final are legal - strictfp and abstract are legal - but you can't put final and abstract together.