Lecture 1
Lecture 1
Lecture 1
Session – 4-5
Branch-Batch-1
Semester-I
Faculty Name-prof. Hemant vyas
Definition OOP stands for Object Oriented POP stands for Procedural Oriented
1 Programing. Programming.
2 Approach OOP follows bottom up approach. POP follows top down approach.
Division A program is divided to objects and their A program is divided into funtions and
3 interactions. they interacts.
Access Access control is supported via access No access modifiers are supported.
5 control modifiers.
Data Hiding Encapsulation is used to hide data. No data hiding present. Data is globally
6 accessible.
Default prototype: Below is the most common way to write main() in Java.
class Test
{
public static void main(String[] args)
{
System.out.println("Main Method");
}
}
Output:
Main Method
Meaning of the main Syntax:
Main Method
Variants of String array arguments: We can place square brackets at different positions and we can use varargs
(…) for string parameter.
Main Method
Main Method
Main Method
{
public static void main(final String[] args)
{
System.out.println("Main Method");
}
}
Output:
Main Method
class Test
{
public final static void main(String[] args)
{
System.out.println("Main Method");
}
}
Output:
Main Method
class Test
{
public synchronized static void main(String[] args)
{
System.out.println("Main Method");
}
}
Output:
Main Method
class Test
{
public strictfp static void main(String[] args)
{
System.out.println("Main Method");
}
}
Output:
Main Method
class Test
{
final static public synchronized strictfp void main(String[] args)
{
System.out.println("Main Method");
}
}
Output:
Main Method
class Test
{
public static void main(String[] args)
{
System.out.println("Main Method String Array");
}
public static void main(int[] args)
{
System.out.println("Main Method int Array");
}
}
Output:
class A
{
public static void main(String[] args)
{
System.out.println("Main Method Parent");
}
}
class B extends A
{
}
Two class files, A.class and B.class are generated by compiler. When we execute any of the two .class, JVM
executes with no error.
O/P: Java A
Main Method Parent
O/P: Java B
Main Method Child