Вы находитесь на странице: 1из 3

Which of the following is required in a non-abstract child?

public abstract int sumUp ( int[] arr ) { . . . }


public int sumUp ( int[] arr ) { . . . }
public double sumUp ( int[] arr ) { . . . }
public int sumUp ( long[] arr ) { . . . }
Which statement is true for any concrete class implementing the
java.lang.Runnable interface?
The class must contain an empty protected void method named run().
The class must contain a public void method named runnable().
The class definition must include the words implements Threads and contain a
method called run().
The mandatory method must be public, with a return type of void, must be called
run(), and cannot take any arguments.
Which is a valid declaration within an interface?
protected short stop = 23;
final void madness(short stop);
public Boolean madness(long bow);
static char madness(double duty);
Can an abstract class define both abstract methods and non-abstract
methods ?
No-it must have all one or the other.
No-it must have all abstract methods.
Yes-but the child classes do not inherit the abstract methods.
Yes-the child classes inherit both.
Which one of the following statements is true ?
An abstract class can be instantiated.
An abstract class is implicitly final.
An abstract class can declare non-abstract methods.
An abstract class can not extend a concrete class.

What is an abstract method?


An abstract method is any method in an abstract class.
An abstract method is a method which cannot be inherited.
An abstract method is one without a body that is declared with the reserved word
abstract.
An abstract method is a method in the child class that overrides a parent method.
What is an abstract class?
An abstract class is one without any child classes.
An abstract class is any parent class with more than one child class.
An abstract class is a class which cannot be instantiated.
An abstract class is another name for "base class."
Which declaration in the below code represents a valid declaration within
the interface ?
1. public interface TestInterface {
2.

volatile long value=98L;

3.

transient long amount=67L;

4.

Long calculate(long input);

5.

static Integer getValue();

6. }
Declaration at line 2.
Declaration at line 3.
Declaration at line 4.
Declaration at line 5.
Given:
1. public interface Constants {
2.

static final int SEASON_SUMMER=1;

3.

final int SEASON_SPRING=2;

4.

static int SEASON_AUTUMN=3;

5.

public static const int SEASON_WINTER=4;

6. }
What is the expected behaviour on compiling the above code?
Compilation error occurs at line 2.
Compilation error occurs at line 3.
Compilation error occurs at line 4.
Compilation error occurs at line 5.
Given the following,
1. abstract class A {
2.

abstract short m1() ;

3.

short m2() { return (short) 420; }

4. }
5.
6. abstract class B extends A {
7.

// missing code ?

8.

short m1() { return (short) 42; }

9. }
Which of the following statements is true?
Class B must either make an abstract declaration of method m2() or implement
method m2() to allow the code to compile.
It is legal, but not required, for class B to either make an abstract declaration of
method m2() or implement method m2() for the code to compile.
As long as line 8 exists, class A must declare method m1() in some way.
If class A was not abstract and method m1() on line 2 was implemented, the code
would not compile.
Given the following,
1. interface Base {
2.

boolean m1 ();

3.

byte m2(short s);

4. }