You are on page 1of 6

Data types – A data type is defined as the set of possible values a variable can hold.

There are two types of data in java.


i. Primitive data types ii. Non-primitive ( composite ) data types

Pritimitive data type with their range and size.


Name Size in byte Size in bits Range Default value
byte 1 8 -27 to 27 -1 0
-128 to 127
Short 2 16 -215 to 215 -1 0
-32768 to 32767
int 4 32 -231 to 231 -1 0

long 8 64 -263 to 263 -1 0

float 4 32 0.0

double 8 64 0.0

char 2 16 ‘\u0000’

boolean - 1 false

ii. Non-primitive data type (composite data type) –


eg – String , Arrays , class etc

String – It’s a predefined class which is used to store a set of alphanumeric. It


creates object.
String s = “CARMEL”;
String s1 = new String(“CARMEL” );
String s2 = new String ( s) ; - it is equivalent to String s1 ;

Syntax To create any object :


Class name Object name = new constructor
eg i. Student RAHUL = new Student ( );
ii Flower Rose = new Flower ( );

POPS – procedural programming is a method where the larger program is broken down into smaller
subprograms called module or procedure. In this method is more important than data.

OOPS – oops focuses on data rather than procedure. It’s a modular approach which allows the data
to be applied within stipulated program area.
Features : Reusability
Robust
Secure
Platform Independent
Object – An object is an identifiable or unique entity which contains data and function.
A software object is a software unit of related variable and methods. Software objects
are used to model real world objects we find in daily life.
Eg Table , chair belongs to Furniture class
Pen ,pencil ,eraser belongs to stationary class
An object contains instance variables and member methods defined within the class. Hence an object
is called an instance of class.

Class – A class is a group of similar objects that share common properties , relationships and
behaviours. It’s a blueprint or prototype of objects.
Class produces objects of similar type that’s why its called factory of objects.
To represent any class , user is actually creating a data type of his own i.e A class is known as user
defined data type.

Message – Software objects interact and communicate with each other using messages.

Abstraction – The act of representing essential features without including the background details.
Since the classes use the concept of data abstraction , they are also known as Abstract Data Type
(ADT)

Encapsulation – The wrapping up of data and functions into a single unit is known as
encapsulation.

Data hiding – The process of protecting data from direct access by the program is called data
hiding or information hiding.

Inheritance – it’s the process by which objects of one class acquire the properties of objects of
another class. It provides the facility of reusability.

Polymorphism – The ability of a message or data to be processed in more than a single form is
called polymorphism.

Dynamic Binding – All objects are created during run time . Dynamic binding is the process to
link the function call with function signature at run time i.e during execution of a program.

JVM- The java byte is a machine instruction for the java processor chip called the JVM.

Java programs – java application and Java applets

Comments in Java – It improves the readability of a program. They are ignored by compiler.
Three types of comments in java –
1. single line comment - // this is used for single line
2. Multiline lne - /* this is used for
More than one line * /
3. Documentation comment - /** for brief description */
Escape Sequences –The escape sequences help to control the cursor’s movement on the output
screen. It starts with backslash ( \ ) followed by a specific character.
Eg “\n” – new line “\t” – tab feed
Syntax error – this error occurs when the syntax of any program is wrong . eg missing semi colon
, comma or spelling mistake.

Run time error – The errors that occurs during execution time are called Run –Time errors.

Logical error- This error cannot be identified by compiler. It’s a error in a program.

Byte code – Java programs are both compiled and interpreted. The java compiler translates the
source code to an intermediate level language called byte code. Then java interpreter coverts byte
code to the machine code.

Source code -------------------Byte code------------------Machine code

Token – A smallest individual element of java program.


Eg – int a;

Keywords – Resevered words of java program is known as keyword.


Eg – int , byte ,if, for

Identifiers – An Identifier is a sequence of character used to name variables .


Rules :-first letter should be an alphabet
Keyword cannot be used as a variable name.
Special character not allowed
Its case sensitive

Literal – A program element whose value remains unchanged during the course of the program is
called a literal.
Types of literals –
i. Integer literal – used to store only integer number . eg int n = 10;
Types of integer literal –
a.Decimal literal – These are the numbers in base 10. they are formed from the digit 0 to 9
eg 29 ,1234

b. Octal literal – These are the numbers in base 8. they are formed from the digit 0 to
7.But the first digit is 0 eg 07 ,04 etc

c.Hexadecimal –These are the numbers in base 16. they are formed from he digits 0 to 9
and then A to F. They are represented by leading 0 and X
eg 0X2 , 0XF 0X56
ii.Character literal – A single character enclosed between single quote. eg ‘A’ , ‘5’ , ‘+’

iii. Boolean literal – A Boolean literal can be either true or false.

iv. Floating literal – These are the decimal integers with a fractional component.
eg 5.50 , 2.67

v. String literal – A group of characters enclosed between double quote “ “


eg “carmel” ,”45”

