gs gs108 Object Oriented Concepts - Polymorphism - 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.
public class sample { public static int x = 100; public static int y = 150; } public class newspaper :sample { new public static int x = 1000; static void Main(string[] args) { console.writeline(sample.x + " " + sample.y + " " + x); } }
public class maths { public int x; public virtual void a() { } } public class subject : maths { new public void a() { } }
class base { public void f1() {} public virtual void f2() {} public virtual void f3() {} } class derived :base { new public void f1() {} public override void f2() {} public new void f3() {} } class Program { static void Main(string[] args) { baseclass b = new derived(); b.f1 (); b.f2 (); b.f3 (); } }
f1() of derived class get executed f2() of derived class get executed f3() of base class get executed
f1() of base class get executed f2() of derived class get executed f3() of base class get executed
f1() of base class get executed f2() of derived class get executed f3() of derived class get executed
f1() of derived class get executed f2() of base class get executed f3() of base class get executed
class csharp { int x, y, z; public csharp() { } public csharp(int a ,int b ,int c) { x = a; y = b; z = c; } Add correct set of code here public void display() { console.writeline(x + " " + y + " " + z); } class program { static void Main(String[] args) { csharp s1 = new csharp(5 ,6 ,8); csharp s3 = new csharp(); s3 = - s1; s3.display(); } } }
public static csharp operator -(csharp s1) { csharp t = new csharp(); t.x = s1.x; t.y = s1.y; t.z = -s1.z; return t; }
public static csharp operator -(csharp s1) { csharp t = new csharp(); t.x = s1.x; t.y = s1.y; t.z = s1.z; return t; }
public static csharp operator -(csharp s1) { csharp t = new csharp(); t.x = -s1.x; t.y = -s1.y; t.z = -s1.z; return t; }