SlideShare a Scribd company logo
INTRODUCTION TO OOP AND
JAVA FUNDAMENTALS
N.ANSGAR MARY
AP/IT
Introduction to oop and java fundamentals
Unit I
• Object Oriented Programming - Abstraction –
objects and classes - Encapsulation- Inheritance-
Polymorphism- OOP in Java – Characteristics of
Java – The Java Environment - Java Source File -
Structure Compilation. Fundamental
Programming Structures in Java – Defining classes
in Java – constructors, methods - access specifiers
- static members - Comments, Data Types,
Variables, Operators, Control Flow, Arrays,
Packages - JavaDoc comments.
OBJECT-ORIENTED PROGRAMMING
Object-Oriented Programming (OOP) is a programming
language model organized around objects rather than
actions and data. An object-oriented program can be
characterized as data controlling access to code. Concepts
of OOPS
• Object
• Class
• Inheritance
• Polymorphism
• Abstraction
• Encapsulation
Introduction to oop and java fundamentals
OBJECT
• Object means a real word entity such as pen, chair, table etc.
• Any entity that has state and behavior is known as an object.
• Object can be defined as an instance of a class.
• An object contains an address and takes up some space in memory. Objects can
communicate without knowing details of each other's data or code, the only
necessary thing is that the type of message accepted and type of response
returned by the objects.
• An object has three characteristics:
• state: represents data (value) of an object.
• behavior: represents the behavior (functionality) of an object such as deposit,
withdraw etc.
• identity: Object identity is typically implemented via a unique ID. The value of the
ID is not visible to the external user. But, it is used internally by the JVM to identify
each object uniquely.
Example of an object : dog1
CLASS
• Collection of objects is called class.
• It is a logical entity.
• A class can also be defined as a blueprint from which
you can create an individual object.
• A class consists of Data members and methods.
• The primary purpose of a class is to hold
data/information.
• The member functions determine the behavior of the
class, i.e. provide a definition for supporting various
operations on data held in the form of an object.
• Class doesn’t store any space.
Introduction to oop and java fundamentals
Introduction to oop and java fundamentals
Example
public class Dog
{
String breed;
int age;
String color;
void barking()
{ }
void hungry()
{ }
void sleeping()
{ }
}
Constructors
• Each time a new object is created, at least one
constructor will be invoked. The main rule of
constructors is that they should have the same name
as the class. A class can have more than one
constructor.
Following is an example of a constructor −
Example
public class Puppy
{
public Puppy()
{ }
public Puppy(String name)
{ // This constructor has one parameter, name. } }
Introduction to oop and java fundamentals
INHERITANCE
• Inheritance can be defined as the procedure or mechanism
of acquiring all the properties and behavior of one class to
another, i.e., acquiring the properties and behavior of child
class from the parent class.
• When one object acquires all the properties and
behaviours of another object, it is known as inheritance.
• It provides code reusability and establishes relationships
between different classes. A class which inherits the
properties is known as Child Class(sub-class or derived
class) whereas a class whose properties are inherited is
known as Parent class(super-class or base class).
• Types of inheritance in java: single, multilevel and
hierarchical inheritance. Multiple and hybrid inheritance is
supported through interface only.
Introduction to oop and java fundamentals
POLYMORPHISM
• When one task is performed by different ways
i.e. known as polymorphism. For example: to
draw something e.g. shape or rectangle etc.
Polymorphism is classified into two ways:
Method Overloading(Compile time Polymorphism)
• Method Overloading is a feature that allows a class to
have two or more methods having the same name but
the arguments passed to the methods are different.
Compile time polymorphism refers to a process in
which a call to an overloaded method is resolved at
compile time rather than at run time.
Method Overriding(Run time Polymorphism)
• If subclass (child class) has the same method as
declared in the parent class, it is known as method
overriding in java. In other words, If subclass provides
the specific implementation of the method that has
been provided by one of its parent class, it is known as
method overriding.
ABSTRACTION
• Abstraction refers to the act of representing
essential features without including the
background details or explanations.
For example: phone call, we don't know the
internal processing. In java, we use abstract class
and interface to achieve abstraction.
ENCAPSULATION
• The wrapping up of data and methods into a single unit (called class) is known as
encapsulation.
• Data encapsulation is the most striking feature of a class. The data is not accessible
to' the outside world and only those methods, which are wrapped in the class, can
access it. These methods provide the interface between the object's data and the
program.
• i.e. mixed of several medicines. A java class is the example of encapsulation.
• This insulation of the data from direct access by 'the program is called data hiding.
Message Communication:
• 1. Creating classes that define objects and
their behaviour.
• 2. Creating objects from class definitions.
• 3. Establishing communication among objects.
Introduction to oop and java fundamentals
Dynamic Binding
• Dynamic binding means that the code
associated with a given procedure call is not
known until the time of the call at runtime.
DIFFERENCE BETWEEN PROCEDURE-ORIENTED AND OBJECT-ORIENTED
PROGRAMMING
JAVA
• Java is a robust, general-purpose, high-level
programming language and a powerful software
platform. It is also object-oriented, distributed,
portable and multi-threaded. Java follows the 'Write -
once - run - anywhere' approach.
• All Java programs must run on the Java platform that
has two components,
i. Java Virtual Machine (JVM)
Ii.Java Application Programming Interface (API).
• With Java API, many types of Java programs can be
developed. These include
Java stand-alone applications
Java Applets
Java Servlets
Introduction to oop and java fundamentals
Characteristics of Java language
• Compiled and Interpreted
• Platform-Independent and Portable
• Object-Oriented
• Robust and Secure
• Distributed
• Familiar, Simple. and Small
• Multithreaded and Interactive
• High Performance
• Dynamic and Extensible
THE JAVA PROGRAMMING
ENVIRONMENT:
STRUCTURE OF JAVA PROGRAM
A Java program involves the following sections:
• Documentation Section
• Package Statement
• Import Statements
• Interface Statement
• Class Definition
• Main Method Class
• Main Method Definition
COMPILATION AND EXECUTION OF A
JAVA PROGRAMCompilation
• First, the source .java‘ file is passed through the compiler, which
then encodes the source code into a machine independent
encoding, known as Bytecode. The content of each class contained
in the source file is stored in a separate .class‘ file.
Execution
• The class files generated by the compiler are independent of the
machine or the OS, which allows them to be run on any system. To
run, the main class file (the class that contains the method main) is
passed to the JVM, and then goes through three main stages before
the final machine code is executed. These stages are:
a. Class Loader
b.Bytecode Verifier
c.Just-In-Time Compiler
Introduction to oop and java fundamentals
FUNDAMENTAL PROGRAMMING
STRUCTURES IN JAVA
• COMMENTS
– System.out.println("Hello, World!"); // comment
– /* and */
– /** to start and a */ to end
public class JavaApplication1
{
public static void main(String[] args)
{
System.out.println("welcome");
}
}
DATA TYPES
1) Integers
• Java defines four integer types: byte, short,
int, and long.
Introduction to oop and java fundamentals
2. Floating-Point Types
3. Characters
It is a unification of dozens of character sets, such as Latin,
Greek, Arabic, Cyrillic, Hebrew, Katakana, Hangul, and many
more. For this purpose, it requires 16 bits. Thus, in Java char is
a 16-bit type. The range of a char is 0 to 65,536.
Although char is designed to hold Unicode characters, it can
also be thought of as an integer type on which you can
perform arithmetic operations
4. Booleans
Literals
• 1. Integer Literals
• 2. Floating-Point Literals
• 3. Boolean Literals
• 4. Character Literals
• 5. String Literals
VARIABLES• The variable is the basic unit of storage in a Java program.
• Declaring a Variable
type identifier [ = value][, identifier [= value] ...] ;
• int a, b, c; // declares three ints, a, b, and c.
• int d = 3, e, f = 5; // declares three more ints, initializing // d and f.
Dynamic Initialization:
double c = Math.sqrt(a * a + b * b);
The Scope and Lifetime of Variables
There are two general categories of scopes:
• global and
• local
Type Conversion and Casting -int value to a long variable
Casting Incompatible Types
int a;
byte b;
// ...
b = (byte) a;
OPERATORS
• 1. Arithmetic Operators:
• 2. The Bitwise Operators
• 3. Relational Operators
• 4. Boolean Logical Operators
• 5. Short-Circuit Logical Operators
• 6. The Assignment Operator:
• 7. The ? Operator
– General form:
– expression1 ? expression2 : expression3
CONTROL STATEMENTS
Java‘s program control statements can be put
into the following categories:
• Selection statements
• Iteration statements
• Jump statements
1. Selection statements
Java supports two selection statements:
• if
• switch
2. Iteration Statements
Java‘s iteration statements are
• for
for(initialization; condition; iteration) {
// body
}
• do-while
• while
while(condition) {
// body of loop
}
• do-while

More Related Content

PPTX
Event handling
PDF
PPTX
Arrays in Java
PDF
Methods in Java
PPTX
Strings in Java
PPTX
Java abstract class & abstract methods
PDF
Oops concepts || Object Oriented Programming Concepts in Java
PPTX
Event In JavaScript
Event handling
Arrays in Java
Methods in Java
Strings in Java
Java abstract class & abstract methods
Oops concepts || Object Oriented Programming Concepts in Java
Event In JavaScript

What's hot (20)

PDF
Arrays in python
PPT
SQLITE Android
PPTX
This keyword in java
PPT
Jsp ppt
PDF
Arrays in Java
PPT
Basic concept of OOP's
ODP
OOP java
PPTX
Basics of JAVA programming
PPTX
Android User Interface
PPTX
Android activity lifecycle
PPTX
Arrays in java
PPT
Serialization/deserialization
PPTX
Applets in java
PDF
Class and Objects in Java
PPTX
Notification android
PPTX
Interface in java ,multiple inheritance in java, interface implementation
PPTX
PPTX
Android Architecture.pptx
PPTX
SQLite database in android
PPTX
Java string handling
Arrays in python
SQLITE Android
This keyword in java
Jsp ppt
Arrays in Java
Basic concept of OOP's
OOP java
Basics of JAVA programming
Android User Interface
Android activity lifecycle
Arrays in java
Serialization/deserialization
Applets in java
Class and Objects in Java
Notification android
Interface in java ,multiple inheritance in java, interface implementation
Android Architecture.pptx
SQLite database in android
Java string handling
Ad

Similar to Introduction to oop and java fundamentals (20)

PPTX
INDUMATHY- UNIT 1 cs3391 oops introduction to oop and java.pptx
PDF
Cs8392 oops 5 units notes
PPTX
U1 JAVA.pptx
PDF
MCA NOTES.pdf
PPTX
oop unit1.pptx
PPTX
Java Programming - UNIT - 1, Basics OOPS, Differences
PPTX
PDF
M.c.a. (sem iv)- java programming
PPTX
object oriented programming unit one ppt
PPTX
ppt_on_java.pptx
DOCX
Class notes(week 2) on basic concepts of oop-2
DOCX
Object Oriented Programming All Unit Notes
PPTX
Object Oriented Programming Tutorial.pptx
PDF
Class notes(week 2) on basic concepts of oop-2
PPTX
UNIT I OOP AND JAVA FUNDAMENTALS CONSTRUCTOR
PDF
Complete Java Course
PPT
Java Tutorials
PPTX
Android Training (Java Review)
PDF
Java chapter 3
DOCX
OOP Lab-manual btech in cse kerala technological university
INDUMATHY- UNIT 1 cs3391 oops introduction to oop and java.pptx
Cs8392 oops 5 units notes
U1 JAVA.pptx
MCA NOTES.pdf
oop unit1.pptx
Java Programming - UNIT - 1, Basics OOPS, Differences
M.c.a. (sem iv)- java programming
object oriented programming unit one ppt
ppt_on_java.pptx
Class notes(week 2) on basic concepts of oop-2
Object Oriented Programming All Unit Notes
Object Oriented Programming Tutorial.pptx
Class notes(week 2) on basic concepts of oop-2
UNIT I OOP AND JAVA FUNDAMENTALS CONSTRUCTOR
Complete Java Course
Java Tutorials
Android Training (Java Review)
Java chapter 3
OOP Lab-manual btech in cse kerala technological university
Ad

Recently uploaded (20)

PDF
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
PPTX
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
PPTX
history of c programming in notes for students .pptx
PDF
2025 Textile ERP Trends: SAP, Odoo & Oracle
PDF
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
PPTX
CHAPTER 12 - CYBER SECURITY AND FUTURE SKILLS (1) (1).pptx
DOCX
The Five Best AI Cover Tools in 2025.docx
PDF
How to Choose the Right IT Partner for Your Business in Malaysia
PPTX
ISO 45001 Occupational Health and Safety Management System
PDF
Digital Strategies for Manufacturing Companies
PPTX
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
PDF
System and Network Administration Chapter 2
PDF
Softaken Excel to vCard Converter Software.pdf
PPTX
Materi_Pemrograman_Komputer-Looping.pptx
PPTX
Introduction to Artificial Intelligence
PDF
How Creative Agencies Leverage Project Management Software.pdf
PDF
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
PDF
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
PPTX
VVF-Customer-Presentation2025-Ver1.9.pptx
PPTX
Online Work Permit System for Fast Permit Processing
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
history of c programming in notes for students .pptx
2025 Textile ERP Trends: SAP, Odoo & Oracle
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
CHAPTER 12 - CYBER SECURITY AND FUTURE SKILLS (1) (1).pptx
The Five Best AI Cover Tools in 2025.docx
How to Choose the Right IT Partner for Your Business in Malaysia
ISO 45001 Occupational Health and Safety Management System
Digital Strategies for Manufacturing Companies
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
System and Network Administration Chapter 2
Softaken Excel to vCard Converter Software.pdf
Materi_Pemrograman_Komputer-Looping.pptx
Introduction to Artificial Intelligence
How Creative Agencies Leverage Project Management Software.pdf
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
VVF-Customer-Presentation2025-Ver1.9.pptx
Online Work Permit System for Fast Permit Processing

Introduction to oop and java fundamentals

