Java Programming-Unit1
Java Programming-Unit1
IVth SEMESTER
CIC-212
1. Simple
2. Object Oriented
3. Robust
4. Platform Independent
5. Secure
6. Multi-threading
7. Portable
8. High Performance
1. Primitive Variable – Can be used to represent primitive values, for eg: int x
= 10;
2. Reference Variable – Used to Refer Objects, for eg: Student s = new
Student();
Based on the purpose and position of declaration all variables are divided into
3 types:
1. Instance Variable
2. Static Variable
3. Local Variables
1. Value of the variable is varied from object to object and for every object
separate copy of instance variable is created.
2. Scope is exactly same as the scope of the objects.
3. Cannot be accessed from static area directly, we need to access by using
object reference.
Command
Line
Arguments
Starting
Point of
the Code
To call by JVM JVM calls this Main method can’t
from method without return anything to
anywhere any existing object JVM
Department of COMPUTER SCIENCE & ENGINEERING, BVCOE New Delhi
First Hello World Program
Method present to
output Values on
Class Name Static variable of type
Console
Present in PrintStream present in
java.lang system class
Department of COMPUTER SCIENCE & ENGINEERING, BVCOE New Delhi
Passing Command Line Argument
Increment Operator
1. Pre Increment – int x=++y, Post Increment – int x =y++;
Decrement Operator
1. Pre Decrement – int x = --y, Post Decrement – int x = y--;
Example Showing Use of Increment and Decrement Operator
1. Use continue statement to skip current iteration and continue for next
iteration inside loops.
L2p5.java
Example – App.java
Example
Example
Department of COMPUTER SCIENCE & ENGINEERING, BVCOE New Delhi
Inheritance in Java
When the keyword abstract appears in a class definition, it means that zero or
more of its methods are abstract.
1. An abstract method has no body
2. Some of the subclass has to override it and provide the implementation
3. Objects cannot be created out of abstract class.
4. Abstract classes basically provide a guideline for the properties and
methods of an object.
5. In order to use abstract classes, they have to be subclassed.
6. There are situations in which you want to define a superclass that declares
the structure of a given abstraction without providing a complete
implementation of every method.