Wednesday, 12 August 2015

Object and Class:

OOPS (Object Oriented Programming Systemis a programming approach which provides solution to problems with the help of algorithms based on real world. It uses real world approach to solve a problem.

Main Oops concepts are : 

  • Inheritance
  • Polymorphism
  • Encapsulation
  • Abstraction

Class : A class is declared using class keyword. A class is a blue print or set of instruction to bind the data with its related and corresponding functions. 

A Class can contain :-
  1. Fields
  2. methods,
  3. constructors
  4. objects 
Syntax: 
                                              
class <class_name>{ 
    field; 
    method; 
}

Object :

An object is an entity which contain state and behaviour. Object is nothing but instance of a class.
An object has three characteristics:

  • State : represent state of an object.
  • Behaviour: represent behaviour of an object. The functionalities associated with the object => Behavior of the object.
  • Identity: represent identity of an object.
Ways to initialize an object : 
  • Using New keyword
  • Class.forName()
  • Using Clone()
  • Using Deserilization
For more details click here 

How a class is initialized in java?

A Class is initialized in Java when an instance of class is created using either new operator or using reflection using class.forName(). A class is also said to be initialized when a static method of Class is invoked or a static field of Class is assigned.

No comments:

Post a Comment

No of Occurrence in Array

package com.tutorial4u; import java.util.HashMap; /************************************************************  No of Occurrence in Array...