0% found this document useful (0 votes)
131 views13 pages

Java Objects and Classes Overview

The document discusses objects and classes in Java programming. It defines objects as instances of classes that contain data fields and methods. Classes contain implementation details and interfaces for programmers. The document provides examples of built-in library classes in Java and how objects store state in data fields and exhibit behavior through methods. It also covers how to access class members and the use of the "this" keyword to refer to the current object.

Uploaded by

Amitabh Kumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
131 views13 pages

Java Objects and Classes Overview

The document discusses objects and classes in Java programming. It defines objects as instances of classes that contain data fields and methods. Classes contain implementation details and interfaces for programmers. The document provides examples of built-in library classes in Java and how objects store state in data fields and exhibit behavior through methods. It also covers how to access class members and the use of the "this" keyword to refer to the current object.

Uploaded by

Amitabh Kumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd

Department of Computer Science and Engineering (CSE)

JAVA Programming (CST-254)

Objects & Classes

University Institute of Engineering (UIE)


Department of Computer Science and Engineering (CSE)

Objects & Classes


Synonymous with data type
Object is like variable
data type is some Class
an instance of a Class

Classes contain:
implementation details
interface for programmers

Objects are complex variables


multiple pieces of internal data
carried out via methods

University Institute of Engineering (UIE)


Department of Computer Science and Engineering (CSE)

Objects & Classes


built in library of classes
String
Math
System
Arrays
Scanner
File

University Institute of Engineering (UIE)


Department of Computer Science and Engineering (CSE)

Objects & Classes

An object

data field 1
A Circle object
... State Data Field
radius = 5
data field n

method 1
Method
findArea
... Behavior

method n

University Institute of Engineering (UIE)


Department of Computer Science and Engineering (CSE)

Objects & Classes

University Institute of Engineering (UIE)


Department of Computer Science and Engineering (CSE)

Objects & Classes

University Institute of Engineering (UIE)


Department of Computer Science and Engineering (CSE)

Objects & Classes

Primitive type int i = 1 i 1

Object type Circle c c reference

c: Circle
Created using
new Circle() radius = 1

University Institute of Engineering (UIE)


Department of Computer Science and Engineering (CSE)

Objects & Classes


Primitive type assignment Object type assignment
i=j c1 = c2

Before: After: Before: After:

i 1 i 2 c1 c1

j 2 j 2 c2 c2

c1: Circle c2: Circle

radius = 5 radius = 9

University Institute of Engineering (UIE)


Department of Computer Science and Engineering (CSE)

Objects & Classes


Accessing Class Members
Objectname.variablename=value;
Objectname.methodname(parameter-list);
Declared using static modifier

Methods
declared inside the body
after declaring variables.

The general form of a method declaration is


Type methodname (parameter-list)
{
method-body;
}

University Institute of Engineering (UIE)


Department of Computer Science and Engineering (CSE)

Objects & Classes


The Keyword this
refer the current object.
invoke current class constructor.

University Institute of Engineering (UIE)


Department of Computer Science and Engineering (CSE)

Objects & Classes

University Institute of Engineering (UIE)


Department of Computer Science and Engineering (CSE)

Objects & Classes

University Institute of Engineering (UIE)


Department of Computer Science and Engineering (CSE)

THANKS..

University Institute of Engineering (UIE)

You might also like