What is object oriented programming explain with an example, JAVA Programming

Assignment Help:

What is Object Oriented Programming explain with an example?

In Java everything is an object or a class (or a piece of one or a collection of various).
Objects send messages to each other through calling methods.
Instance techniques belong to a particular object.
Static techniques belong to a particular class.

Example 1: The Car Class

Suppose you required writing a traffic simulation program in which watches cars going past an intersection. Each car has a speed, a maximum speed, and a license plate in which uniquely identifies it. In traditional programming languages you'd have two floating point and one string variable for each car. With a class you combine these within one thing like this.
class Car {

String licensePlate; // e.g. "New York 543 A23"
double speed; // in kilometers per hour
double maxSpeed; // in kilometers per hour

}
These variables (licensePlate, speed and maxSpeed) are called the member variables, instance variables, or fields of the class.
Fields tell you what a class is and what its properties are.

An object is a specific instance of a class along with particular values (possibly mutable) for the fields. Although a class is a general blueprint for objects, an instance is a particular object.

Remember the use of comments to specify the units. That's significant. A unit confusion between pounds and newtons led to the loss of NASA's $94 million Mars Climate Orbiter. (Believe it or not that's a cheap mission by NASA standards. If you're rich enough in which you don't have to worry about losing $94 million worth of work, you don't have to put comments in your source code. Everybody else has to use comments.)

How would you write an Angle class?


Related Discussions:- What is object oriented programming explain with an example

Area under curve , what will be the logic? in C program #include ...

what will be the logic? in C program #include float start_point, /* GLOBAL VARIABLES */ end_point, total_area; int numtraps; m

Data access objects (DOA) in JDBC, Business Objects represent the data cl...

Business Objects represent the data client. They are the objects that need access to the datasource to obtain and store data. Data Access Objects abstract the relying data access i

I need a dcs source code and jar, I need a DCS (Source code and JAR) to pro...

I need a DCS (Source code and JAR) to process packets from a cheap chinese GPS TK110, the unit is already communicating with the server but is not parsing. So I need someone with e

What is operator overloading, What is Operator Overloading? A few objec...

What is Operator Overloading? A few object oriented languages, notably C++, permit you to not only overload techniques but also operators like + or -. This is very menaingful w

HOW TO MAKE A TRANSCRIPT, Write a java program that computes the scores of ...

Write a java program that computes the scores of 10 students in the following units; 1.Java 2.PHP 3.Python 4.C++ 5.Perl Generate a transcript.

Explain what is fontmetrics in java, Explain what is FontMetrics in Java? ...

Explain what is FontMetrics in Java? No word wrapping is completed when you draw a string in an applet, even if you embed newlines in the string along with \n. If you expect th

What do you mean through ftp or file transfer protocol, What do you mean th...

What do you mean through FTP or File Transfer Protocol? FTP: File transfer protocol was first introduced in the year of 1973; it standardized the transfer of files among comp

What is public static void main signifies, What is 'public static void main...

What is 'public static void main (String args[ ] ) ' signifies? Access specifier is the 'public' keyword. 'static' keyword allows main() to called without instantiating

Describe the life cycle methods of a jsp? , 1. Pre-translated: Before the...

1. Pre-translated: Before the JSP file has been compiled and translated into the Servlet. 2. Translated: The JSP file has been compiled and translated as a Servlet. 3. I

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd