gs gs108 Object Oriented Concepts - Inheritance Implementation - Quiz No.1
gs gs108 CSharp Quiz
This quiz belongs to book/course code gs gs108 CSharp of gs organization. We have 110 quizzes available related to the book/course CSharp. This quiz has a total of 10 multiple choice questions (MCQs) to prepare and belongs to topic Object Oriented Concepts. NVAEducation wants its users to help them learn in an easy way. For that purpose, you are free to prepare online MCQs and quizzes.
NVAEducation also facilitates users to contribute in online competitions with other students to make a challenging situation to learn in a creative way. You can create one to one, and group competition on an topic of a book/course code. Also on NVAEducation you can get certifications by passing the online quiz test.
class sample { protected int index; public sample() { index = 0; } } class sample 1: sample { public void add() { index += 1; } } class Program { static void Main(string[] args) { sample 1 z = new sample 1(); z . add(); } }
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(); } }
10, 20, 30 base method
class baseclass { private int a; protected int b; public int c; } class derived : baseclass { private int x; protected int y; public int z; } class Program { static Void Main(string[] args) { derived a = new derived(); } }
class sample { public sample() { Console.WriteLine("THIS IS BASE CLASS constructor"); } } public class sample1 : sample { } class Program { static void Main(string[] args) { sample1 obj = new sample1(); Console.ReadLine(); } }
class baseclass { protected int a = 20; } class derived : baseclass { int a = 10; public void math() { /* add code here */ } }
class baseclass { int a; public baseclass(int a1) { a = a1; console.writeline(" a "); } class derivedclass : baseclass { public derivedclass (int a1) : base(a1) { console.writeline(" b "); } } class program { static void main(string[] args) { derivedclass d = new derivedclass(20); } } }
b a
a b