Null literal – It is represented as ‘\0’. It is applied in a java program as a string terminator .


Null statement – An empty statement is called a null statement.
Static Initialization – The variable is initialized during its declaration.
eg int a=5;

Dynamic Initialization – Dynamic initialization means that any variable can be initialized during
run time using expressions.
int t = 4; // static initialization
eg double area = 3.14 * r*r // Dynamic initialization

final keyword - It’s a keyword which is used with numeric data type whose purpose is to fix the
value throughout the program . That means that cannot be update .
eg final int a=5;
a=a+10 ; // cannot be done , run time error

Expression – An expression is a sequence of operators and operand.It can be arithmetic , logical and
compound expression.
Expressions that have all opereands of same type are called pure expressions where as
expressions that have operands of different data types are called mixed expressions.
int a,b,c ; c= a+b; // pure expression
int a; float b; double c; c= a+b ; // mixed expression

Type conversion – The process of converting of one predefined type to another is called type
conversion. It has two types – Implicit type and Explicit type
i. Implicit type - In mixed expression , the data type of the result gets converted
automatically into its higher type without intervention of the user.It is also known as
coercion.
int a; long b; long c;
c = a + b;

ii. Explicit type – When the data type gets converted to another type after user intervention,
the type conversion is known as explicit type conversion.

int a,b ;
float x = (float ) (a+b);

Modulo operator – This operator divides one operand by another and returns the remainder as its
result.

Precedence of operator – The order in which the operators in an expression are evaluated is known
as operator precedence. The operator Associativity is the set of rules how operators are grouped and
evaluated in an expression where more than one operator exists with the same precedence.
Unary op , * , / , % ,+ , - , comparions , && ,|| ,=

Arithmetical operator – The five arithmetical operations supported by java ( + ,- ,* ,/ ,%).


It is used for mathematical calculations

Relational operator- Relational operators are binary operators that evaluate comparisions between
two operands or expression.
eg > , < ,>= ,<= ,!= ,= =

Logical operator – It s used to along with relational expressions to combine them. Java provides six
logical operator .
eg (! , & , ^ ,| , && ,| | )

Java Features :
1. Platform independent
2. Reusability
3. Robust language

Reusability – It’s a process of adding some additional features to a class without modifying its
contents. This process can easily be attained if a class inherits another class which means the new
class contains some features of the existing class.

Jump statement – Break and continue


Break – This statement can be used to transfer the execution flow outside the loop body.

Continue – The statement changes the flow of execution to stop the sequential execution and resume
the loop in the next iteration

Shorthand operations : - In java expression can be written in short form .


Eg a = a + b can be written as a + = b
a = a * b can be written as a*=b
unary operator :- it takes one operand and one operator . eg + , - ++ ,--

- a , a++ , --a
Binary – It takes two operand and one operator eg A + B , A * B

Ternary Operator (conditional operator ) – It takes three operand and two operator.
Eg Variable = (condition ) ? Statement 1 : Statement 2

Package – Package is a collection of classes. Import keyword is used to fetch the


supporting files which is stored under any package.

Fall Through – In a program where multiple cases are available , the control needs to
execute a specific case block for a given switch value. Under the circumstances , if
break statement is not applied at the end of a case then he control enters into the next
case statement for the execution. This unusual execution of more than one cases at a
time is termed as fall through .

Testing – it’s a process in which a program is validated.


Debugging – It’s a process in which the errors in the program are removed.

Compound statement : Multiple statement written within braces { } are known as


compound statement or block in java.

Null loop – A loop statement which does not include any statement as body of the
loop is called null loop or empty loop.
Eg for( I=1 ; I<5 ;I++) ;
A semicolon is placed after closing braces in a for loop indicates that the loop does not
execute any statement under it or body of the loop is not available. The purpose of
using such looping is simply to create delay during execution.
Infinite loop – A loop which will never end is known as infinite loop
Eg for ( i=1 ; i>0 ; i++)
{
Body of the loop
}

Nested Loop – A loop within a loop is known as nested loop. It can be nested a any
depth .

While loop Do while loop


1. This loop is known as entry controlled 1.This loop is known as exit controlled
loop loop
2.This loop will not execute at all if the 2. This loop will execute at least once
condition is not satisfied even the condition is false.

Wrapper classes – A wrapper class is a member of java library java. lang . It wraps the primitive
data values in object.
Eg Character , Byte,Short,Integer,Long,Float , Double

Instance variable – A variable whose value can be changed object to object is known as instance
variable. Eg int a , char c

Class variable/Static variable – A static data member is an instance variable which is global in the
class and used commonly by all the objects of that class type.( In short A vaiable whose value cannot
be changed object to object.) static keyword is to make any variable class variable.
Eg static double pi=3.14;
Static member method – A static member method is a member method which uses only static data
members or static instance variable
String StringBuffer
1. String type object has fixed length 1. String Buffer type object has provisions
2. New object is created to produce the To change the length
change 2.Change is maintained in the same object.

You might also like