Define Abstract method & class with Example
Answers were Sorted based on User's Feedback
Answer / manoj kumar verma allahabad(ba
Abstract class shows kins of relationship.it is the impure
abstract.Abstract class can have method with body or
without. Abstract class can not be instantiated.e.g. Object
nahi ban sakta abstract class ka.
for example :-
abstract class Shape
{
abstract void area(); // No body compulsory to be
overriding
void show()
{
System.out.println("Shape is the show");
}
}
class circle extends Shape
{
void area()
{
}
void show()
{
System.out.println("Show the circle");
}
}
class Testabstract
{
public static void main(String ar[])
{
circle c1=new Shape(); // error object of
abstract class cannot be made
circle c2=new circle();
c2.area();
c1.show();
}
}
| Is This Answer Correct ? | 1 Yes | 0 No |
Answer / micheal b
abstract means wrapping the data in sigle unit
class is a user define data type
| Is This Answer Correct ? | 2 Yes | 2 No |
Answer / ramyathillainathan
We can indicate that a method must always be redefined in a sub class , thus making overriding compulsory. This is done using the modifier keyword abstract in the method definition.
example;
abstract class Shape
{
------------
------------
Abstract void draw();
------------
---------------
}
| Is This Answer Correct ? | 0 Yes | 0 No |
through which algorithm does the garbage collector works? how the garbage collector will understand that the object will going to be deleted?
what is the difference between SCAN AND CHECK,LOKUP AND XFOOT? where we can use thease opcodes? Can any body tell me real time senariao with example?
What are the advantages of Server Controls over HTML/ASP Controls.
is it acceptable if we declare multiple exceptions in same overridden method.
how we define two jobs have same name??is it exist??
how can we implement locks in plsql?
Any real time example of O2C process from taking order till creating invoice.
what are wrapper classes
A, B and C are 8 bit nos. They are as follows: A 1 1 0 1 1 0 1 1 B 0 1 1 1 1 0 1 0 C 0 1 1 0 1 1 0 1 Find ( (A-B) u C )=? how to solve this need with steps
How to connect to ms word wit VB ojective is to prepare s/w to generate question paper , selects questions randomly from the ms access , database
2.Different data types in C? and its value and range?
Why we need new operator in java at the time of object declaration and why not in c++?