gs gs108 Indexers and Exception Handling - Properties and its Applications - 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 Indexers and Exception Handling. 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 math { int ad; public int add { get { return ad; } } }
class math { public int add { get { return ad; } } }
class math { int ad; public int add { get { return ad; } set { ad = value; } } }
class math { public int add { set { add = value; } } }
class math { int ad; public int add { set { ad = value; } } }
class math { int ad; public int add { get { return ad; } set { ad = value; } } }
class number { private int num1; private int num2; public int anumber { get { return num1; } set { num1 = value; } } public int anumber1 { get { return num2; } set { num2 = value; } } } class Program { public static void Main(string[] args) { number p = new number(); p.anumber = 20; number k = new number(); k.anumber1 = 40; int m = p.anumber; int t = k.anumber1; int r = p.anumber + k.anumber1; System.Console.WriteLine("number1 = " +m); System.Console.WriteLine("number2 = " +t); System.Console.WriteLine("sum = " +r); System.Console.ReadLine(); } }
number1 = 30 number2 = 40 sum = 70
number1 = 20 number2 = 40 sum = 60
class student { int []scores = new int[5] {23, 42, 54, 11, 65}; public int this[int index] { get { if (index < 5) return scores[index]; else { Console.WriteLine("invalid index"); return 0; } } set { if (index < 5) scores[index] = value; else Console.WriteLine("invalid index"); } } }
class student { int []scores = new int[5] {23, 42, 54, 11, 65}; public int this[int index] { get { if (index < 5) return scores[index]; } } }
class student { int []scores = new int[5]{23, 42, 54, 11, 65}; public int this[int index] { set { if (index < 5) return scores[index]; else { Console.WriteLine("invalid index"); return 0; } } } }
class student { int []scores = new int[3] {13, 32, 24}; public int this[int index] { get { if (index < 3) return scores[index]; else { Console.WriteLine("invalid index"); return 0; } } private set { if (index < 3) scores[index] = value; else Console.WriteLine("invalid index"); } } } class Program { public static void Main(string[] args) { student s = new student(); int[] scores1 = new int[3] {8, 19, 40}; for (int i = 0; i < 3; i++) { if (scores1[i] > s[i]) { Console.WriteLine(" scores1 had greater value :" + scores1[i]); } else { Console.WriteLine("scores had greater value :" + s[i]); } } Console.ReadLine(); } }
scores had greater value : 13 scores had greater value : 32 scores1 had greater value : 40