DEV Community

pranavinu
pranavinu

Posted on

Mock interview-2

1)Tell me about youeself ?
Iam pranavinu, a mechanical engineering grad with a passion for coding and IT. Proficient in Java

2)Why mech to IT ?
Mechanical engineering gave me problem-solving skills. I'm excited about IT's growth and versatility.

3)If mech is your first choice,why IT course ?
Initially into Mech, but IT's growth and opportunities drew me in. Now passionate about coding.

4)Why java ?
Java's versatility, OOP features, and widespread use in industries attracted me.

5)Is java easy ?
Java's syntax is straightforward, but mastering concepts takes time.

6)compiling a program ?
Translating code to bytecode (.class file) for JVM execution.

7)Execution ?
JVM runs the bytecode, performing actions specified in code.

8)Without System.out.println() ?
Yes,programs can run without it (e.g., calculations, file operations).

9)System.out.println() output ?
Prints to console.

10)Control flow statement ?
Directs program flow (if-else, loops, switch).

11.What is switch case ?
Checks value against cases, executes matching block.

12)
public class Test1 {
public static void main(String[] args) {
int x = 2;

    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");
    }
}
Enter fullscreen mode Exit fullscreen mode

}
Output:Two Three Default

13)
nt x = 1;

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

Output:Default One Two

14)
char ch = 65;

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

Output:A (case 'A' matches, 65 is treated as int)

15)
int day = 3;

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

    System.out.println(result);
Enter fullscreen mode Exit fullscreen mode

Output:Wednesday

Top comments (0)