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

To change c code and place into a java application, To change c code and pl...

To change c code and place into a java application Project Description: To change c code and place into a java application Skills required are C Programming, Java, Softwar

Java collection framework., #question.Write a program that computes the edi...

#question.Write a program that computes the edit distance (also called the Levenshtein distance, for its creator Vladimir Levenshtein) between two words. The edit distance between

What happens to static fields of class during serialization, What happens t...

What happens to the static fields of a class during serialization? There are three exceptions in which serialization does not necessarily read and write to the stream. These

Develop news feed android app design template, Project Description: You ...

Project Description: You should give A Working, Sample Android .apk Project and Java source code Original Photoshop PSD that I can edit and customize to fit my needs All S

Explain the term- strings, Explain the term- Strings A string is genera...

Explain the term- Strings A string is generally considered to be a sequence of characters stored in memory and accessible as a unit. Strings in java are signified as objects

What is jsp page, A JSP page is a text-based document that having two types...

A JSP page is a text-based document that having two types of text: static template data, which can be expressed in any text-based format like HTML, SVG, WML, and XML, and JSP eleme

What does it mean that a method or class is abstract, What does it mean tha...

What does it mean that a method or class is abstract? An abstract class cannot be instantiated. Abstract methods may only be included in abstract classes. However, an abstract

Write responsibility of developer-executive -support team, Write responsibi...

Write responsibilities of the followings 1. Developer a) Module level design. b) Coding c) Unit testing 2. Executive Team a) Responsible for the day to day operations. b) A

Developing a prototype system in php and javascript, General Overview A...

General Overview A number of organisations are using micro-blogging as a cost-effective way of communicating with customers, building online communities and releasing informati

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