A valid reason to declare a class as abstract is to

A valid reason to declare a class as abstract is to

A valid reason to declare a class as abstract is to

A.
define methods within a parent class, which may not be overridden in a child class

B.
define common method signatures in a class, while forcing child classes to contain
unique methodimplementations

C.
prevent instance variables from being accessed

D.
prevent a class from being extended

E.
define a class that prevents variable state from being stored when object Instances are
serialized

F.
define a class with methods that cannot be concurrently called by multiple threads



Leave a Reply 2

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


duff

duff

A.
B closer to interface. Abstract class not force child classes to contain
unique method implementations

gelete

gelete

A.
“define methods within a parent class, which may not be overridden in a child class”

OCA/OCP Java SE 7 Programmer I & II Study Guide (Kathy Sierra, Bert Bates)
70 Chapter 1: Declarations and Access Control
The first concrete class to extend an abstract class must implement all of its ABSTRACT methods

but, concrete methods?

abstract class AbsClass {
private int X = 555;
public abstract int getX();
public abstract void setX();
public void printX() { System.out.println(X); };
}

// Inherited abstract methods: the type AbsClassExt must implement the inherited abstract method AbsClass.getX()
// Inherited abstract methods: the type AbsClassExt must implement the inherited abstract method AbsClass.setX()
// Inherited concrete methods may not be overriden

class AbsClassExt extends AbsClass {
@Override
public int getX() {return 1;}

@Override
public void setX() { }

// @Override
// public void printX() { super.printX(); }

}

This code compiles