OOPs - Lecture 03 - OOPs Concept, Datatypes, Variables
OOPs - Lecture 03 - OOPs Concept, Datatypes, Variables
Lecture 03
Learning Outcome
After the completion of today’s lecture you will be able to:
• Illustrate all the OOPs concepts.
• Relate the OOPs concept with real world examples.
• Learn the lexical issues in java
• List various keywords in java
OOPs concepts
Encapsulation
Polymorphism
Abstraction
• Abstraction means showing essential features and hiding non-essential features
to the user.
• It is used to manage complexity easily.
• eg
Encapsulation
• Encapsulation means which binds the data and code (or) writing operations and
methods in single unit.
• Encapsulation is the mechanism that binds together code and the data it
manipulates, and keeps both safe from outside interference and misuse.
• eg
Polymorphism
• Polymorphism (from Greek, meaning “many forms”) is a feature that allows one
interface to be used for a general class of actions.
• The specific action is determined by the exact nature of the situation.
• Polymorphism means ability to take more than one form that an operation can
exhibit different behavior at different instance depend upon the data passed in
the operation.
• eg
Inheritance
• Inheritance is the process by which one object acquires the properties of another
object.
• This is important because it supports the concept of hierarchical classification.
• eg
Lexical issues
• Whitespaces: No indentation required. All can be written in one line.
• Identifiers: Identifiers are used to name things, such as classes,
variables, and methods. An identifier may be any descriptive
sequence of uppercase and lowercase letters, numbers, or the
underscore and dollar-sign characters. (The dollar-sign character is
not intended for general use.) They must not begin with a number,
lest they be confused with a numeric literal.
• Literals: A constant value in Java is created by using a literal
representation of it.
Java Keywords
Datatypes in Java
Data Types
Primitive Reference/Object
Primitive data types
• Integers This group includes byte, short, int, and long, which are for
whole-valued signed numbers.
• Floating-point numbers This group includes float and double, which
represent numbers with fractional precision.
• Characters This group includes char, which represents symbols in a
character set, like letters and numbers.
• Boolean This group includes boolean, which is a special type for
representing true/false values.
Reference/Object Data type
• These are created or developed by programmers.
• Eg.
Employee e;
Where Employee is a class and “e” is an object of the class.
So, here e is the reference/object data types.
Variables
• The variable is the basic unit of storage in a Java program.
• A variable is defined by the combination of an identifier, a type, and
an optional initializer.
• Java supports dynamic initialization
Eg:
Types of variable
Class A
{
Instance
Variable