Day 1: Introduction To OOP and Java
Day 1: Introduction To OOP and Java
Class Object
Car Maruti-800,
Mobile Nokia-X6, Samsung Galaxy
Pen Raynold Jetter
Dog Tommy
Features of OOPs-
1. Encapsulation & Abstraction
2. Polymorphism
3. Inheritance
4. Message Passing
Java
1. Java was developed by James Gosling in
1990 at sun macrosystem.
2. It is a case sensitive langauge.
3. The Extention of Java Program must be
.java.
4. Java is a plateform independent language.
5. Java is technicaly known as JVM(java
virtual machine)
JVM= JDK (Java Developement Kit)+ JRE
(Java Runtime Environment)
6. Java uses compiler for converting high
level code into machine level code.
7. There are a lot of built in classes &
methods available in java & remember the
built in classes are always written in
PascalCase Case & Methods are written in
camelCase.
Example
PascalCase =>InputStreamReader
camelCase=>readLine()
8. The java program must be start with class
keyword
9. Initially the name of program must be
same as name of class.
10. for compiling a java program we use
javac command & for ruuning a java program
we use java command.
11. Before executing your program you must
set the path-
Like
set path=C:\Program
Files\Java\jdk1.7.0_04\bin
12. For compiling & running-
javac programname.java
java programname
Datatype
char
number
fixed point
int
long
floating point
float
double
boolean
class test
{
public static void main(String args[])
{
int a,b,c;
a=Integer.parseInt(args[0]);
b=Integer.parseInt(args[1]);
c=a+b;
System.out.println("Sum : "+c);
}
}
javac test.java
java test 10 20
System.out.println("Largest :"+a);
else
System.out.println("Largest :"+c);
}
else
{
if(b>c)
System.out.println("Largest :"+b);
else
System.out.println("Largest :"+c);
}
}
}
switch case statement- It is also a
decision making statement.It works faster
than if statement, but the disadvantages is
that it did not support logical and
relational operator.
Syntax
switch(expression)
{
case value-1:
statement-1;
break;
case value-2:
statement-2;
break;
_____________________
_____________________
case value-n:
statement-n;
break;
default:
default statement
}
Que- read day number and print day name.
Que- Read two values & then print the
following menu-
1. Add
2. Subtract
3. Multiply
4. Divide
then read choice(1-4) & according to choice
perform the operation.