SlideShare a Scribd company logo
Pundra University of Science & Technology
Department of Computer Science & Engineering
Name: Md. Sihab Uddin
Batch No: 6th
Semester No: 4th
Roll No: 05
Outline
• Program Structure
• Concept of Class
• Concept of Object
• Concept of Constructor
• Method
Program Structure
• Structure
Import Statement
Package Statement
Class Definition
Inheritance Statement
Interface Statement
Main Method
Concept of Class
• A class is simply a representation of a type of object
• It is the blueprint/ plan/ template that describe the
details of an object
• For example- mango, apple, orange are the members of
the class fruits
• If fruits has been defined as a class, then the statement
Fruits mango;
• It will create an object mango belonging to the class
fruit
Cont……..
• Java is a case-sensitive language
• Class declaration
• Opening braces
• The main line
• The output line
Class Csepu
{
Public static void main (String args[])
{
System.out.println(“Java is better than C++”);
}
}
Cont……………
• Class declaration
Class Csepu
– This line uses the keyword class to declare that a new class is
being defined
– Csepu is the name of the class
• Opening braces
{
……
}
– The class definition begins with the opening curly brace ({) and
ends with the closing curly brace (}).
– The elements between the two braces are members of the class
Cont………..
• The main line
Public static void main (String args[])
– The keyword public means that the method main() can
be accessed by any other Java class.
– The keyword static means that you don’t have to create
an instance of this class to use this method.
– The keyword void means that the method main()
doesn’t return any value to the calling program.
– The keyword String[] args tells us that this method
will receive an array of characters as the argument
Cont…….
• The Output line
System.out.println(“Java is better than C++”);
– This is similar to the printf() statement of C
– Since Java is a true object oriented language, every method
must be part of an object
– The println method is a member of the out object, which is
a static data member of System class
– The method println always appends a newline character to
the end of the string
– This means that any subsequent output will start on a new
line
Object
• Objects are instances of a class. It is the building block
of OOP.
• They are the basic runtime entities in an object
oriented system
• They may present a person, a place, a bank account, a
table of data or any item that the program may handle
• Object must have the following three characteristics:
– Identity
– State
– Behavior
Concept of Constructors
• A constructor initializes an object when it is created
• It has the same name as its class and is syntactically similar to a method
• However, constructors have no explicit return type
• simple example class Adition
{ public void add()
{int a,b,add;
a=4;b=5;
add=a+b;
System.out.println("Result of Add:
"+add);
}
}
public class Exmcons1
{ public static void main (String args[])
{
Adition obj = new Adition();
obj.add();
}
}
Concept of Methods
• Methods are the interface or communications between
program components
• A Java method is a collection of statements that are grouped
together to perform an operation
• As an example when we call the System.out.println method…
– The system actually executes several statements in order to
display a message on the console
– In general, a method has the following syntax
Modifier returnValueType methodName (list of parameters)
{
//method of body;
}
Cont…………..
Declaring a Methods
• Modifiers
– The modifier, which is optional, tells the compiler how
to call the method
– This defines the access type of the method
• Return Type
– A method may return a value
– The returnValueType is the data type of the value the
method returns
– Some methods perform the desired operations without
returning a value
– In this case, the returnValueType is the keyword void
Cont………….
• Method Name
– This is the actual name of the method
– The method name and the parameter list together constitute
the method signature
• Parameters
– A parameter is like a place holder
– When a method is invoked, pass a value to the parameter
– This value is referred to as actual parameter or argument
– The parameter list refers to the type, order, and number of
the parameters of a method
– Parameters are optional; that is, a method may contain no
parameters
Cont………….
• Method Body
– The method body contains a collection of statements that define
what the method does
• Example
– The following defined method called max()
– This method takes two parameters num1 and num2 and returns
the maximum between the two
public static int max(int num1, int num2)
{
int result;
if (num1 > num2)
result = num1;
else
result = num2;
return result;
}

More Related Content

What's hot (20)

Strings in Java
Strings in Java
Abhilash Nair
 
Wrapper class
Wrapper class
kamal kotecha
 
Classes, objects in JAVA
Classes, objects in JAVA
Abhilash Nair
 
Interfaces in java
Interfaces in java
Abishek Purushothaman
 
Java program structure
Java program structure
shalinikarunakaran1
 
Inter Thread Communicationn.pptx
Inter Thread Communicationn.pptx
SelvakumarNSNS
 
Methods in java
Methods in java
chauhankapil
 
Data types in java
Data types in java
HarshitaAshwani
 
Control statements in java
Control statements in java
Madishetty Prathibha
 
20.3 Java encapsulation
20.3 Java encapsulation
Intro C# Book
 
Packages in java
Packages in java
Kavitha713564
 
Operator overloading and type conversion in cpp
Operator overloading and type conversion in cpp
rajshreemuthiah
 
Generics in java
Generics in java
suraj pandey
 
Java abstract class & abstract methods
Java abstract class & abstract methods
Shubham Dwivedi
 
Classes objects in java
Classes objects in java
Madishetty Prathibha
 
Understanding java streams
Understanding java streams
Shahjahan Samoon
 
Static Members-Java.pptx
Static Members-Java.pptx
ADDAGIRIVENKATARAVIC
 
Chapter 02: Classes Objects and Methods Java by Tushar B Kute
Chapter 02: Classes Objects and Methods Java by Tushar B Kute
Tushar B Kute
 
Exception handling in java
Exception handling in java
Pratik Soares
 
Java interfaces & abstract classes
Java interfaces & abstract classes
Shreyans Pathak
 
Classes, objects in JAVA
Classes, objects in JAVA
Abhilash Nair
 
Inter Thread Communicationn.pptx
Inter Thread Communicationn.pptx
SelvakumarNSNS
 
20.3 Java encapsulation
20.3 Java encapsulation
Intro C# Book
 
Operator overloading and type conversion in cpp
Operator overloading and type conversion in cpp
rajshreemuthiah
 
Java abstract class & abstract methods
Java abstract class & abstract methods
Shubham Dwivedi
 
Understanding java streams
Understanding java streams
Shahjahan Samoon
 
Chapter 02: Classes Objects and Methods Java by Tushar B Kute
Chapter 02: Classes Objects and Methods Java by Tushar B Kute
Tushar B Kute
 
Exception handling in java
Exception handling in java
Pratik Soares
 
Java interfaces & abstract classes
Java interfaces & abstract classes
Shreyans Pathak
 

Similar to Java class,object,method introduction (20)

Jacarashed-1746968053-300050282-Java.ppt
Jacarashed-1746968053-300050282-Java.ppt
DilipDas70
 
Android Training (Java Review)
Android Training (Java Review)
Khaled Anaqwa
 
Chap-2 Classes & Methods.pptx
Chap-2 Classes & Methods.pptx
chetanpatilcp783
 
Basic concept of class, method , command line-argument
Basic concept of class, method , command line-argument
Suresh Mohta
 
Java Programming - 04 object oriented in java
Java Programming - 04 object oriented in java
Danairat Thanabodithammachari
 
Core Java unit no. 1 object and class ppt
Core Java unit no. 1 object and class ppt
Mochi263119
 
123 JAVA CLASSES, OBJECTS AND METHODS.ppt
123 JAVA CLASSES, OBJECTS AND METHODS.ppt
mcjaya2024
 
2.oop concept
2.oop concept
Robbie AkaChopa
 
CJP Unit-1 contd.pptx
CJP Unit-1 contd.pptx
RAJASEKHARV10
 
Class and Object.pptx from nit patna ece department
Class and Object.pptx from nit patna ece department
om2348023vats
 
Class and Object JAVA PROGRAMMING LANG .pdf
Class and Object JAVA PROGRAMMING LANG .pdf
sameer2543ynr
 
Explain Classes and methods in java (ch04).ppt
Explain Classes and methods in java (ch04).ppt
ayaankim007
 
JAVA-PPT'S-complete-chrome.pptx
JAVA-PPT'S-complete-chrome.pptx
KunalYadav65140
 
JAVA-PPT'S.pptx
JAVA-PPT'S.pptx
RaazIndia
 
UNIT - IIInew.pptx
UNIT - IIInew.pptx
akila m
 
Unit3 part1-class
Unit3 part1-class
DevaKumari Vijay
 
UNIT 3- Java- Inheritance, Multithreading.pptx
UNIT 3- Java- Inheritance, Multithreading.pptx
shilpar780389
 
oblect oriented programming language in java notes .pdf
oblect oriented programming language in java notes .pdf
sanraku980
 
introduction_OOP for the java courses [Autosaved].pptx
introduction_OOP for the java courses [Autosaved].pptx
DrShamimAlMamun
 
Lec 5 13_aug [compatibility mode]
Lec 5 13_aug [compatibility mode]
Palak Sanghani
 
Jacarashed-1746968053-300050282-Java.ppt
Jacarashed-1746968053-300050282-Java.ppt
DilipDas70
 
Android Training (Java Review)
Android Training (Java Review)
Khaled Anaqwa
 
Chap-2 Classes & Methods.pptx
Chap-2 Classes & Methods.pptx
chetanpatilcp783
 
Basic concept of class, method , command line-argument
Basic concept of class, method , command line-argument
Suresh Mohta
 
Core Java unit no. 1 object and class ppt
Core Java unit no. 1 object and class ppt
Mochi263119
 
123 JAVA CLASSES, OBJECTS AND METHODS.ppt
123 JAVA CLASSES, OBJECTS AND METHODS.ppt
mcjaya2024
 
CJP Unit-1 contd.pptx
CJP Unit-1 contd.pptx
RAJASEKHARV10
 
Class and Object.pptx from nit patna ece department
Class and Object.pptx from nit patna ece department
om2348023vats
 
Class and Object JAVA PROGRAMMING LANG .pdf
Class and Object JAVA PROGRAMMING LANG .pdf
sameer2543ynr
 
Explain Classes and methods in java (ch04).ppt
Explain Classes and methods in java (ch04).ppt
ayaankim007
 
JAVA-PPT'S-complete-chrome.pptx
JAVA-PPT'S-complete-chrome.pptx
KunalYadav65140
 
JAVA-PPT'S.pptx
JAVA-PPT'S.pptx
RaazIndia
 
UNIT - IIInew.pptx
UNIT - IIInew.pptx
akila m
 
UNIT 3- Java- Inheritance, Multithreading.pptx
UNIT 3- Java- Inheritance, Multithreading.pptx
shilpar780389
 
oblect oriented programming language in java notes .pdf
oblect oriented programming language in java notes .pdf
sanraku980
 
introduction_OOP for the java courses [Autosaved].pptx
introduction_OOP for the java courses [Autosaved].pptx
DrShamimAlMamun
 
Lec 5 13_aug [compatibility mode]
Lec 5 13_aug [compatibility mode]
Palak Sanghani
 
Ad

Recently uploaded (20)

362 Alec Data Center Solutions-Slysium Data Center-AUH-Adaptaflex.pdf
362 Alec Data Center Solutions-Slysium Data Center-AUH-Adaptaflex.pdf
djiceramil
 
Universal Human Values and professional ethics Quantum AKTU BVE401
Universal Human Values and professional ethics Quantum AKTU BVE401
Unknown
 
Montreal Dreamin' 25 - Introduction to the MuleSoft AI Chain (MAC) Project
Montreal Dreamin' 25 - Introduction to the MuleSoft AI Chain (MAC) Project
Alexandra N. Martinez
 
operationg systemsdocumentmemorymanagement
operationg systemsdocumentmemorymanagement
SNIGDHAAPPANABHOTLA
 
How Binning Affects LED Performance & Consistency.pdf
How Binning Affects LED Performance & Consistency.pdf
Mina Anis
 
Blood bank management system project report.pdf
Blood bank management system project report.pdf
Kamal Acharya
 
Impurities of Water and their Significance.pptx
Impurities of Water and their Significance.pptx
dhanashree78
 
TEA2016AAT 160 W TV application design example
TEA2016AAT 160 W TV application design example
ssuser1be9ce
 
4th International Conference on Computer Science and Information Technology (...
4th International Conference on Computer Science and Information Technology (...
ijait
 
ACEP Magazine Fifth Edition on 5june2025
ACEP Magazine Fifth Edition on 5june2025
Rahul
 
22PCOAM16 _ML_Unit 3 Notes & Question bank
22PCOAM16 _ML_Unit 3 Notes & Question bank
Guru Nanak Technical Institutions
 
社内勉強会資料_Chain of Thought .
社内勉強会資料_Chain of Thought .
NABLAS株式会社
 
Great power lithium iron phosphate cells
Great power lithium iron phosphate cells
salmankhan835951
 
Development of Portable Biomass Briquetting Machine (S, A & D)-1.pptx
Development of Portable Biomass Briquetting Machine (S, A & D)-1.pptx
aniket862935
 
Water demand - Types , variations and WDS
Water demand - Types , variations and WDS
dhanashree78
 
OCS Group SG - HPHT Well Design and Operation - SN.pdf
OCS Group SG - HPHT Well Design and Operation - SN.pdf
Muanisa Waras
 
IntroSlides-June-GDG-Cloud-Munich community [email protected]
IntroSlides-June-GDG-Cloud-Munich community [email protected]
Luiz Carneiro
 
Understanding Amplitude Modulation : A Guide
Understanding Amplitude Modulation : A Guide
CircuitDigest
 
chemistry investigatory project for class 12
chemistry investigatory project for class 12
Susis10
 
Fundamentals of Digital Design_Class_21st May - Copy.pptx
Fundamentals of Digital Design_Class_21st May - Copy.pptx
drdebarshi1993
 
362 Alec Data Center Solutions-Slysium Data Center-AUH-Adaptaflex.pdf
362 Alec Data Center Solutions-Slysium Data Center-AUH-Adaptaflex.pdf
djiceramil
 
Universal Human Values and professional ethics Quantum AKTU BVE401
Universal Human Values and professional ethics Quantum AKTU BVE401
Unknown
 
Montreal Dreamin' 25 - Introduction to the MuleSoft AI Chain (MAC) Project
Montreal Dreamin' 25 - Introduction to the MuleSoft AI Chain (MAC) Project
Alexandra N. Martinez
 
operationg systemsdocumentmemorymanagement
operationg systemsdocumentmemorymanagement
SNIGDHAAPPANABHOTLA
 
How Binning Affects LED Performance & Consistency.pdf
How Binning Affects LED Performance & Consistency.pdf
Mina Anis
 
Blood bank management system project report.pdf
Blood bank management system project report.pdf
Kamal Acharya
 
Impurities of Water and their Significance.pptx
Impurities of Water and their Significance.pptx
dhanashree78
 
TEA2016AAT 160 W TV application design example
TEA2016AAT 160 W TV application design example
ssuser1be9ce
 
4th International Conference on Computer Science and Information Technology (...
4th International Conference on Computer Science and Information Technology (...
ijait
 
ACEP Magazine Fifth Edition on 5june2025
ACEP Magazine Fifth Edition on 5june2025
Rahul
 
社内勉強会資料_Chain of Thought .
社内勉強会資料_Chain of Thought .
NABLAS株式会社
 
Great power lithium iron phosphate cells
Great power lithium iron phosphate cells
salmankhan835951
 
Development of Portable Biomass Briquetting Machine (S, A & D)-1.pptx
Development of Portable Biomass Briquetting Machine (S, A & D)-1.pptx
aniket862935
 
Water demand - Types , variations and WDS
Water demand - Types , variations and WDS
dhanashree78
 
OCS Group SG - HPHT Well Design and Operation - SN.pdf
OCS Group SG - HPHT Well Design and Operation - SN.pdf
Muanisa Waras
 
Understanding Amplitude Modulation : A Guide
Understanding Amplitude Modulation : A Guide
CircuitDigest
 
chemistry investigatory project for class 12
chemistry investigatory project for class 12
Susis10
 
Fundamentals of Digital Design_Class_21st May - Copy.pptx
Fundamentals of Digital Design_Class_21st May - Copy.pptx
drdebarshi1993
 
Ad

Java class,object,method introduction

  • 1. Pundra University of Science & Technology Department of Computer Science & Engineering Name: Md. Sihab Uddin Batch No: 6th Semester No: 4th Roll No: 05
  • 2. Outline • Program Structure • Concept of Class • Concept of Object • Concept of Constructor • Method
  • 3. Program Structure • Structure Import Statement Package Statement Class Definition Inheritance Statement Interface Statement Main Method
  • 4. Concept of Class • A class is simply a representation of a type of object • It is the blueprint/ plan/ template that describe the details of an object • For example- mango, apple, orange are the members of the class fruits • If fruits has been defined as a class, then the statement Fruits mango; • It will create an object mango belonging to the class fruit
  • 5. Cont…….. • Java is a case-sensitive language • Class declaration • Opening braces • The main line • The output line Class Csepu { Public static void main (String args[]) { System.out.println(“Java is better than C++”); } }
  • 6. Cont…………… • Class declaration Class Csepu – This line uses the keyword class to declare that a new class is being defined – Csepu is the name of the class • Opening braces { …… } – The class definition begins with the opening curly brace ({) and ends with the closing curly brace (}). – The elements between the two braces are members of the class
  • 7. Cont……….. • The main line Public static void main (String args[]) – The keyword public means that the method main() can be accessed by any other Java class. – The keyword static means that you don’t have to create an instance of this class to use this method. – The keyword void means that the method main() doesn’t return any value to the calling program. – The keyword String[] args tells us that this method will receive an array of characters as the argument
  • 8. Cont……. • The Output line System.out.println(“Java is better than C++”); – This is similar to the printf() statement of C – Since Java is a true object oriented language, every method must be part of an object – The println method is a member of the out object, which is a static data member of System class – The method println always appends a newline character to the end of the string – This means that any subsequent output will start on a new line
  • 9. Object • Objects are instances of a class. It is the building block of OOP. • They are the basic runtime entities in an object oriented system • They may present a person, a place, a bank account, a table of data or any item that the program may handle • Object must have the following three characteristics: – Identity – State – Behavior
  • 10. Concept of Constructors • A constructor initializes an object when it is created • It has the same name as its class and is syntactically similar to a method • However, constructors have no explicit return type • simple example class Adition { public void add() {int a,b,add; a=4;b=5; add=a+b; System.out.println("Result of Add: "+add); } } public class Exmcons1 { public static void main (String args[]) { Adition obj = new Adition(); obj.add(); } }
  • 11. Concept of Methods • Methods are the interface or communications between program components • A Java method is a collection of statements that are grouped together to perform an operation • As an example when we call the System.out.println method… – The system actually executes several statements in order to display a message on the console – In general, a method has the following syntax Modifier returnValueType methodName (list of parameters) { //method of body; }
  • 13. Declaring a Methods • Modifiers – The modifier, which is optional, tells the compiler how to call the method – This defines the access type of the method • Return Type – A method may return a value – The returnValueType is the data type of the value the method returns – Some methods perform the desired operations without returning a value – In this case, the returnValueType is the keyword void
  • 14. Cont…………. • Method Name – This is the actual name of the method – The method name and the parameter list together constitute the method signature • Parameters – A parameter is like a place holder – When a method is invoked, pass a value to the parameter – This value is referred to as actual parameter or argument – The parameter list refers to the type, order, and number of the parameters of a method – Parameters are optional; that is, a method may contain no parameters
  • 15. Cont…………. • Method Body – The method body contains a collection of statements that define what the method does • Example – The following defined method called max() – This method takes two parameters num1 and num2 and returns the maximum between the two public static int max(int num1, int num2) { int result; if (num1 > num2) result = num1; else result = num2; return result; }