Introduction to Object and Class in Java


OBJECT

An object is an identifiable entity with some characteristics & behavior.

 Eg. 1. Orange, 2. chair .

Characteristics

 1. It is spherical shape and color is orange .   2. It has four legs, back and arms 

 Behaviour

1.It is citrus in nature and taste sour.
2. It lets you sit on it.

Note:-Object interact with each other by passing message.

Creating a class

 <Access Specifier> class <class name> { 

//data members; variable used by member methods 

// member methods; to perform some specific task 


Creating a object 

<class name > < object name> = new <class name >(); 


Basic concept of OOP (Object Oriented Programming) 

1. Abstraction refers to the act of representing essential features without including the background details or expressions.

 2. Encapsulation the wrapping of data (characteristics) and functions (behaviour) into a single unit (class) is known as encupsulation.

 3. Inheritance is the capability of one class of things to inherit capabilities and properties from another class .
i) Super class or base class (parent class) : The class from which the other class inherits the properties .
ii) Derived or sub class (child class) : The class which inherits the properties from other class .

4. Polymorphism is the ability for a message or data to be processed in more than one form.(function/constructor overloading). p.

5. Dynamic Binding: It is the process that links the function - call with function signature at runtime.


The object is implemented in software term as follows. 

1. Characteristics & Attributes are implemented through member variables or data items of the objects .

2. Behaviour is implemented through member function called methods/function.

Class

Class represents a set of objects that share common  characteristics & behaviour. 

i )A class is an object maker or object factory because it contains all the statements needed to create an object. It attributes as well as statements to describe the operation that the object will be able to perform. 

 1.Source program the program written in high level language by programmer is called source code.

2. Object Code or Machine Code Computer needs source code to be converted into low level language to be executed and the code is saved with .class extension The difference between .class and java is that when we save a source file it is saved with java and after compilation the machine code is saved with .class .
3. Compiler/Interpreter : They both are used for translate HLL(High Level Language) into machine language. Compiler does it at once wile , interpreter does it line by line.

 4. Java Virtual Machine (JVM) is a JAVA internreter which translates byte code for specific platforms.

1.Java reserve words : reserve words or key words are those words, which are preserved with the system. These words carry the special meaning and can’t be taken as variable name. Comments Symbols: there are three type of Comments in java program 


1. Document comment: /** isa document comment */ .

 2. Single line comment: // it is a single line comment

 3. Multi Line comment: // it is . 


c Multi line Comment */ 


Output Statements is java : 


1. System.out.prinitn( “ it print on current line then change line”); 

2. System.out.print(” It print on current line”); 


Input Statement in Java : Using BufferedReader or Scanner class input operation can be performed. 


Difference between JDK and BLUE J 


JDK : It is dos based, uses command for compilation. Sample program appears.


Blue j: It is windows based platform uses menu driven approach for compilation. Sample program appears. 


Constructor : A member function with the same name as its class is called Constructor and it is used to initialize the object of that class type with a legal initial value. Constructor are three type . 


i) Default constructor : Assign default values to the data members of the class. 

ii) Parameterized Constructor : assign parameterized values to the data members of the class. 

iii) Copy Constructor : it is used to copy the object value to the data members of the class 


Class member : static members are called class members because they share the same memory. 

Instant members: Non static members are called instant members because they share the different memory.



Post a Comment

0 Comments