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

What are the role of keywords in java, What are the role of Keywords in jav...

What are the role of Keywords in java? Keywords are identifiers such as public, static and class in which have a special meaning inside Java source code and outside of comments

Opengts geozone violation alerts, Opengts Geozone violation alerts Proje...

Opengts Geozone violation alerts Project Description: I am seeking a very reliable, articulate and an experienced Java and MySQL developer to customize the Device Communicati

Talent agency system, Talent agencies like ICM, CAA and Paradigm represent ...

Talent agencies like ICM, CAA and Paradigm represent writers, directors and actors (among other talent).  These agencies take in hundreds of millions of dollars a year collecting 1

Need tomcat based iptv cms p2p, Need tomcat based iptv cms p2p , avrelay tr...

Need tomcat based iptv cms p2p , avrelay trans-coder software Project Description: Tomcat based iptv cms p2p tracker cdn included, avrelay for trans-coding h264, Skills re

Sudoku class used in java program, Sudoku Class (Simple Version) The ...

Sudoku Class (Simple Version) The Sudoku class will encapsulate the minimum necessary data and logic to manipulate, print, and set the SudCells , in anticipation of a high

I want multiplayer backgammon game, I want Multiplayer Backgammon Game P...

I want Multiplayer Backgammon Game Project Description: We want a multiplayer backgammon as short as well as long one. It should be free and on money also. The games fronted

Bluej, how to write a program to assign value of variable age and print if ...

how to write a program to assign value of variable age and print if person is major.

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