Which code fragment is illegal?

Which code fragment is illegal?

Which code fragment is illegal?

A.
class Base1 {
abstract class Abs1 { }}

B.
abstract class Abs1 {
void doit () { }
}

C.
class Basel {
abstract class Abs1 extends Basel {

D.
abstract int var1 = 89;

Explanation:

The abstract keyword cannot be used to declare an int variable.
The abstract keyword is used to declare a class or method to be abstract[3]. An abstract method has
no implementation; all classes containing abstract methods must themselves be abstract, although
not all abstract classes have abstract methods.



Leave a Reply 0

Your email address will not be published. Required fields are marked *