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 »

Java_Local&Global_Variable

Local Variable - Declared inside a method, constructor, or block {}. - Accessible only within that method or block. - Must be initialized before use. - Lifetim...

Java Inheritance

What is Inheritance? Inheritance is a mechanism where one class gets the states and behaviors of another class. It represents an is‑a relationship, meaning inh...