0

Object-Oriented Programming and Java

Object-Oriented Programming and Java

java Programming

 

Today you’ll get an overview of object-oriented programming concepts in Java and how they relate to how you structure your own programs:

  • What classes and objects are and how they relate to each other
  • The two main parts of a class or object: its behaviors and its attributes
  • Class inheritance and how inheritance affects the way you design your programs
  • Some information about packages and interfaces
What does this have to do with programming ? Everything. Object-oriented programming works in exactly this same way. Using object-oriented programming, your overall program is made up of lots of different self-contained components (objects), each of which has a specific role in the program and all of which can talk to each other in predefined ways.

 Objects and Classes

Object-oriented programming is modeled on how, in the real world, objects are often made up of many kinds of smaller objects. This capability of combining objects, however, is only one very general aspect of object-oriented programming. Object-oriented programming provides several other concepts and features to make creating and using objects easier and more flexible, and the most important of these features is classes.

When you write a program in an object-oriented language, you don’t define actual objects. You define classes of objects, where a class is a template for multiple objects with similar features. Classes embody all the features of a particular set of objects.

A class is a generic template for a set of objects with similar features.

An instance of a class is another word for an actual object. If class is the general (generic) representation of an object, an instance is its concrete representation. So what, precisely, is the difference between an instance and an object? Nothing, really. Object is the more general term, but both instances and objects are the concrete representation of a class. In fact, the terms instance and object are often used interchangeably in OOP.

An instance is the specific concrete representation of a class. Instances and objects are the same thing.

If you’re used to programming in C, you can think of a class as sort of creating a new composite data type by using struct and typedef.When you write a Java program, you design and construct a set of classes. Then when your program runs, instances of those classes are created and discarded as needed. Your task, as a Java programmer, is to create the right set of classes to accomplish what your program needs to accomplish.

The Java environment comes with a standard set of classes (called a class library) that implement a lot of the basic behavior you need-not only for basic programming tasks (classes to provide basic math functions, arrays, strings, and so on), but also for graphics and networking behavior. In many cases, the Java class libraries may be enough so that all you have to do in your Java program is create a single class that uses the standard class libraries.

A class library is a collection of classes intended to be reused repeatedly in different programs. The standard Java class libraries contain quite a few classes for accomplishing basic programming tasks in Java.

 Behavior and Attributes

Every class you write in Java has two basic features: attributes and behavior. In this section you’ll learn about each one as it applies to a theoretical simple class called CodingTAlks. To finish up this section, you’ll create the Java code to implement a representation of a CodingTalks.

Attributes

Attributes are the individual things that differentiate one object from another and determine the appearance, state, or other qualities of that object. Let’s create a theoretical class called CodingTalks. A CodongTalks class might include the following attributes and have these typical values:

  • Color: red, green, silver, brown
  • Style:  Simple, standard
  • Make: php, HTML,Java Script

Attributes of an object can also include information about its state; for example, you could have features for SiteEngine condition (off or on).

Attributes are defined in classes by variables. Those variables’ types and names are defined in the class, and each object can have its own values for those variables. Because each instance of a class can have different values for its variables, these variables are often called instance variables.

 Behavior

A class’s behavior determines how an instance of that class operates; for example, how it will “react” if asked to do something by another class or object or if its internal state changes. Behavior is the only way objects can do anything to themselves or have anything done to them.

To define an object’s behavior, you create methods, a set of Java statements that accomplish some task. Methods look and behave just like functions in other languages but are defined and accessible solely inside a class. Java does not have functions defined outside classes (as C++ does).

Methods are functions defined inside classes that operate on instances of those classes.

While methods can be used solely to operate on an individual object, methods are also used between objects to communicate with each other. A class or an object can call methods in another class or object to communicate changes in the environment or to ask that object to change its state.



You Need "Object-Oriented Programming and Java" ???


"Object-Oriented Programming and Java" (Source Code / Report / PPT) Totally belong to CodingTalks Team and We always ready to Share our Stuff with our users. If you are Very Much Interested on This Topic Then you must Leave a Comment what Exactly you Looking For Or Send us Email to get Full Information.

Coding Talks
Team

Filed in: Java Tags: , ,

Get Updates

Share This Post

Related Posts

Leave a Reply

Submit Comment

© 2017 CodingTalks. All rights reserved.

Warning: filemtime(): stat failed for /home/codingtalks/public_html/wp-content/plugins/floating-social-share-bar//js/waypoints.min.js in /home/codingtalks/public_html/wp-content/plugins/floating-social-share-bar/floatingshare.php on line 213