Professional Documents
Culture Documents
Introduction
There are two types of program. One focuses on data where as other focuses on function. It can also be
written as what is happening and who is being affected. There are two paradigms that govern how a
program is constructed. They are process oriented[i.e. c] and object oriented[i.e. c++, JAVA].
1. Simple
2. Object oriented
3. Robust
4. Multithreaded
5. Architecture neutral
6. Interpreted and high performance
7. Distributed
8. Dynamic
1. Object
2. Class
3. Method
4. Instance variable
i. Separators/Words
ii. White space
iii. Literal
iv. Identifier
v. Keyword[50 out of which 48 is only use]
vi. Comment line
vii. Data type
viii. Variable
1. Integer[sign]
a. Byte=It use 8bit[1 byte]. The range from -27 to 27-1
b. Short=It use 16bit[2 bytes]. The range from -215 to 215-1
c. Int=It use 32bit[4 bytes]. The range from -231 to 231-1
d. Long=It use 64bit[8 bytes]. The range from -263 to 263-1
2. Float[sign]
a. Float=It use 32bit[4 bytes]
b. Double=It use 64bit[8 bytes]
3. Character
• Character=It use 16bit[2 bytes]
4. Boolean
• Boolean=It use 1 bit
Downloaded from Saral Notes Learn something new today. Join Group
Keywords
• Implicit conversion=The conversion done by program itself is called implicit conversion. This is done
for same type of data from small data type to larger type of data
• Explicit conversion=The conversion made by programmer is called explicit conversion. This can be
done in different data type and also from larger to small data type
Array
➢ Types
• One dimensional array
• Multi dimensional array
Operators
1. Arithmetic operator=The operands of arithmetic operators must be of numeric type. We cannot use
them in Boolean type
2. Module operator=The module operator ‘%’ returns the remainder of division operator
3. Assignment operator/short hand notation=Java programs special operations that can be used to
combine an arithmetic operators with an assignment operator
4. Increment and decrement operator=This is denoted by ++ or --. There are two types: pre and post
For example
5. Relational operator=It determine the relationship, the one operand has to other. The result produced by
a relational operator is a Boolean value
6. Boolean operator=The logical operator inverts the Boolean state
7. Ternary operator=The ternary operators(?:) is used for basic conditional expression. So it is also called
conditional operator
8. Bitwise operator=The bitwise operator is used for integer type
Control statement
• Selection statement
➢ If
➢ Nested if
➢ If else-else if ladder
➢ Switch
• Iteration statement
➢ While
➢ Do-while
➢ For
➢ For-each version of loop
Jump statement
• Break
• Continue
• Return
Class
Object
Method
Parameters
Constructors
Method overloading
Conflict
Constructor overloading
Garbage collection
Downloaded from Saral Notes Learn something new today. Join Group
Garbage collection is a form of memory management. The garbage collector attempts to reclaim or memory
occupied by object that are no longer in used by the program
Argument passing
Call by value
Call by reference
Recursion
Access control
Public
Private
Protected
Static[variable, method]
String
Inheritance
The process of carrying some of common feature from super class to sub class is inheritance. It can be
remove with final keyword
Super class
Type of inheritance
Single inheritance
Multiple inheritance
Multilevel inheritance
Hybrid inheritance
Super keyword
Method overriding
Abstract class
Exception
Exceptions is an object that describe an exceptional(i.e. error) condition that occur in a code
Try
Catch
Finally
Downloaded from Saral Notes Learn something new today. Join Group
Throw
throws
Thread
Synchronization
Enumerations
An enumeration is a list of named constants. In Java, an enumeration can have constructors, methods, and
instance variables.
Autoboxing
Autoboxing is the process by which a primitive type is automatically encapsulated (boxed) into its
equivalent type wrapper whenever an object of that type is needed. There is no need to explicitly construct
an object.
Auto-unboxing is the process by which the value of a boxed object is automatically extracted (unboxed)
from a type wrapper when its value is needed. There is no need to call a method such as intValue( ) or
doubleValue( ).
String
String buffer
File
The class File is used for creation of files and directories, file searching, file deletion etc. The File object
represents the actual file/directory on the disk. There are following constructors to create a File object
Package
Downloaded from Saral Notes Learn something new today. Join Group
1. Hello world
Answer
class Example
System.out.println(“hello world”);
Output
2. Declaration of variable
Answer
class Example
int num=100;
System.out.println(“this is num:”+num);
num=num*5;
Output
Downloaded from Saral Notes Learn something new today. Join Group
3. Use of if
Answer
class Sample
int x, y;
x=10;
y=20;
if(x<y)
x=x*2;
if(x==y)
x=x*2;
if(x>y)
x=x*2;
if(x==y)
Output
4. Use of integer
Answer
class Light
intlightspeed;
long days;
long seconds;
long distance;
lightspeed=186000;
days=100;
seconds=days*24*60*60;
distance=lightspeed*seconds;
System.out.println(“in”+days);
System.out.println(distance+“miles”);
Output
Downloaded from Saral Notes Learn something new today. Join Group
5. Use of character
Answer
classCharDemo
char ch1,ch2;
ch1=88;
ch2=’y’;
System.out.println(ch1+“”+ch2);
Output
6. Use of character
Answer
class CharDemo2
char ch1;
Downloaded from Saral Notes Learn something new today. Join Group
ch1=’x’;
System.out.println(“ch1 contains”+ch1);
ch1++;
System.out.println(“ch1 is now”+ch1);
Output
Downloaded from Saral Notes Learn something new today. Join Group