GeekInterview.com
  I am new, Sign me up!
 
GeekInterview.com  >  Interview Questions  >  J2EE  >  Core Java
Go To First  |  Previous Question  |  Next Question 
 Core Java  |  Question 78 of 502    Print  
Meaning - Abstract classes, abstract methods

  
Total Answers and Comments: 4 Last Update: October 26, 2009     Asked by: Beena 
  
 Sponsored Links

 
 Best Rated Answer

No best answer available. Please pick the good answer available or submit your answer.
September 29, 2005 05:55:53   #1  
sarat        

RE: Meaning - Abstract classes, abstract methods...

hi

the abstract class is nothing but the class which is having the method that too without body and begin with abstract keyword.a class which is incomplete is termd as abatract class

for abstract classes we can not instantiate.


 
Is this answer useful? Yes | No
October 19, 2005 02:10:08   #2  
Devidas Sonawane        

RE: Meaning - Abstract classes, abstract methods...

Abstract Class:- it has abstract methods and non-abstract methods. Abstract Methods:- this methods has no body. these final and variables of these methods are static final and protected.


 
Is this answer useful? Yes | No
October 22, 2009 01:25:44   #3  
haruto Member Since: August 2009   Contribution: 1    

RE: Meaning - Abstract classes, abstract methods
In java a class has a well defined structure and behaviour. There are times where we do not need to implement a method such methods are written in the class where the class is preceded by keyword 'abstract' in short we could say that the implementation of the method can be written in the child class of the abstract class to summarize in short an abstract class is a class which contains abstract as well as concrete methods (non abstract which has well defined shape
and structure) since because of this we cannot create an object of the abstract class hence memory is not allocated from it but
any how we can create a reference for the same.

Eg
abstract class ABC
{

void add()
{// method body .. method is non abstract .
}

void sub();//abstract method

}

class XYZ extends ABC
{
void sub()
{
SOP('Sub');
}

PSVM(String ar[])
{
ABC a ; //we can create reference of an abstract class.
XYZ z new XYZ(); // creating object of the child class.

a z; //upcasting .
a.sub();// this is possible as we performed upcasting..

}
}

but do remember that if
you are not implementing the abstract method of the parent class in child class then the child class should
be made abstract as well.

 
Is this answer useful? Yes | No
October 25, 2009 02:59:26   #4  
jawaharl0207 Member Since: February 2009   Contribution: 9    

RE: Meaning - Abstract classes, abstract methods
Abstract Class: There are two ways to create abstract class one is by mentioning abstract key before the class declaration and second one is by mentioning abstract key before the method declaration we can make that class as abstract class.
eg:public abstract class AbstractDem

Abstract method:mention abstract key before declaring the method then it will be a abstract method.
eg: public abstract xyz();

implemented example:

package abs;

public abstract class AbstractDem {

/**
* @param args
*/
public abstract void xyz();
public static void xyz1(){System.out.println("method xyz1");};
public static void main(String[] args) {
// TODO Auto-generated method stub
AbstractDem.xyz1();

}

 
Is this answer useful? Yes | No


 
Go To Top


 Sponsored Links

 
About Us -  Privacy Policy -  Terms and Conditions -  Contact -  Ask Question -  Propose Category -  Site Updates 

Copyright © 2005 - 2009 GeekInterview.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape