Professional Documents
Culture Documents
CHAPTER IN BOOK- 6
CLASSES & METHODS
-K. Indhu
K. INDHU
GOALS
1. Introduction
2. Syntax for Class & Example for Class
3. Example for Class with Two Objects
4. Declaring Objects Syntax
5. Use of new Operator
6. Assigning Object Reference Variables
7. Methods Syntax & Example
8. Constructors Definition & Example
9. Three types of Constructors
10.Parameterized Constructors
11.This Keyword
12.Garbage Collection in Java Runtime Environment
13.Finalize() method
14.Stack Class Example with Output
K. INDHU
INTRODUCTION
K. INDHU
K. INDHU
K. INDHU
K. INDHU
ASSIGNING OBJECT
REFERENCE VARS.
K. INDHU
10
METHODS SYNTAX
K. INDHU
11
METHODS EXAMPLE
METHOD WITHOUT
RETURN VALUE
K. INDHU
12
METHODS EXAMPLE
CONTINUED
CREATE 2 OBJECTS
CALL FUNCTION
WITHOUT
RETURN VALUE
CALL FUNCTION
WITH RETURN
VALUE DOUBLE
K. INDHU
13
CONSTRUCTORS
14
CONSTRUCTORS EXAMPLE
K. INDHU
15
THREE TYPES OF
(1) DEFAULTCONSTRUCTORS
CONSTRUCTOR->
16
PARAMETRIZED
CONSTRUCTORS
K. INDHU
17
THIS KEYWORD
18
Like Below->
19
GARBAGE COLLECTION
Garbage Collection works like this:1. "When no references to an object exist, that object is
assumed to be no longer needed and the memory
occupied by the object can be reclaimed.
2. There is no explicit need to destroy objects as in C++."
K. INDHU
20
FINALIZE() METHOD
K. INDHU
21
K. INDHU
22
K. INDHU
23
K. INDHU
24
SO FAR WE STUDIED
Introducing Classes and Methods in Java
K. INDHU
25
HAPPY
LEARNING!!!