Given the following code, what will be the result? public class Test { public…

PYQ DSSSB 2025

Given the following code, what will be the result? public class Test { public static void main(String[] args) { Object obj = new String("Hello"); String str = (String) obj; System.out.println(str); } }

  1. A.

    Throws ClassCastException.

  2. B.

    Runtime error.

  3. C.

    Hello will be printed.

  4. D.

    Compilation error.

Attempted by 544 students.

Sign up free to check your answer

Sign up free

Explore the full course: Dsssb Tgt Computer Science Paper 2

Loading lesson…