Skip to content

Tag Archives: Inheritance

Output of following Java program? class Base {     public void Print() {         System.out.println("Base");     }          }    class Derived extends Base {         public void Print() {… Read More
Output of following program? #include <iostream> #include<string> using namespace std;    class Base { public:     virtual string print() const     {         return "This is Base class";… Read More
Which of the following is true about inheritance in Java? 1) Private methods are final. 2) Protected members are accessible within a package and inherited… Read More
class Base {     public static void show() {        System.out.println("Base::show() called");     } }     class Derived extends Base {     public static void show() {        System.out.println("Derived::show() called");… Read More
class Base {     final public void show() {        System.out.println("Base::show() called");     } }     class Derived extends Base {     public void show() {        System.out.println("Derived::show() called");     }… Read More
Output of following Java Program? class Base {     public void show() {        System.out.println("Base::show() called");     } }     class Derived extends Base {     public void show()… Read More
#include<iostream> using namespace std;    class Base { public:     void fun()          {    cout << "Base::fun() called";     }     void fun(int i)     {   cout << "Base::fun(int i)… Read More
#include<iostream> using namespace std;    class Base { public:     int fun()  { cout << "Base::fun() called"; }     int fun(int i)  { cout << "Base::fun(int i)… Read More
#include<iostream> using namespace std;    class Base { public:     void show()     {         cout<<" In Base ";     } };    class Derived: public Base { public:… Read More
#include<iostream> using namespace std;    class Base {};    class Derived: public Base {};    int main() {     Base *bp = new Derived;     Derived *dp… Read More
Output? #include<iostream> using namespace std;    class Base { private:      int i, j; public:     Base(int _i = 0, int _j = 0): i(_i), j(_j) {… Read More
#include<iostream>     using namespace std; class P { public:    void print()  { cout <<" Inside P"; } };     class Q : public P {… Read More
Assume that an integer takes 4 bytes and there is no alignment in following classes, predict the output. #include<iostream> using namespace std;    class base… Read More
Output? #include <iostream>   using namespace std;    class Base1 {  public:      ~Base1()  { cout << " Base1's destructor" << endl; } };      class Base2… Read More
#include<iostream>     using namespace std; class Base1 {  public:      Base1()      { cout << " Base1's constructor called" << endl;  } };     class Base2 {… Read More