0% found this document useful (0 votes)
44 views

Advanced Object Oriented Programming (Lab 1) : Download and Install The Java

This document provides instructions for completing several tasks involving basic Java programs. It begins by explaining how to download and install Java, then describes creating a simple "Hello World" program. It also explains some key Java concepts like classes, methods, and System.out.println. Finally, it lists several tasks to write additional programs that output name/details, sum of integers, difference of integers, product of integers, and division of integers.

Uploaded by

Ghulam Ali
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
44 views

Advanced Object Oriented Programming (Lab 1) : Download and Install The Java

This document provides instructions for completing several tasks involving basic Java programs. It begins by explaining how to download and install Java, then describes creating a simple "Hello World" program. It also explains some key Java concepts like classes, methods, and System.out.println. Finally, it lists several tasks to write additional programs that output name/details, sum of integers, difference of integers, product of integers, and division of integers.

Uploaded by

Ghulam Ali
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Advanced Object Oriented Programming (Lab 1)

Download and Install the Java:

1. https://www.oracle.com/java/technologies/javase-jdk16-downloads.html

Windows x64 150.56 MB jdk-16.0.1_windows-x64_bin.exe


Installer

Task 1: Create, compile and run the first java program to print a greeting message on
screen:

1. Open any simple editor like Notepad, Notepad++.


2. Write the following code (to print a simple welcome message on the screen) and save the file
with the name “welcome.java”.

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 

Understanding the first java 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.

You might also like