SlideShare a Scribd company logo
MGM’s College of Engineering &
Technology, Kamothe.
Department of Computer Engineering
Subject: Object Oriented Programming with Java
(CSL304)
Second Year – Semester III
A.Y. – 2022-23
Subject In-charge: Prof. Vijay R Bhosale
OOPM Introduction.ppt
OOPM Introduction.ppt
OOPM Introduction.ppt
Syllabus
Syllabus
OOPM Introduction.ppt
OOPM Introduction.ppt
OOP stands for Object-Oriented Programming.
 Procedural programming is about writing procedures or
methods that perform operations on the data, while
object-oriented programming is about creating objects
that contain both data and methods.
Object-oriented programming has several advantages
over procedural programming:
 OOP is faster and easier to execute
 OOP provides a clear structure for the programs
 OOP helps to keep the Java code DRY "Don't Repeat
Yourself", and makes the code easier to maintain,
modify and debug
 OOP makes it possible to create full reusable
applications with less code and shorter development
time
What are Classes and Objects?
 So, a class is a template for objects, and an object is an
instance of a class.
 When the individual objects are created, they inherit all the
variables and methods from the class.
What is Java?
Java is a popular programming language, created in
1995.
 It is owned by Oracle, and more than 3
billion devices run Java.
It is used for:
 Mobile applications (specially Android apps)
 Desktop applications
 Web applications
 Web servers and application servers
 Games
 Database connection
And much, much more!
Why Use Java?
 Java works on different platforms (Windows, Mac,
Linux, Raspberry Pi, etc.)
 It is one of the most popular programming language
in the world
 It is easy to learn and simple to use
 It is open-source and free
 It is secure, fast and powerful
 It has a huge community support (tens of millions of
developers)
 Java is an object oriented language which gives a
clear structure to programs and allows code to be
reused, lowering development costs
 As Java is close to C++ and C#, it makes it easy for
Java Install
 To check if you have Java installed on a Windows PC,
search in the start bar for Java or type the following in
Command Prompt (cmd.exe):
 If Java is installed, you will see something like this
(depending on version):
 If you do not have Java installed on your computer, you
can download it for free at oracle.com.
 Note: We can use “notepad”, “notepad++” for writing
java code. However, it is possible to write Java in an
Integrated Development Environment, such as IntelliJ
IDEA, Netbeans or Eclipse, which are particularly useful
when managing larger collections of Java files.
Download Java
 https://www.oracle.com/java/technologies/javase-
jdk16-downloads.html
Run the downloaded file and click
next
Click next
Progress......
Progress.....
Java successfully installed.
OOPM Introduction.ppt
1. Go to "System Properties"
(Can be found on Control Panel >
System and Security > System >
Advanced System Settings)
2. Click on the "Environment
variables" button under the
"Advanced" tab
3. Then, select the "Path" variable in
System variables and click on the
"Edit" button
4. Click on the "New" button and add the path where
Java is installed, followed by bin. By default, Java is
installed in C:Program FilesJavajdk-11.0.1 (If nothing
else was specified when you installed it).
In that case, You will have
to add a new path
with: C:Program Files
Javajdk-11.0.1bin
Then, click "OK",
and save the settings
5. At last, open Command Prompt
(cmd.exe) and type java -version to
see if Java is running on your
machine
Creating first Java file
 In Java, every application begins with a class name,
and that class must match the filename.
 Let's create our first Java file, called Main.java, which
can be done in any text editor (like Notepad).
 The file should contain a "Hello World" message, which
is written with the following code:
 Save the code in Notepad as "Main.java". Open
Command Prompt (cmd.exe), navigate to the directory
where you saved your file, and type "javac Main.java":
 Save the code in Notepad as "Main.java". Open
Command Prompt (cmd.exe), navigate to the directory
where you saved your file, and type "javac Main.java":
 This will compile your code. If there are no errors in the
code, the command prompt will take you to the next
line. Now, type "java Main" to run the file:
 The output will be:
Explanation
 Every line of code that runs in Java must be inside
a class.
 In our example, we named the class Main. A class
should always start with an uppercase first letter.
Note: Java is case-sensitive: "MyClass" and "myclass"
has different meaning.
 The name of the java file must match the class name.
When saving the file, save it using the class name and
add ".java" to the end of the filename.
The main Method
 The main() method is required and you will see it in
every Java program:
 Any code inside the main() method will be executed.
You don't have to understand the keywords before and
after main. You will get to know them bit by bit while
reading this tutorial.
 For now, just remember that every Java program has
a class name which must match the filename, and that
every program must contain the main() method.
System.out.println()
 Inside the main() method, we can use
