abstraction

abstraction

give a simple example program for abstraction

View Answers

March 26, 2011 at 2:55 PM

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.*/

March 26, 2011 at 2:56 PM

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.*/

March 26, 2011 at 7:24 PM

thak u dude

Ads









Related Tutorials/Questions & Answers:
abstraction
abstraction  give a simple example program for abstraction   public class Animal { double energyReserves; boolean isHungry() { return... is an abstraction used in place of an actual animal
abstraction
abstraction  give a simple example program for abstraction  ... is an abstraction used in place of an actual animal.*/   public class Animal...); } } } /*In the above example, the class Animal is an abstraction used in place
Advertisements
ModuleNotFoundError: No module named 'abstraction'
ModuleNotFoundError: No module named 'abstraction'  Hi, My Python... 'abstraction' How to remove the ModuleNotFoundError: No module named 'abstraction' error? Thanks   Hi, In your python environment
encapsulation vs abstraction
encapsulation vs abstraction  what is the difference between encapsulation and abstraction
Abstraction In Java for Java beginners
Abstraction In Java for Java beginners  Hi, As a beginner in Java I am looking for good tutorial that explains the Abstraction concept in Java... of Abstraction in Java? Thanks   Hi, What is abstraction in Java
What is Abstraction In Java?
What is Abstraction In Java?  Hi, What is Abstraction In Java? How to use the Abstraction In Java to write program? Thanks   Hi, Suppose... external access. This process of hiding/securing the class is know as Abstraction
Abstraction In Java
Abstraction In Java In this section we will read about the abstraction in Java. Java is an Object Oriented Programming language and Abstraction is one of the feature of OOPs i.e. Java has the feature of abstraction. In Java abstraction
diff between encapsulation and abstraction code
diff between encapsulation and abstraction code  diff between encapsulation and abstraction code
ModuleNotFoundError: No module named 'project-abstraction'
ModuleNotFoundError: No module named 'project-abstraction'  Hi, My... named 'project-abstraction' How to remove the ModuleNotFoundError: No module named 'project-abstraction' error? Thanks   Hi
Spring Abstraction with Redis
Spring Abstraction with Redis  Hi.. I have implemented @Cacheable for one method like @Cacheable("parameter1") public String getCompaniesList(String parameter1, String parameter2) throws Exception { //code
Abstraction in Java
Abstraction in Java Abstraction is one of the four pillar of OOPS Concept. Abstraction in java is a process by which hiding the irrelevant data  and exposing only the essential feature of object. In java Abstraction
diff between encapsulation and abstraction code with output
diff between encapsulation and abstraction code with output   diff between encapsulation and abstraction code with output
diff between encapsulation and abstraction code with output
diff between encapsulation and abstraction code with output   diff between encapsulation and abstraction code with output
diff between encapsulation and abstraction code with output
diff between encapsulation and abstraction code with output   diff between encapsulation and abstraction code with output
How to make query and abstraction in Java
How to make query and abstraction in Java  Hi, I read the lessons you have in the sites. They are really useful. However, I could not write codes... PostgreSQL database, and I want to make a query and abstraction for a table. Could
Abstraction in Java 7
Abstraction in Java 7 This section elaborate about abstraction. It is one of OOPs concept. Abstraction :  Abstraction means hiding the unnecessary... or object.  In java, you can see concept of abstraction whenever you use
ModuleNotFoundError: No module named 'object_store_abstraction'
ModuleNotFoundError: No module named 'object_store_abstraction'  Hi...: No module named 'object_store_abstraction' How to remove the ModuleNotFoundError: No module named 'object_store_abstraction' error? Thanks  
ModuleNotFoundError: No module named 'osm-bot-abstraction-layer'
ModuleNotFoundError: No module named 'osm-bot-abstraction-layer'  Hi...: No module named 'osm-bot-abstraction-layer' How to remove the ModuleNotFoundError: No module named 'osm-bot-abstraction-layer' error? Thanks  
ModuleNotFoundError: No module named 'python-sql-abstraction'
ModuleNotFoundError: No module named 'python-sql-abstraction'  Hi...: No module named 'python-sql-abstraction' How to remove the ModuleNotFoundError: No module named 'python-sql-abstraction' error? Thanks   Hi
ModuleNotFoundError: No module named 'simple-sql-abstraction'
ModuleNotFoundError: No module named 'simple-sql-abstraction'  Hi...: No module named 'simple-sql-abstraction' How to remove the ModuleNotFoundError: No module named 'simple-sql-abstraction' error? Thanks   Hi
ModuleNotFoundError: No module named 'zaber-zerp-wamp-abstraction'
ModuleNotFoundError: No module named 'zaber-zerp-wamp-abstraction'  ...: No module named 'zaber-zerp-wamp-abstraction' How to remove the ModuleNotFoundError: No module named 'zaber-zerp-wamp-abstraction' error? Thanks
how to do abstraction for insurance policy being issued...
how to do abstraction for insurance policy being issued...  an insurance policy is being insured.... now what will be the classes for policy and how to do abstraction of the same
Difference between Encapsulation and Abstraction in Java
and Abstraction in Java. Encapsulation is a process of hiding all the data and methods within a class from outside world. Abstraction on the other hand.... Abstraction in Java is represented by Interface, Abstract class, Abstract methods
An exercise using (SRS) as a blue print for Abstraction and Modeling in a one page answer. Was this example correct?
An exercise using (SRS) as a blue print for Abstraction and Modeling in a one page answer. Was this example correct?  The software tool to help automate the process of producing a blueprint for problems with a television
Java Data Objects
Java Data Objects       The Java Data Objects (JDO) API is a specification of Java model abstraction of persistence, that is developed under the supervision of the Java Community
Abstract Factory Pattern
Abstract Factory Pattern       II Abstract Factory Pattern :  This pattern is one level of abstraction higher than factory pattern. This means that the abstract factory returns
Encapsulation in Java
Encapsulation along with Inheritance, Polymorphism, and Abstraction are the four concepts of Object Oriented Programming (OOPs). Encapsulation in Java is the technique of binding or wrapping the data and the codes in a class private
java interview question
java interview question  when will we use abstraction or interface
oops concepts
oops concepts  What is polymorphism?Explain with an example. What is abstraction?Explain with an example. What is inheritance?Explain with an example. What is encapsulation?Explain with an example
hi plzz reply
of abstraction Plz reply i m trying to learn java ...   means in language of coding we r not using abstraction this will be used only for making ideas... ..   Abstraction is the feature of OOPS in which we show the essential
Encapsulation versus Absraction
Encapsulation versus Absraction  I believe no one in this world knows real difference between Encapsulation and Abstraction , one of them is me as well but if there is anyone who really understand the difference please help me
Is Java object oriented?
Is Java object oriented?  Hi, Is Java object oriented? Thanks   Hi, Java is object oriented programming language. It is supports OPPS concepts: Object Class Inheritance Polymorphism Abstraction Encapsulation All
Cajax
JavaScript. User abstraction layer plug-in through XMLHTTPRequest for submitting
arraylist
Duplicates from ArryaList   Encapsulation And Abstraction   
servlets
abstraction in the Servlet API is the Servlet interface. All servlets implement
OOPs concepts in Java
Object Inheritance Encapsulation Abstraction Polymorphism Class: Class... of old general class. This reduces the development time. Abstraction: Abstraction in Java shows the essential features of the object that are relevant
hai
); b1.displayvolume(); } } Abstraction Example: public class Animal { double...); } } } /*In the above example, the class Animal is an abstraction used in place
Structural Patterns
is that class patterns describe abstraction using inheritance and describe how it can
Java7 : OOPs Concepts
following concepts: Abstraction Encapsulation Inheritance Polymorphism Abstraction : Abstraction means hiding the unnecessary information to the user
Polymorphism
Polymorphism        OOPs revolve around the four concepts: 1. Encapsulation 2. Polymorphism 3. Abstraction 4. Inheritance In OOPs, these concepts are implemented through
Difference between abstract class and an interface
for which we cannot create object of it. Interface is known for fully abstraction... abstract and interface is a way to achieve abstraction in java. Now here, we
What is Spring?
a generic abstraction layer for transaction management. This allowing...: The JDBC abstraction layer of the Spring offers a meaningful exception... transaction abstraction. To allow users to implement
What Is OOPS In Java
concepts such as, Inheritance, Polymorphism, Encapsulation, Abstraction, etc... the properties.   Abstraction : Abstraction is the special feature of OOPs
Bridge Pattern
the relationship among the objects.  Benefits: It separates the abstraction from the implementation details. Inheritance tightly couples the abstraction... by extending independency between the abstraction and the implementation. Usage
Inheritance
Inheritance        OOPs revolve around the four concepts: 1. Encapsulation 2. Polymorphism 3. Abstraction 4. Inheritance In OOPs, these concepts are implemented through a class
Java DB
)   The Java Data Objects (JDO) API is a Java model abstraction
OOP
concepts: 1. Encapsulation 2. Polymorphism 3. Abstraction 4. Inheritance In OOPs
Encapsulation
Encapsulation       OOPs revolve around the four concepts: 1. Encapsulation 2. Polymorphism 3. Abstraction 4. Inheritance In OOPs, these concepts are implemented through a class
Software Design
as abstraction. The process of refinement and abstraction are complementary
Interface in Java
oriented concept. Through interface only abstraction is achieved in java. Syntax...: With the help of  Interface  fully abstraction is achieved in 

Ads