Which lines contain errors?
 
using System; 
namespace Inheritance 
{ 
      class A { } 
      interface Inner { } 
      struct S : A, Inner //1 
      { 
          int num = 10;   //2 
          public S()       //3 
          { 
          } 
          static S()      //4 
          { 
          } 
      } 
      class Program 
     { 
         static void Main(string[] args) 
         {
            S obj = new S(); //5 
         } 
     }
 }
 
Explanation
1 - structures do not support classical inheritance, and A is a class name
2 - fields of structures can not be initialized during the declaration
3 - it's not allowed to declare default constructors

Follow CodeGalaxy

Mobile Beta

Get it on Google Play
Send Feedback
Cosmo
Sign Up Now
or Subscribe for future quizzes