the println() method to print a line of text to the
screen:
 Code:
 O/P:
 Note: The curly braces {} marks the beginning
and the end of a block of code.
 Note: Each code statement must end with a
Java Classes/Objects
 Java is an object-oriented programming language.
 Everything in Java is associated with classes and
objects, along with its attributes and methods. For
example: in real life, a car is an object. The car
has attributes, such as weight and color, and methods,
such as drive and brake.
 A Class is like an object constructor, or a "blueprint" for
creating objects.
Create a Class
 To create a class, use the keyword class:
Create an Object
 In Java, an object is created from a class. We have
already created the class named Main, so now we can
use this to create objects.
 To create an object of Main, specify the class name,
followed by the object name, and use the keyword new:
 Code:
 O/P:
We can create multiple objects of one class:
Code:
O/P:
 Using Multiple Classes
 You can also create an object of a class
and access it in another class. This is often
used for better organization of classes
(one class has all the attributes and methods,
while the other class holds the main() method
(code to be executed)).
 Remember that the name of the java file
should match the class name. In this example,
 we have created two files in the same
directory/folder:
1. Main.java
2. Second.java
 When both files have been compiled:
 Run the Second.java file: O/P:

More Related Content

Similar to OOPM Introduction.ppt (20)

PPTX
Chapter 2.1
sotlsoc
 
PPT
Chapter1pp
J. C.
 
PPTX
What is Java, JDK, JVM, Introduction to Java.pptx
kumarsuneel3997
 
PPT
Java platform
BG Java EE Course
 
PDF
Java lab-manual
Khurshid Asghar
 
PDF
Java In Easy Steps Covers Java 9 1st Edition Mike Mcgrath
metalsmunshe
 
PPTX
1.introduction to java
Madhura Bhalerao
 
PDF
Java interview question
simplidigital
 
PDF
Beginning Java with WebSphere Expert s Voice in Java Janson Robert W
kuclermialee
 
PDF
Javanotes
John Cutajar
 
PPT
1 2 java development
Ken Kretsch
 
PPT
R:\ap java\class slides\chapter 1\1 2 java development
Ken Kretsch
 
PPTX
Chapter 1
siragezeynu
 
DOCX
Java interview questions and answers
Krishnaov
 
PPT
Java_presesntation.ppt
VGaneshKarthikeyan
 
PPT
INTRODUCTION TO JAVA APPLICATION
Ajit Yadav
 
PPT
Classes and Objects
vmadan89
 
PPSX
Java Semimar Slide (Cetpa)
Pratima Parida
 
PPSX
Java Semimar Slide (Cetpa)
Pratima Parida
 
PPTX
Unit 1 – Introduction to Java- (Shilpa R).pptx
shilpar780389
 
Chapter 2.1
sotlsoc
 
Chapter1pp
J. C.
 
What is Java, JDK, JVM, Introduction to Java.pptx
kumarsuneel3997
 
Java platform
BG Java EE Course
 
Java lab-manual
Khurshid Asghar
 
Java In Easy Steps Covers Java 9 1st Edition Mike Mcgrath
metalsmunshe
 
1.introduction to java
Madhura Bhalerao
 
Java interview question
simplidigital
 
Beginning Java with WebSphere Expert s Voice in Java Janson Robert W
kuclermialee
 
Javanotes
John Cutajar
 
1 2 java development
Ken Kretsch
 
R:\ap java\class slides\chapter 1\1 2 java development
Ken Kretsch
 
Chapter 1
siragezeynu
 
Java interview questions and answers
Krishnaov
 
Java_presesntation.ppt
VGaneshKarthikeyan
 
INTRODUCTION TO JAVA APPLICATION
Ajit Yadav
 
Classes and Objects
vmadan89
 
Java Semimar Slide (Cetpa)
Pratima Parida
 
Java Semimar Slide (Cetpa)
Pratima Parida
 
Unit 1 – Introduction to Java- (Shilpa R).pptx
shilpar780389
 

Recently uploaded (20)

PPTX
HYDROCEPHALUS: NURSING MANAGEMENT .pptx
PRADEEP ABOTHU
 
PDF
community health nursing question paper 2.pdf
Prince kumar
 
PDF
SSHS-2025-PKLP_Quarter-1-Dr.-Kerby-Alvarez.pdf
AishahSangcopan1
 
PDF
Isharyanti-2025-Cross Language Communication in Indonesian Language
Neny Isharyanti
 
PPTX
MENINGITIS: NURSING MANAGEMENT, BACTERIAL MENINGITIS, VIRAL MENINGITIS.pptx
PRADEEP ABOTHU
 
PDF
Chapter-V-DED-Entrepreneurship: Institutions Facilitating Entrepreneurship
Dayanand Huded
 
