Advanced Object Oriented Programming (Lab 1) : Download and Install The Java
Advanced Object Oriented Programming (Lab 1) : Download and Install The Java
1. https://www.oracle.com/java/technologies/javase-jdk16-downloads.html
Task 1: Create, compile and run the first java program to print a greeting message on
screen:
3. Open command prompt to compile and run the program using following commands:
a. Press Windows+R key cmd (press enter key)
b. Go to the bin directory inside java (cd C:\Program Files\Java\jdk-16.0.1\bin)
c. You may need to set path to java’s bin directory for example by writing (set
path=C:/Program Files/Java/jdk-16.0.1/bin)
d. Type (javac welcome.java) to compile the program
e. Type (java welcome) to run the program
Let's see what is the meaning of class, public, static, void, main, String[],
System.out.println().
class keyword is used to declare a class in java.
public keyword is an access modifier which represents visibility. It means it is visible to
all.
static is a keyword. If we declare any method as static, it is known as the static method.
The core advantage of the static method is that there is no need to create an object to
invoke the static method. The main method is executed by the JVM, so it doesn't require
to create an object to invoke the main method. So it saves memory.
void is the return type of the method. It means it doesn't return any value.
main represents the starting point of the program.
String[] args is used for command line argument. We will learn it later.
System.out.println() is used to print statement. Here, System is a class, out is the object
of PrintStream class, println() is the method of PrintStream class. We will learn about
the internal working of System.out.println statement later.
Task 2: Write a java program to display your name, roll number, class and department
on the screen.
Task 3: Write a java program to create 2 integers and display their sum on the screen.
Task 4: Write a java program to create 2 integers and display their difference on the
screen.
Task 5: Write a java program to create 2 integers and display their product on the
screen.
Task 6: Write a java program to create 2 integers and display their division on the
screen.