abstraction

abstraction

give a simple example program for abstraction

View Answers

March 26, 2011 at 2:53 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.*/









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
Abstraction in flex
Abstraction in flex  Hi... What keyword allows you to implement abstraction better? please tell me about it.... ThanksADS_TO_REPLACE_1   Ans: Flex does not support abstart class directly. ThanksADS_TO_REPLACE_2
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
Java abstraction - Java Beginners
Java abstraction  Is abstraction and abstract class are related ar same
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 : Java Glossary
Abstraction : Java Glossary   .... Encapsulation 2. Polymorphism 3. Abstraction 4. Inheritance In OOPs, these concepts... creation process, programmatically. Here we will discuss Abstraction briefly
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
What is Abstraction - Java Beginners
What is Abstraction  What is abstraction in java? How is it used in java..please give an example also  Hi Friend, Abstraction is nothing but data hiding.It involves with the dealing of essential information
Abstraction in java - Java Interview Questions
Abstraction in java  Abstraction in java - I know its a very basic question that i can find anywhere else as well... but i am looking for a description as well as an example on Abstraction in java. can anyone
Encapsulation & Abstraction - Java Interview Questions
Encapsulation & Abstraction  What is the difference between Encapsulation and Abstraction
Encapsulation & Abstraction - Java Interview Questions
Encapsulation & Abstraction  What is the difference between Encapsulation and Abstraction
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
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
Java abstraction - Java Beginners
Java abstraction  what is abstraction in java please explain with example  Hi, Abstract Class Abstract classes are those that works only as the parent class or the base class. Subclasses are derived to implement
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 '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 '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 '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
ABSTRACTION AND INTERFACE - Java Interview Questions
ABSTRACTION AND INTERFACE  When Use Abstract?When Use Interface ?I Want Explanations?plz help me  Hi Friend, When we do not want to allow any one to create object of our class, we define the class as abstract. When
Encapsulation VS Abstraction - Java Beginners
Encapsulation VS Abstraction  Real Time sample code for Encapsulation and Abstraction. where to use abstract and where to use specifies like public...(); } Abstraction-The process of abstraction in Java is used to hide certain details
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
OOPS Concept Abstraction with example - Java Beginners
OOPS Concept Abstraction with example  I am new to java. In java OOPS concept Abstraction means abstract or something. Please explain it with one example  Hi Friend, The process of abstraction in Java is used
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
Java Abstraction - Java Beginners
Java Abstraction - Java Beginners
classes and data abstraction - Java Beginners
for Mexican pesos, f for Swiss francs, e for Euro dollars or q to quit...() is called. If the user enters 'q', the data member more is set to false to allow
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
Java Data Objects
Java model abstraction of persistence, developed as Java Specification Request
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
SCJP Module-1 Question-27
Java beginner - Java Beginners
Java beginner  what is the diffrence between abstraction and interface? with coding
java interview question
java interview question  when will we use abstraction or interface
pls help me with this question
pls help me with this question  how to write a program in C++ using encapsulation,polymorphism,inheritance and abstraction?(all these concepts should come in a single program
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
Theory - Java Beginners
Theory  1) Define Polymorphism 2)Define Function 3)What is composite Data type? 4)How does a class represent abstraction of a real world entity...)? 6)How does a class accomplish abstraction? Program code required::: I
Theory - Java Beginners
Theory  1) Define Polymorphism 2)Define Function 3)What is composite Data type? 4)How does a class represent abstraction of a real world entity...)? 6)How does a class accomplish abstraction? Program code required::: I
Theory - Java Beginners
Theory  1) Define Polymorphism 2)Define Function 3)What is composite Data type? 4)How does a class represent abstraction of a real world entity...)? 6)How does a class accomplish abstraction? Program code required::: I

Ads