You are not logged in.

#1 2015-06-12 06:34:43

husnain
User RankUser RankUser RankUser RankUser RankUser Rank
Administrator
From: Chichawatni,Pakistan
Registered: 2014-10-03
Posts: 8,129
Website

Class Value:

Java Quizzes Java Language Overriding And Overloading

Directions:
class A{
      int i = 10;
      public void printValue(){
            System.out.print("Value-A");
      }
}

class B extends A{
      int i = 12;
      public void printValue(){
            System.out.print("Value-B");
      }
}

public class Test{
      public static void main(String args[]){
            A a = new B();
            a.printValue();
            System.out.print(a.i);
      }
}

Question:
What will be the output?

Option A):
Value-B 10
Option B):
Value-B 13
Option C):
Value-B 11
Option D):
Value-B 12

Correct Answer is Option A):
Value-B 10


You cannot discover the new oceans unless you have the courage to lose the sight of the shore.

2015-06-12 06:34:43

Advertisement
Ads By Google

Re: Class Value:



\n

Board footer