  • 1. INTRODUCTION TO OOP AND JAVA FUNDAMENTALS N.ANSGAR MARY AP/IT
  • 3. Unit I • Object Oriented Programming - Abstraction – objects and classes - Encapsulation- Inheritance- Polymorphism- OOP in Java – Characteristics of Java – The Java Environment - Java Source File - Structure Compilation. Fundamental Programming Structures in Java – Defining classes in Java – constructors, methods - access specifiers - static members - Comments, Data Types, Variables, Operators, Control Flow, Arrays, Packages - JavaDoc comments.
  • 4. OBJECT-ORIENTED PROGRAMMING Object-Oriented Programming (OOP) is a programming language model organized around objects rather than actions and data. An object-oriented program can be characterized as data controlling access to code. Concepts of OOPS • Object • Class • Inheritance • Polymorphism • Abstraction • Encapsulation
  • 6. OBJECT • Object means a real word entity such as pen, chair, table etc. • Any entity that has state and behavior is known as an object. • Object can be defined as an instance of a class. • An object contains an address and takes up some space in memory. Objects can communicate without knowing details of each other's data or code, the only necessary thing is that the type of message accepted and type of response returned by the objects. • An object has three characteristics: • state: represents data (value) of an object. • behavior: represents the behavior (functionality) of an object such as deposit, withdraw etc. • identity: Object identity is typically implemented via a unique ID. The value of the ID is not visible to the external user. But, it is used internally by the JVM to identify each object uniquely.
  • 7. Example of an object : dog1
  • 8. CLASS • Collection of objects is called class. • It is a logical entity. • A class can also be defined as a blueprint from which you can create an individual object. • A class consists of Data members and methods. • The primary purpose of a class is to hold data/information. • The member functions determine the behavior of the class, i.e. provide a definition for supporting various operations on data held in the form of an object. • Class doesn’t store any space.
  • 11. Example public class Dog { String breed; int age; String color; void barking() { } void hungry() { } void sleeping() { } }
  • 12. Constructors • Each time a new object is created, at least one constructor will be invoked. The main rule of constructors is that they should have the same name as the class. A class can have more than one constructor. Following is an example of a constructor − Example public class Puppy { public Puppy() { } public Puppy(String name) { // This constructor has one parameter, name. } }
  • 14. INHERITANCE • Inheritance can be defined as the procedure or mechanism of acquiring all the properties and behavior of one class to another, i.e., acquiring the properties and behavior of child class from the parent class. • When one object acquires all the properties and behaviours of another object, it is known as inheritance. • It provides code reusability and establishes relationships between different classes. A class which inherits the properties is known as Child Class(sub-class or derived class) whereas a class whose properties are inherited is known as Parent class(super-class or base class). • Types of inheritance in java: single, multilevel and hierarchical inheritance. Multiple and hybrid inheritance is supported through interface only.
  • 16. POLYMORPHISM • When one task is performed by different ways i.e. known as polymorphism. For example: to draw something e.g. shape or rectangle etc.
  • 17. Polymorphism is classified into two ways: Method Overloading(Compile time Polymorphism) • Method Overloading is a feature that allows a class to have two or more methods having the same name but the arguments passed to the methods are different. Compile time polymorphism refers to a process in which a call to an overloaded method is resolved at compile time rather than at run time. Method Overriding(Run time Polymorphism) • If subclass (child class) has the same method as declared in the parent class, it is known as method overriding in java. In other words, If subclass provides the specific implementation of the method that has been provided by one of its parent class, it is known as method overriding.
  • 18. ABSTRACTION • Abstraction refers to the act of representing essential features without including the background details or explanations. For example: phone call, we don't know the internal processing. In java, we use abstract class and interface to achieve abstraction.
  • 19. ENCAPSULATION • The wrapping up of data and methods into a single unit (called class) is known as encapsulation. • Data encapsulation is the most striking feature of a class. The data is not accessible to' the outside world and only those methods, which are wrapped in the class, can access it. These methods provide the interface between the object's data and the program. • i.e. mixed of several medicines. A java class is the example of encapsulation. • This insulation of the data from direct access by 'the program is called data hiding.
  • 20. Message Communication: • 1. Creating classes that define objects and their behaviour. • 2. Creating objects from class definitions. • 3. Establishing communication among objects.
  • 22. Dynamic Binding • Dynamic binding means that the code associated with a given procedure call is not known until the time of the call at runtime.
  • 23. DIFFERENCE BETWEEN PROCEDURE-ORIENTED AND OBJECT-ORIENTED PROGRAMMING
  • 24. JAVA • Java is a robust, general-purpose, high-level programming language and a powerful software platform. It is also object-oriented, distributed, portable and multi-threaded. Java follows the 'Write - once - run - anywhere' approach. • All Java programs must run on the Java platform that has two components, i. Java Virtual Machine (JVM) Ii.Java Application Programming Interface (API). • With Java API, many types of Java programs can be developed. These include Java stand-alone applications Java Applets Java Servlets
  • 26. Characteristics of Java language • Compiled and Interpreted • Platform-Independent and Portable • Object-Oriented • Robust and Secure • Distributed • Familiar, Simple. and Small • Multithreaded and Interactive • High Performance • Dynamic and Extensible
  • 28. STRUCTURE OF JAVA PROGRAM A Java program involves the following sections: • Documentation Section • Package Statement • Import Statements • Interface Statement • Class Definition • Main Method Class • Main Method Definition
  • 29. COMPILATION AND EXECUTION OF A JAVA PROGRAMCompilation • First, the source .java‘ file is passed through the compiler, which then encodes the source code into a machine independent encoding, known as Bytecode. The content of each class contained in the source file is stored in a separate .class‘ file. Execution • The class files generated by the compiler are independent of the machine or the OS, which allows them to be run on any system. To run, the main class file (the class that contains the method main) is passed to the JVM, and then goes through three main stages before the final machine code is executed. These stages are: a. Class Loader b.Bytecode Verifier c.Just-In-Time Compiler
  • 31. FUNDAMENTAL PROGRAMMING STRUCTURES IN JAVA • COMMENTS – System.out.println("Hello, World!"); // comment – /* and */ – /** to start and a */ to end public class JavaApplication1 { public static void main(String[] args) { System.out.println("welcome"); } }
  • 32. DATA TYPES 1) Integers • Java defines four integer types: byte, short, int, and long.
  • 34. 2. Floating-Point Types 3. Characters It is a unification of dozens of character sets, such as Latin, Greek, Arabic, Cyrillic, Hebrew, Katakana, Hangul, and many more. For this purpose, it requires 16 bits. Thus, in Java char is a 16-bit type. The range of a char is 0 to 65,536. Although char is designed to hold Unicode characters, it can also be thought of as an integer type on which you can perform arithmetic operations 4. Booleans
  • 35. Literals • 1. Integer Literals • 2. Floating-Point Literals • 3. Boolean Literals • 4. Character Literals • 5. String Literals
  • 36. VARIABLES• The variable is the basic unit of storage in a Java program. • Declaring a Variable type identifier [ = value][, identifier [= value] ...] ; • int a, b, c; // declares three ints, a, b, and c. • int d = 3, e, f = 5; // declares three more ints, initializing // d and f. Dynamic Initialization: double c = Math.sqrt(a * a + b * b); The Scope and Lifetime of Variables There are two general categories of scopes: • global and • local Type Conversion and Casting -int value to a long variable Casting Incompatible Types int a; byte b; // ... b = (byte) a;
  • 38. • 2. The Bitwise Operators
  • 39. • 3. Relational Operators
  • 40. • 4. Boolean Logical Operators • 5. Short-Circuit Logical Operators
  • 41. • 6. The Assignment Operator: • 7. The ? Operator – General form: – expression1 ? expression2 : expression3
  • 42. CONTROL STATEMENTS Java‘s program control statements can be put into the following categories: • Selection statements • Iteration statements • Jump statements
  • 43. 1. Selection statements Java supports two selection statements: • if • switch
  • 44. 2. Iteration Statements Java‘s iteration statements are • for for(initialization; condition; iteration) { // body } • do-while