Java Notes For Class I
Java Notes For Class I
OBJECT an object is an identifiable entity with some characteristics & behavior. E.g. 1 Orange 2 chair
characteristics
1. It is spherical shape and color is orange
2. It has four legs, back and arms
behavior
1. It is citrus in nature and taste sour. 2. It lets you sit on it
Object interact with each other by passing message.
Basic concept of OOP (object oriented programming)
1.Abstraction refers to the act of representing essential features without including the background details or expressions.
2.Encapsulation the wrapping of data and functions into a single unit (class) is known as encapsulation.
3.Inheritance is the capability of one class of things to inherit capabilities and properties from another class.
4.Polymorphism is the ability for a message or data to be processed in more than one form. (function/constructor
overloading).
The object is implemented in software term as follows.
1. characteristics & Attributes are implemented through member variables or data items of the objects
2. behavior is implemented through member function called
methods/function.
Class represents a set of objects that share common characteristics & behavior.
A class is an object maker or object factory. Created objects are known as instance of class.
Source program the program written in high level language by programmer is called source code.
Machine code Computer needs source code to be converted into low level language to be executed
Byte code in java source code is not converted into machine code but is converted in byte code while compilation which
is same for all machines
Compiler/Interpreter They both are used for translating HLL into machine language. Compiler does it at once while
interpreter does it line by line.
JVM Java Virtual Machine is a java interpreter which translates byte code for specific platforms.
Characteristics of java.
1.Write once run anywhere 2. light weight code 3 security 4. built in graphics 5. object oriented language 6. supports
multimedia 7. platform independent 8. open product
Java Character set character set is a set valid characters that a language can recognize (i.e. letters, digit, sign etc.)
Unicode java uses Unicode character set. Unicode is a 2-byte character code set which represents almost all characters
first 128 are identical two ASCII code.
You refer to a particular Unicode by using \u followed by 4-digit hexadecimal number
Tokens the smallest individual unit in a java program is known as token. which are keywords, identifiers, literals,
punctuators, operators.
Keywords are the words that convey a special meaning to the language compiler (if, for etc.)
Identifiers are the name given to different parts of program e.g. variables, objects, class, arrays, function.
Literals are constant i.e. data item that are fixed values i.e. integer, Boolean, character, null, floating, string.
Punctuators separators e.g. (), [], {}
Operators =,>, <, = =, etc.
Data types are means to identify that type of data and associated operation of handling it.
1) primitive (byte, short, int, long, float, double, char, boolean)
2) Reference (class, array, interface).
Jump Statements :-these statements are used for transferring the control of program from one part of the program to
another part of the program. The jump statements used in JAVA are 1. break 2. continue 3 return .
Where as a library function System.exit() is used to jump out from program
1. break statement is used with blocks(eg. switch case) or loops to jump out from loop or block to the statement given
just after that block or loop.
Example :
for(i=0;i<10;i++)
{
if(i==5)
break;
System.out.print(i);
}
statement 1.
2. where as continue statement is used to transfer the control to the next iteration
Example :-
for(i=0;i<10;i++)
{
if(i==5)
continue;
System.out.print(i);
}
3. return statement is used to return a value from the function to the function from where that is called or you can say
return statement is used to make the immediate exit from the function within which it is used.
4. Nested Loops : when there are loops inside loop then they are said to be nested loop.
Differences and similarities in loop statements:-
1. for, do – while and while they all are used for forming loops.
2. They both are entry control loops where as do – while is a exit control loop.
3. In while loop if the test condition is false it will not be executed at least once but in do while even if the condition
is false it will be executed at least once.