Professional Documents
Culture Documents
OBJECT ORIENTED
PROGRAMMING
VASANTHA KUMAR V
AP/CSE
What is OOP?
◦ OOP helps to keep the code easier to maintain, modify and debug
◦ Java applications are typically compiled to byte code (class file) that can run on
any Java virtual machine (JVM) regardless of computer architecture.
◦ Java applications are typically compiled to byte code (class file) that can run on
any Java virtual machine (JVM) regardless of computer architecture.
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.)
◦ 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.