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 life-cycle of an object?

2 Answers   Broadridge, Syntel,


class{ ... ... interface myinterface{ ... ... } abstract class{ .. .. } ... .. .. } is this possible to write "Interface and/ or Abstract class inside a class ? if possible whcich one is possible is only interface? is only abstract?

2 Answers   Logica CMG,


Consider that class classA, abstract class classB, and final classC have been defined.Which one of the following is correct? 1. classA extends classC implements classB 2. class A extends classB, classC 3. classA extends classB 4. classB implements classC

2 Answers  


What are synchronized methods and synchronized statements in java programming?

0 Answers  


What are identifiers in java?

0 Answers  






What is meant by overloading?

0 Answers  


Can we declare a class as abstract without having any abstract method?

0 Answers  


What is double data type?

0 Answers  


What is google full form?

0 Answers  


What is difference between checked and unchecked exception in java?

0 Answers  


My application URL : http://localhost:8080/Application/Login.jsp. When a user enter this url in IE then, how it get Login.JSP Page exactly? what are the processes will happen from when we submit the URL to get Login.jsp?

3 Answers   IBM, TCS,


Can size_t be negative?

0 Answers  


Categories