OBJECT ORIENTED FUNDAMENTALS

What  is object oriented programming?

—Object means a real-world entity
—Object-Oriented Programming is a methodology  to design a program using classes and objects
OOPS CONCEPTS

1)OBJECT

—An entity that has state and behavior is known as an object .
—The object is an instance of a class.
—
2)CLASS
—A class is a group of objects which have common properties.
— It is a template or blueprint from which objects are created.
—It is a logical entity. It can't be physical.
3)INHERITANCE
— which one object acquires all the properties and behaviors of a parent object.
4) POLYMORPHISM
—we can perform a single action in different ways.
5)ABSTRACT
—Hiding internal details and showing functionality is known as abstraction.
6)ENCAPSULATION
—Encapsulation  is a process of wrapping code and data together into a single unit.
—Encapsulation in Java is a process of wrapping code and data together into a single unit.
—We can create a fully encapsulated class in Java by making all the data members of the class private.
—Now we can use setter and getter methods to set and get the data in it.
ADVANTAGE OF ENCAPSULATION
—control over the data
— data hiding
—easy to test
EXAMPLE 1
class t  test.java
{
  private String a;
  private String b;
  public void seta(String name)
  {
  a=name;
  }
  public void setb(String nam)
  {
  b=nam;
  }
  void disp()
  {
  System.out.println(a+b);
  }
  public String geta()
  {
  return a;
  }
  public String getb()
  {
  return b;
  }
}

Comments

Popular posts from this blog

UNIT II---WORKING WITH ARRAYS AND FUNCTIONS

CHARACTERISTICS OF JAVA

JAVA ARRAY