Engineering Full Stack Apps with Java and JavaScript
What will the following code print when compiled and run:
class Data { int intVal = 0; String strVal = "default"; public Data(int k){ this.intVal = k; } } public class TestClass { public static void main(String[] args) throws Exception { Data d1 = new Data(10); d1.strVal = "D1"; Data d2 = d1; d2.intVal = 20; System.out.println("d2 val = "+d2.strVal); } }
Select 1 option
A. d2 val =
B. d2 val = default
C. d2 val = D1
D. Exception at run time.