Mock interview-2

Published: (February 8, 2026 at 09:47 PM EST)
1 min read
Source: Dev.to

Source: Dev.to

Interview Questions

  1. Tell me about yourself?
  2. Why move from Mechanical Engineering to IT?
  3. If Mechanical Engineering was your first choice, why choose an IT course now?
  4. Why Java?
  5. Is Java easy?
  6. What does compiling a program involve?
  7. What happens during execution?
  8. How can you produce output without using System.out.println()?
  9. What does System.out.println() output?
  10. What are control‑flow statements?
  11. What is a switch case?

Example 1

switch (x) {
    case 1:
        System.out.print("One ");
    case 2:
        System.out.print("Two ");
    case 3:
        System.out.print("Three ");
    default:
        System.out.print("Default");
}

Output: Two Three Default

Example 2

switch (x) {
    default:
        System.out.print("Default ");
    case 1:
        System.out.print("One ");
    case 2:
        System.out.print("Two ");
}

Output: Default One Two

Example 3

switch (ch) {
    case 'A':
        System.out.println("A");
        break;
    case 65:
        System.out.println("Sixty Five");
}

Output: A
(The 'A' case matches; 65 is treated as an int.)

Example 4 (switch expression)

String result = switch (day) {
    case 1 -> "Monday";
    case 2 -> "Tuesday";
    case 3 -> "Wednesday";
    default -> "Invalid";
};

System.out.println(result);

Output: Wednesday

0 views
Back to Blog

Related posts

Read more »

Switch case

Overview - A switch case is a control statement that lets you run different blocks of code based on the value of a variable or expression. - It is often cleane...

Switch Case

What is a switch statement? The switch keyword in Java is used to execute one block of code among many alternatives. The expression is evaluated once and compa...