java first class (2) (1)
java first class (2) (1)
program-set of instruction
coading-cummunicate
java is a high level language with support oops .java is case sensitive.
history:
popular programming language
gree team
james goslimg
mike sheritan
patrick naughton
founder:james gosling
year:1991-implement
publish:1995
1990-sun micro system decided for aspecial software consumer eletronic devices
1991-named as language as oak
1992-deal with touch sensitive screens
1993-support with web application
1994-web browser
1995-oak renamed as java
1996-java establised as-leader of internet programming
-general purpose programming language
application:
desktop application
mobile application
web application
web server and application servers
games
database connections
banking applicatins
features of java:
simple
compiled and interpreted
portable
object oriented
secure
high performance
dynamic
platform dependent:-
Any application which are developed in one platform able to run a similar platform
only such application is called as platform dependent.
MAC--os update---x
WIN32--HLPL--COMPILER--LLPL--WIN 32--os ----
LINUX--system based
operating system--x
platform independent
Any application which are developed in one platform capale of running different
multiple platform are known as platform independent application
MAC--os update
WIN32--HLPL--COMPILER--LLPL--WIN 32--os
LINUX--system based
operating system
Any application which are developed using java language are platform indepent
application because they undergo 2 stage of convertion
in 1 st stage the compiler will convert source file into class file (or)compiler
will convert java language to byte code.
in 2 nd stage the jvm converts byte code into binary and excutes this program
hence java application can be used as any platform with the help of jvm.
JDK
JRE JVM
system.out.println();
it is used to print whatever the data given and move the cursor to initial postion
to next line.
system.out.print();
it is used to print whatever the data given and move the cursor to immediate next
position in the same line
comment:
single line comment-\\
multi line comment-\* *\
tokens:-
The smallest elements of any programs is called as tokens.
In java we have following tokens:-
1)keyword
2)identifier
3)literal
4)separated
identifier:-
the name given to the members of java is known as identifier
ex:-name given to class ,method and variables.
rules:-
literals:-
the data are the user input
in java we have following literals
1.numbers
2.characters
3.string
4.boolean
note:- Any Character are data that we passed inside single code is considered as
character but the length of the character must be 1 else we get compile time error
whenever we pass character 1 unique code will be considered to be stored the data
in the memory known as ASCII(American Standard Code for Information Interchange)
'A'==>65 'Z'==>90
'a'==>97 'z'==>122
'0'==>48 '9'==>57
string:-
string is the group of character
string are represented using double quotes
ex:-system.out.println("cad point);//cadpoint
boolean:-
in java boolean literls are also keywords
they are:
true
false
we can passed directly
ex:-
system.out.println(true);//true
system.out.println(false);//false
Separators:-
separators are used to separate one instruction from another instruction
ex:-()," ",;,{}
note:-in java every instruction must end with block (or)semicolan
Type casting:-
converting one data type into another data type is known as typecasting
in java we have classified into two types
*primitive typecasting
*non primitive typecasting
primitivetypecasting:-
converting one primitive datatype into another primitive datatype is known as
primitive typecasting.
primitive type casting consist of two process
widening
narrowing
widening process:-
the process of converting smaller range data type into larger data type is known as
widening process.
There is no loss in Widening process it will be done compiler implecitly .
Hence it is also called as auto widening .
Narrowing process:-
The process of conveting larger range data type into smaller range data type is
known as Narrowing process.
There might be data loss in narrowing compiler will not do it implicitly so
programer asked to explicitly by using type caste operator .
Example :-
int a=(int)10.5;
int b=(int)10L;
1 2 4 8 4 8
byte -> short ->int->long->float->double
Operator :-
` A pre define symbol used for particular task is known as Operator .Input or
data that we passed to an Operator are known as operands.
1.Arithmetic Operator.(Binary)(+,-,*,/,%)
2.Relational Operator.(Binary)
3.Logical Operator.
4.Conditional Operator.(Ternary Operator)
5.Bitwise Operator.
6.Unary Operator.(Increment,Decrement).
7.Assignment Operator.
System.out.println((mark>=35)?"pass":"fail");
}
}
Assignment Operator.
public class Main
{
public static void main(String [] args)
{
int a=10;
a+=10;
System.out.println(a);
a-=5;
System.out.println(a);
a*=2;
System.out.println(a);
a/=3;
System.out.println(a);
}