The following C# code is run on single level of inheritance. What will be the Correct statement in the following C# code? [code] class

Nam Phong

New member
The following C# code is run on single level of inheritance. What will be the Correct statement in the following C# code?
Code:
 class sample
 {
     int i = 10;
     int j = 20;
     public void display() 
     {
         Console.WriteLine("base method ");
     }
 }    
 class sample1 : sample 
 {
     public  int s = 30;
 }    
 class Program
 {
     static void Main(string[] args)
     {
         sample1 obj = new sample1();
         Console.WriteLine("{0}, {1}, {2}", obj.i,  obj.j,  obj.s);
         obj.display();
         Console.ReadLine();
     }
 }
A.
10, 20, 30
base method
B. 10, 20, 0
C. compile time error
D. base method
 

Tìm kiếm

Back
Top