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.
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)
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
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.
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.
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.
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
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.
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.
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
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.
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.
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
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.
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.
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.
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();
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()
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.
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.
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
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
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.
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.
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
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.