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); } }
- A.
Throws ClassCastException.
- B.
Runtime error.
- C.
Hello will be printed.
- D.
Compilation error.
Attempted by 544 students.
Sign up free to check your answer
Sign up freeLoading lesson…

