I Have a class abstract with one abstract method, so that
method should override in the subclass, but i dont want to
override, if i am not override what will happen? If
compilation will occur then i dont want to give compilation
error, then what we need to do???
See the sample program.
public abstract class AbstractExample {
public abstract void sampleMethod();
}
public class AbstractExampleImple extends AbstractExample {

}

Answers were Sorted based on User's Feedback



I Have a class abstract with one abstract method, so that method should override in the subclass, ..

Answer / kvsravindrareddy

Normally abstract method should implement in the subclass,
otherwise application will give compilation error. If you want
to without compilation error, then subclass also make as a
abstract class, application will not give any compilation
error.
See the below sample code.

public abstract class AbstractExample {
public abstract void sampleMethod();
}
public abstract class AbstractExampleImple extends
AbstractExample {

}

Is This Answer Correct ?    20 Yes 0 No

I Have a class abstract with one abstract method, so that method should override in the subclass, ..

Answer / shreya tanavade

if you dont want to override the abstract method i.e. SampleMethod ,then you must declare the subclass as ABSTRACT..i.e.declare....public declare class AbstractExampleImple ...otherwise it wuld throw compilation error

Is This Answer Correct ?    1 Yes 0 No

Post New Answer

More Core Java Interview Questions

What is the size of integer?

0 Answers  


How to access a variable if it is declared as private?

3 Answers  


Can a class declared as private be accessed outside it’s package?

0 Answers  


If I don't provide any arguments on the command line, then what will the value stored in the string array passed into the main() method, empty or null?

0 Answers  


What is Collection interface?

1 Answers   Zensar,






What is variable and constant explain with example?

0 Answers  


What is array sorting in java?

0 Answers  


Can inner class be public in java?

0 Answers  


What is rmi and steps involved in developing an rmi object?

0 Answers  


What is an inner class in java?

0 Answers  


How do you represent a space in regex java?

0 Answers  


what is instanceof operator used in java?

0 Answers  


Categories