Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
13 views

java first class (2) (1)

Uploaded by

parveenbegam377
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views

java first class (2) (1)

Uploaded by

parveenbegam377
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 5

introduction of java:

program-set of instruction
coading-cummunicate
java is a high level language with support oops .java is case sensitive.

3 types of programming language:


low level programming language
mechine level programming language
high level proramming language-c++,java,python,.net

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

how java is platform independent:-

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.

note:java is platform independent language for depends on jvm

step to create an excute java program

1.create source file


2.genrate class file
3.execution of program

JDK
JRE JVM

it is java development kit java runtime envirnment


java virtual machine

it provides tools for devloping it provides neccessary tools


converts byte code into binary code and excutes the
and excuting java program required excute the program
program
2

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

java first program:

public class programname


{
public static void main(string args[])
{
system.out.println("cadpoint");
}
}

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

keywords:-predefined words ex:-public static void


50 keywords
int,float,char,double,break,case,static,strig,public,.......
reserved words
note:-keyword must be return in lower case

identifier:-
the name given to the members of java is known as identifier
ex:-name given to class ,method and variables.
rules:-

idendifier should not start with numeric value


ex:-123demo//cte
demo123//cts
special charcters are not allowed other than _and $
ex:-@demo//cte
$_demo//cts
space b/w the charcters are not allowed
ex:-My home//cte
MyHome//cts
keywords cannot be used as identifier

literals:-
the data are the user input
in java we have following literals
1.numbers
2.characters
3.string
4.boolean

number:-In java numeric values can be used directly


ex:-system.out.println(10);//10
system.out.println(10.5);//10.5
character:-
In java characters are represented using single code
*'a'to'z'
*'0'to'9'
*'A'to 'Z'
*special characters
ex:-
system.out.pritln('a');//a
system.out.pritln('4');//4
system.out.pritln('$');//$

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 .

Type Caste Operator:-


It is a unary operator
It is used to convert higher range data type into smaller range data type.
Syntax:-
datatype Identifier =(LHS Data type) value/Expression .

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.

Conditional Operator.(Ternary Operator)


public class Main
{
public static void main(String [] args)
{
int mark=35;

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);
}

You might also like