Java Lab 1 – Introduction & Basics
Objective: Understand Java structure, output, variables, and input.
Quick Recap (Cheat Sheet) Interactive Activities (Tasks)
class Main {
public static void main(String[] args) {
1. Hello World
[Link]("Hello, Java!"); Write and run your first Java program using the
} structure above. Ensure it compiles and prints
} exactly: Hello, Java!
2. Introduce Yourself
Print your name, roll number, and one hobby on
separate lines. Example output: Mirhazar Khan
Chandio\nR-123\nPhotography
Predict & Run (Puzzle)
[Link](5 + 3 * 2); 3. Math
// What will this in Java(Remember operator precedence)
print?
Declare two integers, compute their sum, and print
the result with a message: "Sum = <value>".
int a = 7; int b = 3; [Link]("Sum = " +
Notes / Output
MK Tech – Java Lab Handout • Single-page, print-ready (A4)