0% found this document useful (0 votes)
32 views6 pages

Basic Elements of Oops

The document discusses the basic elements of object-oriented programming (OOP) in Java, including objects, classes, encapsulation, inheritance, polymorphism, and abstraction. It defines objects as unique entities with characteristics and behaviors. Classes are collections of similar objects and act as blueprints that produce object instances. Encapsulation groups related data and functions, inheritance allows classes to inherit characteristics from superclasses, and polymorphism allows the same function to be used for multiple purposes.

Uploaded by

bhaktikhanijo16
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
32 views6 pages

Basic Elements of Oops

The document discusses the basic elements of object-oriented programming (OOP) in Java, including objects, classes, encapsulation, inheritance, polymorphism, and abstraction. It defines objects as unique entities with characteristics and behaviors. Classes are collections of similar objects and act as blueprints that produce object instances. Encapsulation groups related data and functions, inheritance allows classes to inherit characteristics from superclasses, and polymorphism allows the same function to be used for multiple purposes.

Uploaded by

bhaktikhanijo16
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

BASIC ELEMENTS OF OOPS:

 Object
 Class
 Data Abstraction
 Polymorphism
 Encapsulation
 Encapsulation
 Inheritance
 Data Hiding
 Dynamic Binding

Object: It is unique identifiable entity with some characteristic "Data" and behavior "Functions".

Object:- Books

Characteristics:- chapters, pages, and topics

Behavior:- used to read and prepare notes.

Class:- Collection of similar types of objects. It is a blue print that describes the details of an object for
example class-students
Object - ram, Ina, rajest

Class is an object factory: Class is a proto type of an object. Each object belonging to a specific class
possesses the data and methods defined in it. It produces objects of similar types. Hence a class is
termed as object factory.

Class is user defined data type: Primitive data type is not sufficient. A user may create a data type and
declare certain characteristics and behavior with in it. This can be done by using a class. This is the
reason why a class is refer as user defined data type.

Object is an instance of an class: In java where each object is created from a class it is called an
instance of a class. Creating an instance of a class is referred as instantiating the class. Data member of
class are known as instance variable which are embedded automatically within an object at the time of
its creation hence object is referred as instance of class.

Class as a abstract data type: Abstraction is the absolute property of class. The class encapsulate the
data items and functions to promote abstraction. The data members are accessed through the related
functions since the class uses the property of abstraction it is known as abstract data type.

Class as a composite data type: A class is a tool to create user defined data type. The class name
becomes data type for the instances used in a program. It is such a data type that includes various pre
defined data types within it. Hence the class is known as composite data type.

Difference between class and object:

Class:

 It is representation of abstraction only.


 It is an object producer and hence called a blue print for a set of object.
 It is known as object factory.
Objects:

 It is a real and unique entity having some characteristics and behavior.


 It is created with the use of new operation.
 It is known as instance of class.

Encapsulation:- Wrapping of data and functions of a class together so that they can be applied as a
unit to perform any operations is termed as Encapsulation.

Data Abstraction: It is refers to an act of representing essential features without including the
background details.

Inheritance: It is the process in which object of one class can link and share some common properties
of the object with another class. The class whose features are shared are known as base class or super
class and that acquires the features is said to be derived or sub class.

Q. State the java concepts that implement a super class and a sub class?
Q. Act of representing essential features without knowing the background features?

Polymorphism: It is the process of using the functions for more than one purpose. It allow the use
different use of internal structure of the object by keeping some external phase.

Dynamic Binding: It is the process that links the function call with function signature at runtime i.e.
during the execution of program that is known as dynamic binding.

Reusability: It is the process of adding some additional feature to a class without modifying it content.
This means the new class acquires some feature from the existing class.

Static Binding: Linkage of functions with its caller program at the time of compilation is said to be
static binding.

Message Passing: When one object share information and another receive it is known as message
passing.

Data Hiding: The logical insulation of data from direct access is called data hiding.

Q. Create an object book of class library?


Q. Significance of new?

Ans: New is used for dynamic memory of the object that is it allots the dynamic memory for storage of
an object.

Chapter 2.

James A Gosling developed java in 1991. Java originally known as Oak.

Different types of Java Programs:


 Stand alone applications
 Java Applet: They are small java programs which are embedded with HTML to make the
website dynamic and interactive.
Features of Java:
 Java is an object oriented programming.
 Java programs are both compiled and interpreted.
 Java programs are platform independent.
 It is multi-threaded programming.

Compiler and Interpreter: All high level languages are need to be converted into machine code so
that the computer understand the program after taking the required inputs. The conversion of high level
language (source code) into machine language (object code) can be done in two possible ways by using
compiler and interpreter.

Interpreter: The conversion of high level instruction is performed line by line to machine level
language is know as interpreter. If an error is formed in any line the execution stops till it correct it.

Compiler: If all the instructions are converted to machine level language at once and all the errors are
listed together than the software is known as compiler.

Byte Code: It is a platform independent code when a java program is compiled the java compiler
convert a source code into a program independent code that a JVM (java virtual machine) can easily
understand and execute.

