2.1 CHARACTER SET OF
JAVA: - java uses Unicode character set. It occupies 2 byte to store a
character. Unicode can represent 65536 characters. It can recognize character
of most of the language used in the world.
2.2 TOKEN: - Each
individual character used in a Java Statement is known as Token
TYPES OF TOKEN: -
The various type of token available in java is i. Literals ii. Identifier iii.
Keywords. iv puncturators v. operator
2.3 KEYWORD: -
They are the reserve word by the language which conveys special meaning to the
programming language.
Imp- The keyword const
and goto are reserved even though
they are not currently used.
Imp- true and false might appear to be keyword but
they are Boolean literals. null is
not a keyword it is null literals.
2.4 LITERALS(CONSTANTS):-
there are 6 types of literals in java. i. Integer literals ii. Real literals
iii. Character literals iv String Literals v. Boolean literals vi Null
literals.
2.5 INTEGER LITERALS;
- an integer literal are whole numbers have at least one digit and must not
contain and decimal point. It may contain either + or – sigh. Commas cannot
appear in an integer literal.
2.6 FLOATING LITERAL:
- floating literals are number having fractional parts. These may be
written in one of the two forms fractional form or the exponent forms.
2.6.1 FRACTIONAL FORM;
- a real literal in fractional form must have at least one digit before a
decimal point and one digit after decimal point. It may also have either + or –
sigh preceding it.
2.6.2 EXPONANT FORM:
- a real literal in exponent form has two parts; - a mantissa and an
exponent. The mantissa must be either an integer or a proper real number. The
mantissa is followed by a letter E or e and the exponent. The exponent must be
an integer.
2.7 BOOLEAN LITERALS:
- the Boolean type has two values represented by the literal true and false.
2.8 CHARACTER
LITERALS; - A character literals in java must contain one character and
must be enclosed in single quotation marks.
2.9 NON GRAPHIC
CHARACTER;- are those character which can not be directly type from the
keyboard. e.g backspace, tabs, carriage return etc.
2.10 ESCAPE SEQUENCE;
- non graphic character can be represented by using escape sequence. An escape
sequence is represented by a backslash (\) followed by one or more characters.
E.g. \b
backspace, \a alert bell, \n new
line, \t horizontal tab, \\ backslash, \? question mark, \’ single quote,
\” double quote.
2.11 STRING LITERALs
:-is a sequence of zero of more character surrounded by double quotes. Each
character may be represented by and escape sequence.
2.12 VARIBLES: - A variable is a named memory location, which
contains a value. The value of variable can be changed depending upon the
circumstances and problem in the program.
2.15 IDENTIFIERS:
- Identifiers are the name given to different parts of the programs e.g.
function names, variable names, class or object names etc.
2.14 RULES OF NAMING
IDENTIFIERS
An identifier name can be of any length containing alphabet,
digit and underscore. It can not start with a digit. It can not be a keyword.
Identifier name should be meaning full which it easily depicts
the logic.
2.15 DATA TYPE- Data types are means to identify the type of
data and associated operation of handling it.
DATA TYPE IN JAVA:-there are two type of data type. A: -
Primitive type B: - Non –primitive (Reference) type.
2.16 PRIMITIVE DATE TYPE: - The type of
data which are independent of any other type, are known as Primitive data
types. These types are known as fundamental or basic data type. They are
pre-defined or built in data type. E.g. byte, short, int, long, char, float,
double Boolean.
2.17 REFRENCE DATA TYPE;
- they are composed of primitive data type e.g. array, string, class,
interface etc.
2.18 INTEGER TYPE: -
A variable declared integer type contains a whole number.
Data type
|
Size
|
Range
|
Default
|
Byte
|
1 byte
|
-128 to 127
|
0
|
Short
|
2 byte
|
-32768 to 32767
|
0
|
Int
|
4 byte
|
-231 to 231-1
|
0
|
Long
|
8 byte
|
-263 to 263-1
|
0L
|
2.19 FLOATING TYPE:
- a variable to be floating type if we want to store real numbers in it.
Data type
|
Size
|
Range
|
Default
|
Float
|
4 byte
|
3.4 x10-38 to 3.4 x1038
|
0.0F
|
Double
|
8 byte
|
1.7 x 10-308 to 1.7 x 10308
|
0.0
|
Note; - By default java treats fractional numbers as of
double data type.
2.20 CHARACTER TYPE
:- A character type variable contains a single character. It occupies 2
bytes. It can store 65536 characters. It default value is ‘\u0000’.
2.21 BOOLEAN TYPE: -
it is special type in which a variable contains a constant as true of false
these are nonfigurative constant. It occupies 1 byte in memory
2.23 PUNCTUATORS:-are
the punctuation sign used as special character in java. Some punctuators are :
; , etc
2.24 SEPARATORS;-
are special character used in java to separate the character or varibles
e.g ( ),{}, [] etc
2.25. TYPE
CONVERSION(TYPE CASTING) in a mixed expression the result can be obtained
in any one from of its data types. Hence,
it is needed to convert the various data type into the single type. Such
conversion is termed as type casting.
2.25.1 IMPLICT TYPE
CASTING- the data type of the result get converted automatically into its
higher type without intervention of the user. This system of type conversion is
known as implicit type conversion.
2.25.2 EXPLICIT TYPE
CONVERSION:- is another way of type conversion in which the data type gets
converted to another type of depending upon choice. This means the user forces
the system to get back into the desired data type.
e.g. int a,b;
float x=(float) (a+b);
2.26 VARIBLE SCOPE:-
generally refers to the program region with in which a variable is accessible.
2.27 final KEYWORD. This
keyword is used while declaring a variable. These variables are
initialised during the declaration and their values cannot
be modified further in the program. This way keyword final makes the variable
as constants.
Example:- final double pi=3.14;
2.28 OPERATOR;-are
the symbol which tell the computer which operation to take place
Operand: - are the data items on which operation takes
place.
TYPE OF OPERATOR;-
·
Arithmetical Operator
·
Relational Operator
·
Logical Operator
·
Assignment operator
2.29 ARITHMATICAL
OPERATOR: - the operators which are applied to perform arithmetical
calculation in a program are known as arithmetical operator. Some basic calculation
like addition, subtraction, multiplication and division and modulus often
needed during programming.
Type of arithmetical
operator; - unary and binary
Unary operator :-
uses only one operand.
Binary operator
:- uses two operand
Type of unary
operator i.) unary + ii.) unary –
iii) unary increment and unary decrement operator
2.30 INCREMENT/DECREMENT
OPERATOR: - they are used to increment/decrement the value of a integer variable by 1
x++, ++x will increment value of x by 1
x--, --x will decrement value of x by 1
2.30.1 POSTFIX:- evaluates
to the value of the operand after the increment /decrement operation
e.g if x=5
initially then y=x++; will store 5 into y and x will become 6.
if x=5 initially then y=x--; will store 5 into y and x will
become 4.
2.30.2 PREFIX:- evaluates
to the value of the operand before the increment /decrement operation
e.g if x=5
initially then y=++x; will store 6 into y and x will become 6.
if x=5 initially then y=--x; will store 4 into y and x will
become 4.
2.31 RELATIONAL
OPERATOR:- are used to show relationship among the operands. Relational
operators compare the values of the varibles and results in terms of true or
false. Eg:- > ,<, >=,<=,!=,
==
2.32 LOGICAL OPERATOR:-
are used to combine two or more conditions. &&, ||, !
&&(AND) evaluates the condition as true when all
conditions combined with it is true.
||(OR) evaluates the condition as true when any on of the
conditions combined with it is true.
! (NOT ) is used to invert the result of the condition
2.33 TURNARY
OPERATOR;- deal with three operands. It also called condition assignment
statement because the value assigned to a variable depends upon a logical
expression.
Syntax: variable= (test expression) ? expression 1:
expression 2;
Ex. z=(x>y)?x:y;
Here value of z will be x if condition is true otherwise z
will be y.
Ex. Boolean flag=age>18? true:false
Here value of variable flag will be true if age is greater
than 18 otherwise flag will become false.
2.34 OPERATOR
PRECEDENCE: determines the order in which expressions are evaluated. It is
a set of rules that establishes which operators get evaluated first and how
operators with in the same precedence level associate.
2.35 OPERATOR
ASSOCIATIVITY: - rules determine the grouping of operands and operator in
and expression with more than one operator of the same precedence.
2.36 EXPRESSION;
- in java is any valid combination of any valid combination of operators,
constants and variable.
2.36.1 PURE EXPRESSION:
- all the operands are of same data type.
2.36.2 MIXED EXPRESSION:
- the operands are of mixed or different data type.
2.36.3 INTEGER EXPRESSION:
- are formed by connection integer constants or integer variable using integer
arithmetic operator.
2.36.4 REAL
EXPRESSION; - are formed by connection real constants or real variable
using arithmetic operator (except %)
2.37 INSTANCE
VARIBALE: - the variable which are declared inside a class and treated as
data members of the same class called instance variable. Individual copy of
instance variable is created for each object.
2.38 print() and
println():- the print and println
methods send information to standard output because they are part of
System.out.
DIFFERENCE BETWEEN
print() and println():- print(0 displays the given data/information but do
not change line after display where as println() displays the given
data/information and changes line after displaying it.
Name two specific purpose of + operator.
The + operator is used for arithmetic addition and string
concatenation.
e.g.
System.out.print(“Computer “);
System.out.println(“Application”);
System.out.println(“Class X”);
Output:- computer Application
Class X
2.39. DIFFERENCE
BETWEEN OPERATOR AND EXPRESSION. An operator is a symbol that performs a
specific operation on the operands. An operator can be unary operator and
binary operator depending on number of operands it operates upon.
e.g +,-,*,/, % are binary operator.
An expression is formed by the combination of operator of
operators with operands. E.g a+b/2 * c is and arithmetic expression. [2005]
2.40 DIFERENCE
BETWEEN = AND ==:- The ‘=’ (assignment operator) is to assign the value of
the variables, whereas ‘==’ (relational operator) is to compare two values. For
example.
int x=95; //assignment
int y=102; //assignment
if(x==y) //condition
check
2.41 Difference
between unary and binary operator
Unary Operator
|
Binary Operator
|
i. Operators that act on on operand are reffered to as
unary operator.
ii. ++,--, unary + or unary – are unary operator
|
i.
Operator which require two operands for their
functing are calles binary operator.
ii. Arithmatic operator, Relational operator are Binary
operator.
|
2.42 Difference
between Primitive data type and Refrence Data Type.
Primitive Data Type
|
Refrence Data Type
|
i. These are the basic of fundamental data type supported
by java.
ii. The primitive data type variables store the actual
value and their operations deal with rvalue.
iii. example int, char , float, double
iv. use of new operator is not necessary
|
1. These data types are constructed from primitive data
types.
ii.
The reference data type variables store the addresses
or the references of the memory location of the actual data. These deal with
the lvalue.
iii.
Examples:- class, array, refrences.
iv.
Use of new operator is must.
|
2.43 Similarity and
Difference between java character set (Unicode) and ASCII code.
Similarity:- The first 128 characters in the Unicode
character set are same as ASCII character set. i.e. they represent the same
characters.
Difference:-
Unicode
|
ASCII code
|
i.
It is a 2 byte character code set
ii.
It can represent 65536 characters.
|
i.
it is a 1 bypte character code set.
ii.
It can represent only 128 characters.
|
2.44 Difference
between Implicit and Explicit type conversion.
Implicit type conversion
|
Explicit type conversion
|
1.
This type of conversion is performaed by compiler
user intervension not required.
2.
No keyword is requied to perform this conversion.
int x=12;
double d=x;
|
1.
This type of conversion is forces by the user.
Ex. double x=12.5;
int i=(int)x;
|
2.45 Difference
between rvalue and lvalue.
rvalue is called real value. It referes to data item stored
in the variable. Rvalues is calles location value it refers to the memory
address where variable is allocated.
important point
1. Differentiate between operator and
expression. [2005]
an operator is a symbol which specifies that
which operation to take place on operand. where as expression is formed using
valid combination of operator and operand.
e.g
+,-,++,--,>,< are operator where is x=y+z is an expression
2. if m=5 and n=2 output the values of m and n
after exceution in (i) and (ii) : [2005]
i)m-=n
(ii)
m=m+m/n
if
m=5 and n=2 then
(i)
m-=n -> m=m-n -> m=5-2=3
(ii)
m=m+m/n -> 5+5/2=7
3.)
What is a compound statement? Give an Example. [2005]
Compound
statement is a set of two of more programming statements. it is also called a
block.
A compound statement is seen in an if- construct, while loop, do while loop, for loop and switch
A compound statement is seen in an if- construct, while loop, do while loop, for loop and switch
construct.
e.g.
if(x>y)
{
t=x;
x=y;
y=x;
}
e.g.
int num[]={1,2,3,4,5};
4. what will be the output of the following. if
x=5 initially? [2005]
(i)
5*++x
(ii)
5*x++
(i)5*6=30
(ii)5*5=25
5.
What is the output of the following?
[2005]
char
='A';
short
m=26;
int
n=c+n;
System.out.println(n)
ASCII
code of A is 65 so
n=65+26=91
6. What is the
purpose of the new operator? [2006]
new:- The new operator is used to create an object of a class and
associate the object with a variable that names it.
Question 2
7.State the two kinds
of data types. [2006]
Two kinds of data types are i.
Primitive data type e.g. int, char, float.
ii. Refrence data type e.g. object
and array s.
i.
8.
9.What will be the
output for the following program segment? [2006]
int a=0,b=30,c=40;
a= --b + c++ +b ;
System.out.println(a);
Output :- a=98
//Write a
program to input a time in seconds and
convert it into hrs, minutes and seconds.
import java.util.*;
class convert
{
public
static void main(String args[]) Throws Exception
{
Scanner Sn=new Scanner(System.in));
int hr,min,sec, s;
System.out.println(“enter time in seconds”);
s=Sn.nextInt();
hr=s/3600;
s=s%3600;
min=s/60;
sec=s%60;
System.out.println(hr+” Hrs “+min+” minutes “+sec+” seconds”);
}
}
Specify output of
given if a=5 and b=3 initially
C=++a+ --b + ++a +--b
System.out.println(a+”
“+b+” “+c);
Output:- 7 1 16
Specify output of
given if a=5 and b=3 initially
C=a++ + --b + a++ +
--b
System.out.println(a+”
“+b+” “+c);
Output:- 7 1 14
No comments:
Post a Comment