What is the result of attempting to compile and run the program?
Which of the following modifiers can be applied to a class that is not a nested class?
Which of the following techniques can be used to prevent the instantiation of a class by any code outside of the class?
Do not declare any constructors.
Do not use a return statement in the constructor.
Declare all constructors using the keyword void to indicate that nothing is returned.
Declare all constructors using the private access modifier.
None of the above.
Which of the following modifiers can be applied to a constructor?
protected
public
static
synchronized
transient
Which of the following modifiers can be applied to the declaration of a field?
static
synchronized
transient
volatile
native
Which of the following modifiers can not be applied to a method?
final
static
synchronized
transient
native
None of the above.
class JSC202 { static byte m1() {final short s1 = 2; return s1;} // 1 static byte m2(final short s2) {return s2;} // 2 public static void main(String[] args) { short s3 = 4; System.out.print(""+m1()+m2(s3)); // 3 }}
What is the result of attempting to compile and run the program?
Prints: 24
Prints: 6
Compile-time error at 1.
Compile-time error at 2.
Run-time error
None of the above
// Class A is declared in a file named A.java. package com.dan.chisholm; public class A { public void m1() {System.out.print("A.m1, ");} protected void m2() {System.out.print("A.m2, ");} private void m3() {System.out.print("A.m3, ");} void m4() {System.out.print("A.m4, ");} } // Class D is declared in a file named D.java. package com.dan.chisholm.other; import com.dan.chisholm.A; public class D { public static void main(String[] args) { A a = new A(); a.m1(); // 1 a.m2(); // 2 a.m3(); // 3 a.m4(); // 4 }}
What is the result of attempting to compile and run the program?
Prints: A.m1, A.m2, A.m3, A.m4,
Compile-time error at 1.
Compile-time error at 2.
Compile-time error at 3.
Compile-time error at 4.
Which of the follow statements is true.
An anonymous class can be declared abstract.
A local class can be declared abstract.
An abstract class can be instantiated.
An abstract class is implicitly final.
An abstract class must declare at least one abstract method.
An abstract class can not extend a concrete class.
Which of the following statements are true?
The compiler will create a default constructor if no other constructor is declared.
The default constructor takes no arguments.
If a class A has a direct superclass, then the default constructor of class A invokes the no-argument constructor of the superclass.
The default constructor declares Exception in the throws clause.
The default constructor is always given the private access modifier.
The default constructor is always given the public modifier.
The default constructor is always given default package access.
Which of the following is used to prevent the serialization of a non-static field?
final
protected
synchronized
transient
volatile
native
Which of the following modifiers can not be used with the abstract modifier in a method declaration?