Java Tutorial Questions for Exams
Prepare for semester exams using important questions, numericals, viva questions and unit-wise questions.
The History of Java
Features Of Java
Understand JVM, JDK, and JRE
Setting Up the Java Development Environment (IDE)
Data Types and Variables in Java
if-else statement in Java
Switch-Case statement in Java
While Loop in Java
Do-While Loop in Java
For Loop in Java
While Loop in Java – A Complete Guide
Do-While Loop in Java with examples
for Loop in Java – Mastering Iteration Step-by-Step
Switch-Case statement in Java – A Complete Guide
if-else statement in Java- A Detailed Overview with Example
Adjacency Matrix vs Adjacency List: A Detailed Comparison
Adjacency List Representation in Data Structure
Adjacency Matrix Representation in Data Structure
Big O Notation: The Ultimate Guide with Examples
Data Types and Variables in Java
Can You See java -version in CMD Without Setting Environment Variable?
Setting Up the Java Development Environment (IDE) – A Beginner-Friendly Guide
Understand JVM, JDK, and JRE in Java (For Beginners)
Java Features Explained: A Complete Guide for Beginners
The History of Java – From Oak to Oracle
Unit-wise questions
Unit 1
Open unit →
The History of Java
Questions coming soon.
Unit 2
Open unit →
Features Of Java
Questions coming soon.
Unit 3
Open unit →
Understand JVM, JDK, and JRE
- Loads the .class file (compiled Java code)
- Verifies the bytecode
- Executes the bytecode
- Manages memory, garbage collection, threads, etc.
Unit 4
Open unit →
Setting Up the Java Development Environment (IDE)
- Java Development Kit (JDK) – It contains everything you need to compile and run Java programs.
- Integrated Development Environment (IDE) – A tool that helps you write code more easily (like IntelliJ IDEA, Eclipse, or VS Code).
- Java Runtime Environment (JRE) – It’s part of the JDK and is required to run Java programs.
- Go to the official Oracle JDK download page.
- Select the latest Java SE (Standard Edition).
- Choose the correct version based on your OS: Windows
- macOS
- Linux
Unit 5
Open unit →
Data Types and Variables in Java
- Must start with a letter, _ or $
- Cannot start with a number
- Cannot use Java reserved keywords (e.g., int, class)
- Case-sensitive (Age and age are different)
- Should be meaningful (e.g., use marks not x)
Unit 6
Open unit →
if-else statement in Java
- Write a program to check if a number is positive, negative, or zero.
- Create a grade calculator using if-else-if ladder.
- Check whether a character is vowel or consonant.
- Create a login system where username = “admin” and password = “1234”.
- Write a program to check whether a number is divisible by both 3 and 5.
Unit 7
Open unit →
Switch-Case statement in Java
- Write a program to print the name of the month based on an integer input (1 to 12).
- Create a switch-case program to simulate a simple menu system (1. View, 2. Edit, 3. Delete, 4. Exit).
- Write a switch-case based calculator program (Add, Subtract, Multiply, Divide).
- Create a program using switch-case to check grade remarks (A, B, C, D, F).
Unit 8
Open unit →
While Loop in Java
Questions coming soon.
Unit 9
Open unit →
Do-While Loop in Java
- Brush your teeth (task done once).
- Then check the calendar to see if it’s a working day (condition).
- If yes, repeat (e.g., get ready, pack bag, etc.).
- Write a Java program using do-while to calculate the sum of numbers from 1 to 100.
- Create a simple menu using do-while: Press 1 for Addition
- Press 2 for Subtraction
- Press 3 to Exit
- Use do-while to reverse a number entered by the user.
Unit 10
Open unit →
For Loop in Java
- Printing numbers or patterns
- Repeating an operation with a counter
- Traversing arrays or lists (fixed size)
- Summing a series of numbers
- Write a for loop to print the even numbers between 1 and 20.
- Calculate the factorial of a number using a for loop.
- Print this pattern: 1 1 2 1 2 3 1 2 3 4
- Find the maximum number in an array using a for loop.
Unit 11
Open unit →
While Loop in Java – A Complete Guide
Questions coming soon.
Unit 12
Open unit →
Do-While Loop in Java with examples
- Brush your teeth (task done once).
- Then check the calendar to see if it’s a working day (condition).
- If yes, repeat (e.g., get ready, pack bag, etc.).
- Write a Java program using do-while to calculate the sum of numbers from 1 to 100.
- Create a simple menu using do-while: Press 1 for Addition
- Press 2 for Subtraction
- Press 3 to Exit
- Use do-while to reverse a number entered by the user.
Unit 13
Open unit →
for Loop in Java – Mastering Iteration Step-by-Step
- Printing numbers or patterns
- Repeating an operation with a counter
- Traversing arrays or lists (fixed size)
- Summing a series of numbers
- Write a for loop to print the even numbers between 1 and 20.
- Calculate the factorial of a number using a for loop.
- Print this pattern: 1 1 2 1 2 3 1 2 3 4
- Find the maximum number in an array using a for loop.
Unit 14
Open unit →
Switch-Case statement in Java – A Complete Guide
- Write a program to print the name of the month based on an integer input (1 to 12).
- Create a switch-case program to simulate a simple menu system (1. View, 2. Edit, 3. Delete, 4. Exit).
- Write a switch-case based calculator program (Add, Subtract, Multiply, Divide).
- Create a program using switch-case to check grade remarks (A, B, C, D, F).
Unit 15
Open unit →
if-else statement in Java- A Detailed Overview with Example
- Write a program to check if a number is positive, negative, or zero.
- Create a grade calculator using if-else-if ladder.
- Check whether a character is vowel or consonant.
- Create a login system where username = “admin” and password = “1234”.
- Write a program to check whether a number is divisible by both 3 and 5.
Unit 16
Open unit →
Adjacency Matrix vs Adjacency List: A Detailed Comparison
Questions coming soon.
Unit 17
Open unit →
Adjacency List Representation in Data Structure
Questions coming soon.
Unit 18
Open unit →
Adjacency Matrix Representation in Data Structure
Questions coming soon.
Unit 19
Open unit →
Big O Notation: The Ultimate Guide with Examples
- Count the loops One loop → O(n)
- Nested loops → O(n²)
- Ignore constants O(2n) becomes O(n)
- Keep the highest-order term O(n² + n) becomes O(n²)
- Recursive functions? Use recursion trees or master theorem
Unit 20
Open unit →
Data Types and Variables in Java
- Must start with a letter, _ or $
- Cannot start with a number
- Cannot use Java reserved keywords (e.g., int, class)
- Case-sensitive (Age and age are different)
- Should be meaningful (e.g., use marks not x)
Unit 21
Open unit →
Can You See java -version in CMD Without Setting Environment Variable?
Questions coming soon.
Unit 22
Open unit →
Setting Up the Java Development Environment (IDE) – A Beginner-Friendly Guide
- Java Development Kit (JDK) – It contains everything you need to compile and run Java programs.
- Integrated Development Environment (IDE) – A tool that helps you write code more easily (like IntelliJ IDEA, Eclipse, or VS Code).
- Java Runtime Environment (JRE) – It’s part of the JDK and is required to run Java programs.
- Go to the official Oracle JDK download page.
- Select the latest Java SE (Standard Edition).
- Choose the correct version based on your OS: Windows
- macOS
- Linux
Unit 23
Open unit →
Understand JVM, JDK, and JRE in Java (For Beginners)
- Loads the .class file (compiled Java code)
- Verifies the bytecode
- Executes the bytecode
- Manages memory, garbage collection, threads, etc.
Unit 24
Open unit →
Java Features Explained: A Complete Guide for Beginners
Questions coming soon.
Unit 25
Open unit →
The History of Java – From Oak to Oracle
Questions coming soon.