VELMURUGAN C
____________________________________________________
Registration No.
531210112
____________________________________________________
Learning Center
2527
____________________________________________________
Course/Program
BCA
____________________________________________________
Semester
IV Semester
____________________________________________________
Subject Code
BC0047
____________________________________________________
Subject Title
JAVA PROGRAMMING
____________________________________________________
Date of Submission
26.02.2014
____________________________________________________
Marks Awarded
:
____________________________________________________
_________________________________________________
_______________________________________________
Signature of Evaluator
SMU
_________________________________________
Use
Meaning
op1+op2
op1-op2
op1*op2
op1/op2
op1 % op2
Comparison Operators:
Op
Meaning
Example
==
Equal
op1 = = op2
!=
Not Equal
op1 != op2
<
Less than
>
Greater than
<=
>=
Logical Operators:
Op
Use
Return true if
&&
||
op1 || op2
If one is true
!op
Op is false
&
Op1 | op2
Operator Precedence
If more than one operator is used in an expression, JAVA establishes
Operator Precedence to determine the order.
Addition and subtraction has the same priority. When the operators are
having the same priority, they are evaluated from left to right in the order
they appear in the expression.
In general the following order is followed when evaluating an expression.
A
A
A
A
Kind-Of relationship.
Is-A relationship.
Part-Of-relationship.
Has-A relationship.
following
A-Kind-Of Relationship:
We can take the example of a Human Being and an Elephant. Both are
'KIND-OF' mammals. As both are mammals they share the attributes and
behaviours of mammals. Hence Human Being and Elephants are subset
of Mammals class.
The following figure depicts the relationship between the mammals and
Human Being classes:
A Kind-Of
Human
Being
Mammals
Is-A Relationship:
Let us take an instance of the human being class ASHOK, who 'IS-A'
human being and, therefore, a mammal.
The following figure depicts the 'is-A' relationship:
Is-A
Ashok
A Kind-Of
Human Being
Mammals
Is-A
Human
Being
Heart
Part-Of
The possible remedies could be to notify the user of an error. Save the
work environment; allowing exiting from the program without adversely
affecting the other programs in execution.
The class at the top of the exception class hierarchy is called Throwable.
Two classes are derived from the Throwable class- Error and Exception.
The Exception class is used for the exceptional conditions that have to be
trapped in a program. The Error class defines a condition that does not
occur under normal circumstances.
The Error class is used for
catastrophic failures such as VirtualMachineError. These classes are
available in the java.lang package.
Common Exceptions:
Java has several predefined exceptions. The most common exceptions
that you may encounter are described below:
Arithmetic Exception
This exception is thrown when an exceptional arithmetic condition has
occurred. For example, a division by zero generates such an exception.
NullPointer Exception
InputStream
SequenceInputStream
ByteArrayInputStream
FileInputStream
ObjectInputStream
PipedInputStream
FilterInputStream
OutputStream
PushbackInputStream
BufferedInputStream
DataInputStream
ObjectOutputStream
ByteArrayOutputStrea
m
FileOutputStream
PipedOutputStream
FilterOutputStream
BufferedInputStream
DataInputStream
JDK 1.1 introduces the Reader and the Writer classes for Unicode I/O.
These classes support internationalization.
The hierarchy of these classes is given below
Reader
BufferedReader
CharArrayReader
InputStreamReader
StringReader
PipedReader
FilterReader
Writer
BufferedWriter
StringWriter
CharArrayWriter
PipedWriter
PrintWriter
FilterWriter
OutputStreamWriter
statement;
termination
condition;
increment
instruction)
}
System.out.println("Total is " + total);
}
}
OUTPUT : 400
if (year % 100 == 0) {
5
6
7
8
9
10
11
12
13
14
15
16
17
18 }
if (year % 400 == 0) {
System.out.println(year + " is a leap year");
} else {
System.out.println(year + " is not a leap year");
}
} else {
if (year % 4 == 0) {
System.out.println(year + " is a leap year");
} else {
System.out.println(year + " is not a leap year");
}
}
}
Sample Executions :
Input :
year = 800
Output :
800 is a leap year
Input :
year = 700
Output :
700 is not a leap year
Input :
year = 34
Output :
34 is not a leap year
Input :
year = 2013
Output :
2013 is not a leap year