Ravi Kumar
Suppose, We have class A and class B having same method. class B inheriting from A. class A not defined virtual that method but Class B define override, then what will happen?
By Ravi Kumar in OOP/OOD on Jan 07 2016
  • Ravi Kumar
    Jan, 2016 7

    Program will not compile generate error like; Error: Class B cannot override inherited member 'Class A' because it is not marked virtual, abstract, or override.

    • 8
  • Prakash Tripathi
    Apr, 2016 11

    You can only override the virtual methods.

    • 3
  • Sweta Shetye
    Dec, 2016 4

    It will give a compilation error. Error : 'ClassB.Function()': cannot override inherited member 'ClassA.Function()' because it is not marked virtual, abstract, or override

    • 2
  • Vishal Jadav
    Aug, 2016 8

    Method of class A is hidden now and method of class B is invoked when called.

    • 2
  • Chaitanya Reddy Vonaja
    May, 2016 20

    No Suitable method found to override

    • 2
  • Rahul Sharma
    Oct, 2016 18

    it will give compilation error...

    • 1
  • Nilesh Patel
    Sep, 2016 19

    I think you must be create virtual method in Class A than you will be use override method in derived class with out it Compilation Error is occur.

    • 1
  • Puneet Kankar
    Sep, 2016 10

    Error : cannot override inherited member ,because it is not marked virtual, abstract, or override.

    • 1
  • Hiren Parmar
    Aug, 2016 14

    metod overiding

    • 1
  • Prashant Singh
    Mar, 2016 19

    In C# virtual is just optional...still it ovveride the method present in classB

    • 1
  • Dheeraj Kumar Jha
    Mar, 2016 14

    here throw Exception, bcz, if base class have member method which does not marke as a virtual or abstract so compiler does not allow we go for in derived class a override that member method which is non virtual or non abstract.so if we want override those method then we have must go for that member method mark as a virtual or abstract. keep in mind.

    • 1
  • Mukesh Kumar
    Aug, 2017 29

    an warning is shown

    • 0
  • Mohsin Mukri
    Jul, 2017 6

    will throw the exception "cannot override inherited member bcoz it is not marked as virtual in a parent class

    • 0
  • Dheeraj Kumar Jha
    Mar, 2016 14

    here throw Exception, bcz, if base class have member method which does not make as a virtual or abstract so compiler does not allow we go for in derived class a override that member method which is non virtual or non abstract. keep in mind.

    • 0