PPTX
Universal immunization Programme (UIP).pptx
Vishal Chanalia
 
PPTX
A PPT on Alfred Lord Tennyson's Ulysses.
Beena E S
 
PPTX
Mathematics 5 - Time Measurement: Time Zone
menchreo
 
PPT
Talk on Critical Theory, Part One, Philosophy of Social Sciences
Soraj Hongladarom
 
PDF
LAW OF CONTRACT ( 5 YEAR LLB & UNITARY LLB)- MODULE-3 - LEARN THROUGH PICTURE
APARNA T SHAIL KUMAR
 
PPTX
How to Set Maximum Difference Odoo 18 POS
Celine George
 
PPTX
Pyhton with Mysql to perform CRUD operations.pptx
Ramakrishna Reddy Bijjam
 
PPTX
How to Create a PDF Report in Odoo 18 - Odoo Slides
Celine George
 
PDF
ARAL_Orientation_Day-2-Sessions_ARAL-Readung ARAL-Mathematics ARAL-Sciencev2.pdf
JoelVilloso1
 
PPTX
2025 Winter SWAYAM NPTEL & A Student.pptx
Utsav Yagnik
 
PDF
Lesson 2 - WATER,pH, BUFFERS, AND ACID-BASE.pdf
marvinnbustamante1
 
PDF
CONCURSO DE POESIA “POETUFAS – PASSOS SUAVES PELO VERSO.pdf
Colégio Santa Teresinha
 