JVM (JAVA VIRTUAL MACHING): The programs written in java language are first converted into
byte code and then these codes are interpreted by using java interpreter for a particular platform to run.
So, the java interpreter is known as JVM and machine language for the JVM is known as Byte code.

Woara: Write once and run anywhere. It is given by the byte code instructions when java programs is
written and compiled then it will create a class file which consists of byte code instructions
understandable to JVM. Every system has its own JVM, so JVM will convert this byte code into
machine language understandable to the machine. So it has write once and run anywhere nature.

JDK (JAVA DEVELOPMENT KIT): Contains a java library for different purposes. Some useful
packages are

 Java.lang:- Support class for string, character, math's, etc.


 Java.IO:- Deals with input output statement
 Java.Applet:- Class to generate applet.
 Java.txt:- Support text element such as date, time, etc.
 Java.util:- Use for scanner classes.

Q. Name the default package included in java?


Q. Name package use for scanner class?
Q. Name 2 packages provided by java?

API (APPLICATION PROGRAMMING INTERFACE): "Application programming interface".


The library of pre compile code that can be used in java program are known as java API.

Q. What do you mean by import Statement?


Answer:
Import Java .IQ .* ;

Keyword for including the Package main package Sub package include all the classes
The import statement is to load the precompiled classes and instructions into the memory. For e.g.:
"import java.IQ.* "it means loading input output instructions used in a program.

Reserve Words or Keyword: They have specific meaning in java compiler which represents statement
or functions to perform specific task. These words cannot be used as a variable name. For eg: for, else,
int, double, string, etc.

Comments Statements in java: Comments are the statements, they are ignore by the java compiler
these cannot be executed. There are 3 types of java comments.

 Single line comments (//)


 Multiline comments (/*----------*\)
 Document comments (/**----------*\)

Chapter-3 JAVA TOKENS

Concepts of Data Types in Java: The smallest unit used in java program in such a way that it carry
some meaning and takes part in effective execution of programs.

Identifiers: Name used to identify variable, class, functions.

Rules for naming:

Name can be a collections of Alphabets (A_Z, a-z), Digits (0-9) and Underscore(_). No other special
symbols are allowed. There should be no space or dot between any letter or a variable. Name never
starts with digits. Name cannot be a keyword.

Variables:- Variable is a named memory location that is used to contain a value and can changed
depending on the circumstances and problem during the program execution.

Constants & Literals: Literals are the constants in java programs. In java some quantities remained
fixed throughout the execution of programs such quantities are termed as literals and constants.

1. Integers Literals: The numbers which are represented without decimal point are called Integer
Literals. These are the whole numbers having positive or negative values. E.g. 14, 345,8, 6392,
-18, -391 etc.

2. Real Literals: These are also called floating-point constants. They represent numbers with
decimal points. e.g. 24.6, 0.0072, -3.652, 1.0E-03 etc.

3. Character Literals: The constants, which are alphanumeric in nature, are called character
literals. All alphabets upper or lower case, digits, special characters can be termed as character
literals. E.g. A', 'd', '3', '*' etc.
A character literal represents a single character enclosed within single quotes.

4. String Literals: String is a set of alphanumeric characters. A group of characters enclosed


within a pair of opening and closing double quotes is known as string literal. E.g. "VIJAY
KUMAR PANDEY", "Year 2006", "10% per annum" etc.

5. Boolean Literals: Boolean constants are special literals. They represent true or false and can be
applied in a java program to ensure that a given logical condition is satisfied or not.
Null Literal: This is another special purpose literal. It is represented as '\0'. It is applied in a java
program as a string terminator to mark end of the string.

PUNCTUATORS: Punctuators are the punctuation signs used as special characters in java. Some of
the punctuators are:? (Questions mark), ; (semi colon), . (dot) etc.

Dot (.) is used to represent the scope of a function i.e. a function belonging to an object or a class.

e.g. system.out.println (), java.io.* etc.

Semi colon (;) is used in a java program as a statement terminator. It indicates the end of a statement.
Any line continued after semi colon is treated as the next line.

e.g. int a=5; System.out.println(a); are treated two separate statements in java.

SEPARATORS: They are the special characters in Java, which are used to separate the variables or
the characters.

e.g. Brackets (,), Curly brackets {,}, Square brackets [,] etc.

Comma (,) in a java program is applied to separate multiple variables under same declaration.

e.g. int a,b,c;

Brackets () are used to enclose any arithmetical or relational expressions.

Curly brackets {} are applied to enclose a group of statements under a compound statement.

Square brackets [] are used to enclose subscript


math.abs (-73)
math.abs (-73.25)
math.sqrt (81);
math.sqrt (81.9)
math.pow (3,2)
math.pow (-2,3)
math.round (1.5)
math.round (-1.5)
math.ceil (15.3)
math.ceil (15.52)
math.ceil (9.01)
math.ceil (-9.01)
math.max (15, 20)
math.max (-1.5, 1.5)
math.rint (25.3)
math.rint (25.5)
math.rint (-5.5)
double b= -15.6
double a= math.rint (Math .abs (b));
sop ("a=" +a)

You might also like