Total members 11890 |It is currently Tue Apr 23, 2024 5:13 pm Login / Join Codemiles

Java

C/C++

PHP

C#

HTML

CSS

ASP

Javascript

JQuery

AJAX

XSD

Python

Matlab

R Scripts

Weka





what is the meaning of abstract class,concrete class and interface ?
1. In Java there is no multipliable inheritance like in C++ .But you can implement more thank one interface .
The interface methods are all abstract , this means contain no body ,and all properties are public static final (Means can't be changed later) . In interface you just say what is the class but don't say how to do it . Methods of interface are public and abstract by defaults and you don't need write the modifiers. interface can extend one or more interfaces .

Example
Code:

 interface shape 
{
         public abstract void   draw(); 


 
} 
 

Here a class circle implements the shape interface.

Code:
class shape implements shape
{
          public void draw()
                        {
                          // Draw body 
                         }


}
  

 


2. Abstract class can have implemented methods and others not , you can't have an abstract method in non abstract class. you have always to remember to that abstract methods end with semicolon . example

Code:

public abstract class Vehicle 
{
private String type;
public abstract void goUpHill(); // Abstract method
public String getType() { // Non-abstract method
return type;
}
}
public abstract class Car extends Vehicle {
public abstract void goUpHill(); // Still abstract
public void doCarThings() {
// special car code goes here
}
}
public class Mini extends Car {
public void goUpHill() {
// Mini-specific going uphill code
}
}
 





Last edited by DrRakha on Fri May 31, 2013 12:59 pm, edited 3 times in total.
edit title


Author:
Newbie
User avatar Posts: 4
Have thanks: 0 time
Post new topic Reply to topic  [ 1 post ] 

  Related Posts  to : java abstract class,concrete class and interface
 The difference between an Interface and an Abstract class     -  
 concrete class     -  
 what is a concrete class     -  
 What is an Abstract Class? !!!     -  
 make abstract class     -  
 how to Define abstract class in php     -  
 why cant instantiate an abstract class     -  
 Is garbageCollector a Class or interface?     -  
 Define class helper class to check the method existance     -  
 relationship between the Canvas class and the Graphics class     -  



Topic Tags

Java OOP
cron





Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com