Q1easy
What will happen if a class does not define a constructor?
Topic-wise practice questions for Programming (C++ / Java / Python). Test your knowledge, check solutions on demand, and pace your preparation.
class Parent {
void show() { print("Parent"); }
}
class Child extends Parent {
void show() { print("Child"); }
}
Parent obj = new Child();
obj.show();
class Counter {
static int count = 0;
Counter() { count++; }
}
Counter c1 = new Counter();
Counter c2 = new Counter();
Counter c3 = new Counter();
print(Counter.count);