4. OBJECTIVES:
BASIC OF PROGRAMMING LANGUAGE.
WHAT IS OOPS?
JAVA OVERVIEW(HISTORY,FEATURES).
OOPS CONCEPT IN JAVA.
JAVA COMPARE WITH C++.
EXAMPLE PROGRAMS OF JAVA AND C++.
5. WHAT IS OBJECT ORIENTED PROGRAMMING?
Object oriented
programming is a computer
programming model that organize
software design around data, or
object ,rather then functions and
logic . An object can be defined
as a data field that has unique
attributes and behavior.
6.
7. PROGRAMMING LANGUAGE:
It is a formal computer language which is
designed to communicate
instruction or commands or orders
to a machine , particularly a
computer programming
languages can be used to create
programs to control behaviour of
the machine.
8.
9.
10. What is java?
Java is an object-oriented,
cross-platform programming
language introduced
in 1995 by Sun
Microsystems .
Today , Java helps run
many applications ,
including Sport ,
Social Media ,
Audio , Video , etc,…
13. Object oriented Programming (oop)
is a computer programming model
that organizes software Design
around data , or objects , rather than
functions and logic. An Object can
be defined as a data field that has
unique attributes and behaviour.
What is OOP(Object Oriented Programming)?
14.
15.
16.
17. CLASS :
A class is a group of
objects that share common
properties and behaviour .
You can also think of a
class as a blueprint from
which you can create
an individual object.
keyword : class
18. Example of class:
Class Bicycle
{
Private int gear=5;
Public void braking()
{
System.out.println(“Working of braking:”);
}
}
21. object:
In the java programming language ,
an object is an instance of
a java class ,meaning it’s a
copy of a specific class .
Java objects have three
primary characteristics:
identity , state and behavior.
22. EXAMPLE OF OBJECT:
Create an object called "myObj" and print the value of
x:
public class Main
{
int x = 5;
public static void main(String[] args)
{
Main myObj = new Main();
System.out.println(myObj.x);
}
}
23.
24.
25. Inheritance:
The process of obtaining the
data members four methods
from one class to another
class is known as
inheritance .
It’s one of the fundamental
features of oops .
27. Example of inheritance:
Class Employee
{
Float salary=40000;
}
Class programmer extends Employee
{
int bonus= 10000;
Public static void main(String [] args)
{
Programmer P =new programmer();
System.out.println(“programmer salary is :”+p.salary);
System.out.println(”Bonus of programmer is :”+p.bonus);
}
}
31. Example of Abstract class that has an abstract method
abstract class Bike
{
abstract void run();
}
class Honda4 extends Bike
{
void run(){System.out.println("running safely");}
public static void main(String args[])
{
Bike obj = new Honda4();
obj.run();
}
}
32.
33. ENCAPSULATION:
Encapsulation is a process of
wrapping data and method in a single
unit is called encapsulation .
In oops , data and methods operating
on that data are combined together to
form a single unit , which is referred
to as a class .
It is the mechanism that binds
together code and the data it
manipulates and keeps both safes
form outside interface and misuse .
35. Example of Encapsulation in Java:
package com.javatpoint;
class student
{
public static void main(String[] args)
{
Student s=new Student();
s.setName("vijay");
System.out.println(s.getName());
}
}
36.
37. Polymorphism:
The process of representing one form in
multiple form is known as polymorphism
.
It is allows us to perform a single
action in different way.
It is allows you to define one interface
and have multiple implementation.
Polymorphism means many form .
38.
39. Example of Java Runtime Polymorphism:
class Bike
{
void run(){System.out.println("running");
}
}
class Splendor extends Bike
{
void run(){System.out.println("running safely with 60km");
}
public static void main(String []args)
{
Bike b = new Splendor();
b.run();
}
}
40.
41. S.NO PARAMETERS JAVA C++
1. Portability It can run on any OS
hence it is portable.
C++ is platform
dependent hence it is not
portable.
2. compilation Java is both compiled
and interpreted language.
C++ is a compiled
language.
3. Memory Management is
System Controlled.
Memory Management in
C++ is Manual.
4. Virtual Keyword It doesn’t have a Virtual
Keyword.
It has Virtual keywords.
5. Multiple Inheritance It supports only single
inheritance. Multiple
inheritances are achieved
partially using interfaces.
It supports both single
and multiple Inheritance.
6. Overloading It supports only method
overloading and doesn’t
allow operator
It supports both method
and operator
overloading.
Memory
Management
42. 7. Pointers It has limited support for
pointers.
It strongly supports
pointers.
8. Libraries Libraries have a wide range
of classes for various high-
level services.
C++ libraries have
comparatively low-level
functionalities.
9. Documentation
Comment
It supports documentation
comments (e.g., /**.. */) for
source code.
It doesn’t support
documentation comments
for source code.
10.
Thread
Support
Java provides built-in support
for multithreading.
C++ doesn’t have built-in
support for threads,
depends on third-party
threading libraries.
11.
Type
Java is only an object-
oriented programming
language.
C++ is both a procedural
and an object-oriented
programming language.
12. Input-Output
mechanism
Java uses the (System
class): System.in for input
C++ uses cin for input
and cout for an output
43. APPLICATIONS OF JAVA PROGRAMMING LANGUAGE:
Desktop GUI Applications development.
Android and Mobile application development.
Application of java are in embedded
technologies lie SIM cards , disk players , TV ,
etc,..
Java EE(Enterprise Edition) provides an API and
runtime environment for running large enterprise
software.
Network Applications and Web services like
Internet connection , Web App Development.
44.
45. SYNTAX OF JAVA :
import java.io.*;
class GFG
{
public static void main (String[] args)
{
System.out.println("GFG!");
}
}
46.
47. EXAMPLE OF JAVA PROGRAM:
Import java.io.*;
Class person
{
String name;
int age;
Person (int age, string name)
{
this.name = name;
this.age=age;
}
}
Class Employee extends person
{
48. int emp _ id;
int emp _ salary;
Employee( int id, String name, int age , int salary)
{
Super(age , name);
emp_id=id;
emp_salary=salary;
}
System.out.println(“Employee ID:”+emp_id);
System.out.println(“Employee name:”+name);
System.out.println(“Employee age:”+age);
System.out.println(“Employee salary:”+emp_salary);
}
}
Public class main
{
Public static void main(string[]args)