PDF
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 - GLOBAL SUCCESS - CẢ NĂM - NĂM 2024 (VOCABULARY, ...
Nguyen Thanh Tu Collection
 
PPTX
Stereochemistry-Optical Isomerism in organic compoundsptx
Tarannum Nadaf-Mansuri
 
HYDROCEPHALUS: NURSING MANAGEMENT .pptx
PRADEEP ABOTHU
 
community health nursing question paper 2.pdf
Prince kumar
 
SSHS-2025-PKLP_Quarter-1-Dr.-Kerby-Alvarez.pdf
AishahSangcopan1
 
Isharyanti-2025-Cross Language Communication in Indonesian Language
Neny Isharyanti
 
MENINGITIS: NURSING MANAGEMENT, BACTERIAL MENINGITIS, VIRAL MENINGITIS.pptx
PRADEEP ABOTHU
 
Chapter-V-DED-Entrepreneurship: Institutions Facilitating Entrepreneurship
Dayanand Huded
 
Universal immunization Programme (UIP).pptx
Vishal Chanalia
 
A PPT on Alfred Lord Tennyson's Ulysses.
Beena E S
 
Mathematics 5 - Time Measurement: Time Zone
menchreo
 
Talk on Critical Theory, Part One, Philosophy of Social Sciences
Soraj Hongladarom
 
LAW OF CONTRACT ( 5 YEAR LLB & UNITARY LLB)- MODULE-3 - LEARN THROUGH PICTURE
APARNA T SHAIL KUMAR
 
How to Set Maximum Difference Odoo 18 POS
Celine George
 
Pyhton with Mysql to perform CRUD operations.pptx
Ramakrishna Reddy Bijjam
 
How to Create a PDF Report in Odoo 18 - Odoo Slides
Celine George
 
ARAL_Orientation_Day-2-Sessions_ARAL-Readung ARAL-Mathematics ARAL-Sciencev2.pdf
JoelVilloso1
 
2025 Winter SWAYAM NPTEL & A Student.pptx
Utsav Yagnik
 
Lesson 2 - WATER,pH, BUFFERS, AND ACID-BASE.pdf
marvinnbustamante1
 
CONCURSO DE POESIA “POETUFAS – PASSOS SUAVES PELO VERSO.pdf
Colégio Santa Teresinha
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 - GLOBAL SUCCESS - CẢ NĂM - NĂM 2024 (VOCABULARY, ...
Nguyen Thanh Tu Collection
 
Stereochemistry-Optical Isomerism in organic compoundsptx
Tarannum Nadaf-Mansuri
 
Ad

OOPM Introduction.ppt

  • 1. MGM’s College of Engineering & Technology, Kamothe. Department of Computer Engineering Subject: Object Oriented Programming with Java (CSL304) Second Year – Semester III A.Y. – 2022-23 Subject In-charge: Prof. Vijay R Bhosale
  • 9. OOP stands for Object-Oriented Programming.  Procedural programming is about writing procedures or methods that perform operations on the data, while object-oriented programming is about creating objects that contain both data and methods. Object-oriented programming has several advantages over procedural programming:  OOP is faster and easier to execute  OOP provides a clear structure for the programs  OOP helps to keep the Java code DRY "Don't Repeat Yourself", and makes the code easier to maintain, modify and debug  OOP makes it possible to create full reusable applications with less code and shorter development time
  • 10. What are Classes and Objects?  So, a class is a template for objects, and an object is an instance of a class.  When the individual objects are created, they inherit all the variables and methods from the class.
  • 11. What is Java? Java is a popular programming language, created in 1995.  It is owned by Oracle, and more than 3 billion devices run Java. It is used for:  Mobile applications (specially Android apps)  Desktop applications  Web applications  Web servers and application servers  Games  Database connection And much, much more!
  • 12. Why Use Java?  Java works on different platforms (Windows, Mac, Linux, Raspberry Pi, etc.)  It is one of the most popular programming language in the world  It is easy to learn and simple to use  It is open-source and free  It is secure, fast and powerful  It has a huge community support (tens of millions of developers)  Java is an object oriented language which gives a clear structure to programs and allows code to be reused, lowering development costs  As Java is close to C++ and C#, it makes it easy for
  • 13. Java Install  To check if you have Java installed on a Windows PC, search in the start bar for Java or type the following in Command Prompt (cmd.exe):  If Java is installed, you will see something like this (depending on version):  If you do not have Java installed on your computer, you can download it for free at oracle.com.  Note: We can use “notepad”, “notepad++” for writing java code. However, it is possible to write Java in an Integrated Development Environment, such as IntelliJ IDEA, Netbeans or Eclipse, which are particularly useful when managing larger collections of Java files.
  • 15. Run the downloaded file and click next
  • 21. 1. Go to "System Properties" (Can be found on Control Panel > System and Security > System > Advanced System Settings)
  • 22. 2. Click on the "Environment variables" button under the "Advanced" tab
  • 23. 3. Then, select the "Path" variable in System variables and click on the "Edit" button
  • 24. 4. Click on the "New" button and add the path where Java is installed, followed by bin. By default, Java is installed in C:Program FilesJavajdk-11.0.1 (If nothing else was specified when you installed it). In that case, You will have to add a new path with: C:Program Files Javajdk-11.0.1bin Then, click "OK", and save the settings
  • 25. 5. At last, open Command Prompt (cmd.exe) and type java -version to see if Java is running on your machine
  • 26. Creating first Java file  In Java, every application begins with a class name, and that class must match the filename.  Let's create our first Java file, called Main.java, which can be done in any text editor (like Notepad).  The file should contain a "Hello World" message, which is written with the following code:  Save the code in Notepad as "Main.java". Open Command Prompt (cmd.exe), navigate to the directory where you saved your file, and type "javac Main.java":
  • 27.  Save the code in Notepad as "Main.java". Open Command Prompt (cmd.exe), navigate to the directory where you saved your file, and type "javac Main.java":  This will compile your code. If there are no errors in the code, the command prompt will take you to the next line. Now, type "java Main" to run the file:  The output will be:
  • 28. Explanation  Every line of code that runs in Java must be inside a class.  In our example, we named the class Main. A class should always start with an uppercase first letter. Note: Java is case-sensitive: "MyClass" and "myclass" has different meaning.  The name of the java file must match the class name. When saving the file, save it using the class name and add ".java" to the end of the filename.
  • 29. The main Method  The main() method is required and you will see it in every Java program:  Any code inside the main() method will be executed. You don't have to understand the keywords before and after main. You will get to know them bit by bit while reading this tutorial.  For now, just remember that every Java program has a class name which must match the filename, and that every program must contain the main() method.
  • 30. System.out.println()  Inside the main() method, we can use the println() method to print a line of text to the screen:  Code:  O/P:  Note: The curly braces {} marks the beginning and the end of a block of code.  Note: Each code statement must end with a
  • 31. Java Classes/Objects  Java is an object-oriented programming language.  Everything in Java is associated with classes and objects, along with its attributes and methods. For example: in real life, a car is an object. The car has attributes, such as weight and color, and methods, such as drive and brake.  A Class is like an object constructor, or a "blueprint" for creating objects. Create a Class  To create a class, use the keyword class:
  • 32. Create an Object  In Java, an object is created from a class. We have already created the class named Main, so now we can use this to create objects.  To create an object of Main, specify the class name, followed by the object name, and use the keyword new:  Code:  O/P:
  • 33. We can create multiple objects of one class: Code: O/P:
  • 34.  Using Multiple Classes  You can also create an object of a class and access it in another class. This is often used for better organization of classes (one class has all the attributes and methods, while the other class holds the main() method (code to be executed)).  Remember that the name of the java file should match the class name. In this example,  we have created two files in the same directory/folder: 1. Main.java 2. Second.java  When both files have been compiled:  Run the Second.java file: O/P: