Latest Tutorials| Questions and Answers|Ask Questions?|Site Map




Have Programming Question? Ask it here!
 
 
 


SUJITHKUMAR.K.S
hai
2 Answer(s)      3 years and 4 months ago
Posted in : Java Beginners


bring out the oop features in java with examples?


Advertisement
View Answers

March 26, 2011 at 11:57 AM




March 26, 2011 at 12:14 PM


Encapsulation Example:

public class Box
{
private int length;
private int width;
private int height;

public void setLength(int p)
{length = p;}

public void setWidth(int p)
{width = p;}

public void setHeight(int p)
{height = p;}

public int displayVolume()
{System.out.println(length*width*height)...
}

public static void main(String args [ ])
{
Box b1=new Box(3,4,5);
b1.displayvolume();
}

}

Abstraction Example:

public class Animal
{
double energyReserves;

boolean isHungry() {
return energyReserves < 2.5;
}
void eat(Food f) {
energyReserves += f.getCalories();
}
public static void main(String[] args)
{
thePig = new Animal();
theCow = new Animal();
if (thePig.isHungry()) {
thePig.eat(tableScraps);
}
if (theCow.isHungry()) {
theCow.eat(grass);
}
}
}
/*In the above example, the class Animal is an abstraction used in place of an actual animal.*/

Inheritance Example



Related Tutorials/Questions & Answers:
hai
hai   when we click on submit button request doesnot go to next servlet instead of that that servlet simply downloaded why? can tell me plz   It seems that the problem lies in your code. Anyways, we are providing you
hai
hai   I am using windows 7 with 32 bit os I installed java 1.6 version I also installed oracle 10g. When I am trying to execute jdbc-odbc programs it simply displays "jdbc drivers not found" plz help me   Java
Advertisements
hai
hai  hai this is anitha , i am persuing my B.Tech. 3rd year,i am doing a mini project,my task is to develope a code in java,to generate a graph using sql database values. so,kindly help me with my mini
hai
hai
hai
hai
hai this is sql question
hai this is sql question  what are tables in home appliances web application
hai java - Java Beginners
hai java  what do u mean by unchecked exception and checked exception? and do any java pgm will run with out thread concept... and what si thread...  Hi Friend, Please visit the following link: http
matrix addition
matrix addition  hai
matrix addition
matrix addition  hai
matrix substraction
matrix substraction  hai
matrix substraction
matrix substraction  hai
j2me exception - MobileApplications
j2me exception  Hai
matrix determination in java
matrix determination in java  hai
matrix polynamial addtion
matrix polynamial addtion  hai
jdbc
jdbc  Hai , Give a steps for jdbc connectivity
jsp webapplication
jsp webapplication  hai Good mring to all
need sourcecode - Java Beginners
need sourcecode  Hai, I need program for packetization for videos
SWING FRMES
SWING FRMES  hai SIR? HOW TO DESIGN swing Frames send source code
SWING FRMES
SWING FRMES  hai SIR? HOW TO DESIGN swing Frames send source code
query optimization
query optimization  hai ! i need a code in java for database query optimization.plz help
for loop
for loop  hai, I need to write java program to print numbers in "X" format
String tokenizer class
String tokenizer class  Hai... What is string tokenizer class? & what's its purpose
String tokenizer class
String tokenizer class  Hai... What is string tokenizer class? & what's its purpose
String tokenizer class
String tokenizer class  Hai... What is string tokenizer class? & what's its purpose
length in array
length in array  hai wat s length in array and where it s used
Interface vs abstract class
Interface vs abstract class  Hai, Is there any possible to defining abstract methods in Interface
jsp
jsp  hai please give me the table grid code code for jsp
hibernate query
hibernate query  hibernate apache par kam karta hai kya   Hi Friend, Yes. Thanks
serverdeploymenterror
serverdeploymenterror  hai this anji i required how we configure weblogic server in myeclipseIDE? with detail steps regards anjireddy
database - JDBC
database  hai friend, yes i want to use java database connection in eclipse IDE. Thanks in advance
RARP program using java
RARP program using java   hai, how to implement the RARP concept using java
Search - Java Beginners
Search  hai, how will we can search diff type of files using j2me
Mapping Technics - Hibernate
Mapping Technics  Hai i want some clarifications about one-to-many bidirectional relationship
number - Java Interview Questions
number  apka number kya hai aap apna number mera id per send ker do
scan a image and upload to server
scan a image and upload to server  Hai i am beginner of Java ME..I want the code To scan a image and upload to server
coding for project
coding for project  hai how to write jsp coding for project smart accessories ...... that s to navigate to another page when you click on a tag
multiple fields in hashtable
multiple fields in hashtable  Hai,could anyone help me to implement the object car fields speed,make & color in Hash table
question
question  hai.......... i have one doubt can i have two actions for one button. please reply me soon thanks in advance
vc++ - IDE Questions
vc++  Hai Good Morning,I want clarification about Vc++ Subject.How to display output values .reply immediately
J2EE - JMS
J2EE  hai,This is jagadhish.Iam learning J2EE. I want to know the concept JMS.For that send some data and example programs plz.thank you (in advance
I'v a doubt - Java Beginners
I'v a doubt  Hai to all, How to break the mysql jar file, and import into the java file by without using any editiors. With regards, Terrance. J
without using built-in functions
without using built-in functions  Hai sir... Please help me to solve this... Findout occurances of each string in every another string (built - in functions are not at all allowed) all, and, sand, falling wall and sand
how to use group by in nested query
how to use group by in nested query  Hai, How to use group by clause in nested query select statement in subquery i am having where clause.please help me.thanks in advance
java coding
java coding  Hai,I am having order table in mysql database.when user click download button the order table data shows in csv format.Its very urgent.please help me. Thanks in advance
To scan a image encode that image in j2me
To scan a image encode that image in j2me  Hai team i am new man of j2me i have doubt to scan a image and encode the image in j2me... Please clarify that doubt... Thanks in Advance... Kumar
Java SMS Progam
Java SMS Progam  Hai to all, I have to send SMS alerts in my applicaton in java technology with out using any gateways and GSM Modems. Thanks
Advertisements
 

 

 

DMCA.com