67% found this document useful (3 votes)
720 views28 pages

CS8392 - Oop - Unit 1 - PPT - 1.1

This document provides an overview of Object Oriented Programming (OOP) and Java. It defines OOP as creating objects that contain both data and methods, as opposed to procedural programming which focuses on writing procedures or methods that perform operations on data. The document then discusses advantages of OOP like reusability. It introduces Java as a programming language and discusses its platform independence. Key OOP concepts in Java like classes, objects, abstraction, encapsulation, inheritance and polymorphism are defined. The document also provides instructions on setting up Java on Windows.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
67% found this document useful (3 votes)
720 views28 pages

CS8392 - Oop - Unit 1 - PPT - 1.1

This document provides an overview of Object Oriented Programming (OOP) and Java. It defines OOP as creating objects that contain both data and methods, as opposed to procedural programming which focuses on writing procedures or methods that perform operations on data. The document then discusses advantages of OOP like reusability. It introduces Java as a programming language and discusses its platform independence. Key OOP concepts in Java like classes, objects, abstraction, encapsulation, inheritance and polymorphism are defined. The document also provides instructions on setting up Java on Windows.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 28

CS 8392

OBJECT ORIENTED
PROGRAMMING

VASANTHA KUMAR V
AP/CSE
What is OOP?

OOP stands for Object-Oriented Programming.

Procedural programming is about writing procedures or methods that perform


operations on the data.

Object-oriented programming is about creating objects that contain both data


and methods.
What is OOP?

OOP stands for Object-Oriented Programming.

Procedural programming is about writing procedures or methods that perform


operations on the data.

Object-oriented programming is about creating objects that contain both data


and methods.
Advantages of OOPs

◦ OOP is faster and easier to execute

◦ OOP provides a clear structure for the programs

◦ OOP helps to keep the code easier to maintain, modify and debug

◦ OOP makes it possible to create full reusable applications with less

code and shorter development time


◦ James Gosling and his team developed a programming language called Oak at
Sun Microsystem in 1991.

◦ In 1995 the language was renamed to Java.


What is Java ?

◦ Java is a general-purpose, high-level programming language.

◦ Java applications are typically compiled to byte code (class file) that can run on
any Java virtual machine (JVM) regardless of computer architecture.

◦ “Write Once, Run Anywhere” (WORA)


What is Java ?

◦ Java is a general-purpose, high-level programming language.

◦ Java applications are typically compiled to byte code (class file) that can run on
any Java virtual machine (JVM) regardless of computer architecture.

◦ “Write Once, Run Anywhere” (WORA)


IMPORTANTS OF JAVA
What are Classes and Objects?
Class Objects
Apple
Fruit Orange
Mango

Class Objects
Honda
Cars Audi
BMW
Create a Class
◦ A class should always start with an uppercase first letter.
◦ Every line of code that runs in Java must be inside a class.
◦ To create a class, use the keyword class .
Example :
public class MyClass
{
}
◦ 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.
Example :
MyClass.java
Abstraction
◦ Data abstraction is the process of hiding certain details and showing only
essential information to the user.
Encapsulation
◦ Encapsulation, is to make sure that "sensitive" data is hidden from users.
Abstraction vs Encapsulation
?
Inheritance
◦ In Java, it is possible to inherit attributes and methods from one class to
another.
Polymorphism
◦ Polymorphism means "many forms", and it occurs when we have many classes
that are related to each other by inheritance.
Why to 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


TASK FOR THE DAY
Java Setup for Windows
◦ Go to "System Properties" (Can be found on Control Panel > System and Security >
System > Advanced System Settings)

◦ Click on the "Environment variables" button under the "Advanced" tab

◦ Then, select the "Path" variable in System variables and click on the "Edit" button

◦ Click on the "New" button and add the path where Java is installed, followed
by \bin. By default, Java is installed in C:\Program Files\Java\jdk-14.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\Java\jdk-14.0.1\bin
Then, click "OK", and save the settings

◦ At last, open Command Prompt (cmd.exe) and type java -version to see if Java is
running on your machine
Java Setup for Windows
Step 1 :
Java Setup for Windows
Step 2 :
Java Setup for Windows
Step 3 :
Java Setup for Windows
Step 4 :
Java Setup for Windows
Step 5 :
Write the following in the command line (cmd.exe):
C:\Users\Your Name>java -version

If Java was successfully installed, you will see something like this (depending on
version):
java version "11.0.1" 2018-10-16 LTS
Java(TM) SE Runtime Environment 18.9 (build 11.0.1+13-LTS)
Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.1+13-LTS, mixed mode)
Java
Running a Program
1. Write it.
◦ code or source code: The set of instructions in a program.

2. Compile it.
• compile: Translate a program from one language to another.
◦ byte code: The Java compiler converts your code into a format named byte
code that runs on many computer types.

3. Run (execute) it.


◦ output: The messages printed to the user by a program.

byte code output


source code
compile run
Java - Example
public class MyClass {
public static void main(String[] args) {
System.out.println("Hello World");
}
}
public - it is access specifier means from every where we can access it.
static - access modifier means we can call this method directly using class name
without creating an object of it.
void - its the return type.
main - method name.
String[] args in Java is an array of strings which stores arguments passed by command
line while starting a program. All the command line arguments are stored in that array.
THANK YOU

You might also like