Subject question bank

Java Tutorial Questions for Exams

Prepare for semester exams using important questions, numericals, viva questions and unit-wise questions.

U

Unit-wise questions

Unit 1

The History of Java

Open unit →
  1. Questions coming soon.

Unit 2

Features Of Java

Open unit →
  1. Questions coming soon.

Unit 3

Understand JVM, JDK, and JRE

Open unit →
  1. Loads the .class file (compiled Java code)
  2. Verifies the bytecode
  3. Executes the bytecode
  4. Manages memory, garbage collection, threads, etc.
Unit 4

Setting Up the Java Development Environment (IDE)

Open unit →
  1. Java Development Kit (JDK) – It contains everything you need to compile and run Java programs.
  2. Integrated Development Environment (IDE) – A tool that helps you write code more easily (like IntelliJ IDEA, Eclipse, or VS Code).
  3. Java Runtime Environment (JRE) – It’s part of the JDK and is required to run Java programs.
  4. Go to the official Oracle JDK download page.
  5. Select the latest Java SE (Standard Edition).
  6. Choose the correct version based on your OS: Windows
  7. macOS
  8. Linux
Unit 5

Data Types and Variables in Java

Open unit →
  1. Must start with a letter, _ or $
  2. Cannot start with a number
  3. Cannot use Java reserved keywords (e.g., int, class)
  4. Case-sensitive (Age and age are different)
  5. Should be meaningful (e.g., use marks not x)
Unit 6

if-else statement in Java

Open unit →
  1. Write a program to check if a number is positive, negative, or zero.
  2. Create a grade calculator using if-else-if ladder.
  3. Check whether a character is vowel or consonant.
  4. Create a login system where username = “admin” and password = “1234”.
  5. Write a program to check whether a number is divisible by both 3 and 5.
Unit 7

Switch-Case statement in Java

Open unit →
  1. Write a program to print the name of the month based on an integer input (1 to 12).
  2. Create a switch-case program to simulate a simple menu system (1. View, 2. Edit, 3. Delete, 4. Exit).
  3. Write a switch-case based calculator program (Add, Subtract, Multiply, Divide).
  4. Create a program using switch-case to check grade remarks (A, B, C, D, F).
Unit 8

While Loop in Java

Open unit →
  1. Questions coming soon.

Unit 9

Do-While Loop in Java

Open unit →
  1. Brush your teeth (task done once).
  2. Then check the calendar to see if it’s a working day (condition).
  3. If yes, repeat (e.g., get ready, pack bag, etc.).
  4. Write a Java program using do-while to calculate the sum of numbers from 1 to 100.
  5. Create a simple menu using do-while: Press 1 for Addition
  6. Press 2 for Subtraction
  7. Press 3 to Exit
  8. Use do-while to reverse a number entered by the user.
Unit 10

For Loop in Java

Open unit →
  1. Printing numbers or patterns
  2. Repeating an operation with a counter
  3. Traversing arrays or lists (fixed size)
  4. Summing a series of numbers
  5. Write a for loop to print the even numbers between 1 and 20.
  6. Calculate the factorial of a number using a for loop.
  7. Print this pattern: 1 1 2 1 2 3 1 2 3 4
  8. Find the maximum number in an array using a for loop.
Unit 11

While Loop in Java – A Complete Guide

Open unit →
  1. Questions coming soon.

Unit 12

Do-While Loop in Java with examples

Open unit →
  1. Brush your teeth (task done once).
  2. Then check the calendar to see if it’s a working day (condition).
  3. If yes, repeat (e.g., get ready, pack bag, etc.).
  4. Write a Java program using do-while to calculate the sum of numbers from 1 to 100.
  5. Create a simple menu using do-while: Press 1 for Addition
  6. Press 2 for Subtraction
  7. Press 3 to Exit
  8. Use do-while to reverse a number entered by the user.
Unit 13

for Loop in Java – Mastering Iteration Step-by-Step

Open unit →
  1. Printing numbers or patterns
  2. Repeating an operation with a counter
  3. Traversing arrays or lists (fixed size)
  4. Summing a series of numbers
  5. Write a for loop to print the even numbers between 1 and 20.
  6. Calculate the factorial of a number using a for loop.
  7. Print this pattern: 1 1 2 1 2 3 1 2 3 4
  8. Find the maximum number in an array using a for loop.
Unit 14

Switch-Case statement in Java – A Complete Guide

Open unit →
  1. Write a program to print the name of the month based on an integer input (1 to 12).
  2. Create a switch-case program to simulate a simple menu system (1. View, 2. Edit, 3. Delete, 4. Exit).
  3. Write a switch-case based calculator program (Add, Subtract, Multiply, Divide).
  4. Create a program using switch-case to check grade remarks (A, B, C, D, F).
Unit 15

if-else statement in Java- A Detailed Overview with Example

Open unit →
  1. Write a program to check if a number is positive, negative, or zero.
  2. Create a grade calculator using if-else-if ladder.
  3. Check whether a character is vowel or consonant.
  4. Create a login system where username = “admin” and password = “1234”.
  5. Write a program to check whether a number is divisible by both 3 and 5.
Unit 16

Adjacency Matrix vs Adjacency List: A Detailed Comparison

Open unit →
  1. Questions coming soon.

Unit 17

Adjacency List Representation in Data Structure

Open unit →
  1. Questions coming soon.

Unit 18

Adjacency Matrix Representation in Data Structure

Open unit →
  1. Questions coming soon.

Unit 19

Big O Notation: The Ultimate Guide with Examples

Open unit →
  1. Count the loops One loop → O(n)
  2. Nested loops → O(n²)
  3. Ignore constants O(2n) becomes O(n)
  4. Keep the highest-order term O(n² + n) becomes O(n²)
  5. Recursive functions? Use recursion trees or master theorem
Unit 20

Data Types and Variables in Java

Open unit →
  1. Must start with a letter, _ or $
  2. Cannot start with a number
  3. Cannot use Java reserved keywords (e.g., int, class)
  4. Case-sensitive (Age and age are different)
  5. Should be meaningful (e.g., use marks not x)
Unit 21

Can You See java -version in CMD Without Setting Environment Variable?

Open unit →
  1. Questions coming soon.

Unit 22

Setting Up the Java Development Environment (IDE) – A Beginner-Friendly Guide

Open unit →
  1. Java Development Kit (JDK) – It contains everything you need to compile and run Java programs.
  2. Integrated Development Environment (IDE) – A tool that helps you write code more easily (like IntelliJ IDEA, Eclipse, or VS Code).
  3. Java Runtime Environment (JRE) – It’s part of the JDK and is required to run Java programs.
  4. Go to the official Oracle JDK download page.
  5. Select the latest Java SE (Standard Edition).
  6. Choose the correct version based on your OS: Windows
  7. macOS
  8. Linux
Unit 23

Understand JVM, JDK, and JRE in Java (For Beginners)

Open unit →
  1. Loads the .class file (compiled Java code)
  2. Verifies the bytecode
  3. Executes the bytecode
  4. Manages memory, garbage collection, threads, etc.
Unit 24

Java Features Explained: A Complete Guide for Beginners

Open unit →
  1. Questions coming soon.

Unit 25

The History of Java – From Oak to Oracle

Open unit →
  1. Questions coming soon.