ProgrammingModerateWipro · Capgemini pattern
Which pairing is correct?
- A. Both are resolved at run time
- B. Both are resolved at compile time
- C. Overloading is resolved at compile time; overriding is resolved at run time
- D. Overloading is resolved at run time; overriding is resolved at compile time
Correct answer: C. Overloading is resolved at compile time; overriding is resolved at run time
The compiler picks an overload from the argument types it can see (static polymorphism). Which override runs depends on the actual object at run time (dynamic dispatch).
More OOP with C++ and Java questions
- Which of these operators cannot be overloaded in C++?
- A variable declared inside a Java interface is implicitly:
- What is printed? cpp class A { public: A() { cout << "A"; } ~A() { cout << "a"; } }; class B : public A { public: B() { cout << "B"; }…
- What is printed? java class C { static int n = 0; C() { n++; } } // in main: for (int i = 0; i < 3; i++) new C(); C c = new C()…
- In Java, final applied to a class, a method and a variable means, respectively:
- What is printed? java List<Integer> list = new ArrayList<>(); list.add(1); list.add(2); list.add(1, 5); System.out.print(list);