Total members 10261 | Gratitudes |It is currently Wed May 23, 2012 8:50 am Login / Join Codemiles


All times are UTC [ DST ]




Post new topic Reply to topic  Quick reply  [ 4 posts ] 
Author Question
 Question subject: java abstract class,concrete class and interface
PostPosted: Thu Jan 22, 2009 5:22 pm 
Offline
Newbie
User avatar

Joined: Thu Jan 22, 2009 3:52 am
Posts: 4
Has thanked: 0 time
Have thanks: 0 time

what is the meaning of abstract class,concrete class and interface ?
can give example of each.

thanks


Last edited by msi_333 on Thu Jan 22, 2009 8:09 pm, edited 1 time in total.
edit title


TOP
 Profile Send private message  
Reply with quote  
 Question subject: Re: Pls Help me..
PostPosted: Thu Jan 22, 2009 8:09 pm 
Offline
Mastermind
User avatar

Joined: Tue Mar 27, 2007 10:55 pm
Posts: 2279
Location: Earth
Has thanked: 39 time
Have thanks: 61 time
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 alway 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
}
}




i hope i helped you .

_________________
Currenlty programming with : java , html , php , and javascript . (OCJP-6 certified )


TOP
 Profile Send private message  
Reply with quote  
 Question subject: Re: java abstract class,concrete class and interface
PostPosted: Sat Mar 21, 2009 4:53 am 
Offline
Newbie
User avatar

Joined: Fri Mar 20, 2009 4:03 am
Posts: 21
Location: Indonesia
Has thanked: 0 time
Have thanks: 0 time
Thank you for this information. I was facing an exam and the difference of these abstracts and interfaces confuses me a bit and now i am cleared. Thank you for the question raised by Dummies in Java and the explanation as well from msi_333

_________________
***
Miracle's in your hands
***
Do you Love stories? visit this : http://melyablackrose.blogspot.com/. I bet you won't be sorry


TOP
 Profile Send private message  
Reply with quote  
 Question subject: Re: java abstract class,concrete class and interface
PostPosted: Sat Mar 21, 2009 5:10 pm 
Offline
Mastermind
User avatar

Joined: Tue Mar 27, 2007 10:55 pm
Posts: 2279
Location: Earth
Has thanked: 39 time
Have thanks: 61 time
you are welcome .

_________________
Currenlty programming with : java , html , php , and javascript . (OCJP-6 certified )


TOP
 Profile Send private message  
Reply with quote  
Post new topic Reply to topic Quick reply  [ 4 posts ] 
Quick reply


  

 Similar topics
 video chat application in java
 navigating to database using java
 java mobile apps
 need help in java
 Read your gmail using Java code
 Java Programing to communicating port parallel
 Java Chat
 Steganography in java
 java code for listing folder contents from remote folder
 java

All times are UTC [ DST ]


Users browsing similar posts

Users browsing this forum: Yahoo [Bot] and 2 guests



Jump to:  
Previous Question | Next Question 




Home
General Talks
Finished Projects
Code Library
Games
Tutorials

Java
C/C++
C-sharp
php
Script
JSP/Servlets
Ajax
ASP/ASP.net
Google SEO
Database
Communications
Phpbb3 styles
Photoshop tutorials
Flash tutorials
Find a job






Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team