1. Trang chủ
  2. » Giáo Dục - Đào Tạo

Session4 module8 9 abstractclasses interface properties indexers

5 28 0

Đang tải... (xem toàn văn)

THÔNG TIN TÀI LIỆU

Cấu trúc

  • Answers

Nội dung

ACCP I10 SEMESTER PCS – PROGRAMMING IN C# MODULAR QUIZ FOR Session 04 Which of these statements about abstract classes and abstract methods are true? A An abstract class can be declared using the declare keyword B An abstract class cannot be instantiated using the new keyword C An abstract class be created by declaring and defining methods D An abstract method can be declared without an access modifier Which of these statements about interfaces are false? A An interface can contain abstract as well as implemented methods B An inheriting class can override the implemented methods of an interface C A class can implement abstract methods from multiple interfaces D An interface can implement multiple interfaces but only a single abstract class You are trying to inherit the abstract class Vehicle and implement its methods in the subclass Ferrari Which of the following codes will help you to achieve this? A class Vehicle{ public void Wheels(){ Console.WriteLine("Every Car has four wheels"); } public abstract void Speed(); } C class Vehicle{ public void Wheels(){ Console.WriteLine("Every Car has four wheels"); } public abstract void Speed(); } class Ferrari : Vehicle { public void Speed(){ Console.WriteLine("The Speed of Ferrari exceeds 200 mph"); class Ferrari extends Vehicle { public override void Speed(){ Console.WriteLine("The Speed of Ferrari exceeds 200 mph"); } } static void Main(){ Ferrari objCar = new Ferrari(); objCar.Speed(); } static void Main(){ Ferrari objCar = new Ferrari(); objCar.Speed(); } } } B abstract class Vehicle{ public void Wheels(){ Console.WriteLine("Every Car has four wheels"); } public abstract void Speed(); } D abstract class Vehicle{ public void Wheels(){ Console.WriteLine("Every Car has four wheels"); } public abstract void Speed(); } class Ferrari :: Vehicle { public override void Speed(){ Console.WriteLine("The Speed of Ferrari exceeds 200 mph"); } class Ferrari : Vehicle { public override void Speed(){ Console.WriteLine("The Speed of Ferrari exceeds 200 mph"); } static void Main(){ Ferrari objCar = new Ferrari(); objCar.Speed(); } static void Main(){ Ferrari objCar = new Ferrari(); objCar.Speed(); } } } Which of these statements about the property accessors and the types of properties are true? A The read-only property can be defined using the set accessor B The write-only property can be defined using the get accessor C The get accessor can be executed by referring to the name of the property D The set accessor can be executed when the property is assigned a new value Which of these statements about indexers are true? A Indexers cannot be overloaded B Indexers can be declared as static C Indexers can be overridden D Indexers may or may not contain parameters A property can be declared inside a class, struct, Interface A True B False Which of the following statements is correct about properties used in C#.NET? A A property can simultaneously be read only or write only B A property can be either read only or write only C A write only property will have only get accessor D A write only property will always return a value A Student class has a property called rollNo and stu is a reference to a Student object and we want the statement stu.RollNo = 28 to fail Which of the following options will ensure this functionality? A Declare rollNo property with both get and set accessors B Declare rollNo property with only set accessor C Declare rollNo property with get, set and normal accessors D Declare rollNo property with only get accessor E None of the above If a class Student has an indexer, then which of the following is the correct way to declare this indexer to make the C#.NET code snippet given below work successfully? Student s = new Student(); s[1, 2] = 35; A class Student { int[ ] a = new int[5, 5]; public property WriteOnly int this[int i, int j] { C class Student { int[ , ] a = new int[5, 5]; public int this[int i, int j] { set { a[i, j] = value; } set { a[i, j] = value; } } } } } B class Student { int[ , ] a = new int[5, 5]; public int property WriteOnly { set { a[i, j] = value; } } } D class Student { int[ , ] a = new int[5, 5]; int i, j; public int this { set { a[i, j] = value; } } } 10 If Sample class has a Length property with set accessor then which of the following statements will work correctly? A Sample m = new Sample(); int l; l = m.Length; B Sample m = new Sample(); m.Length = m.Length + 20; E Sample m = new Sample(); m.Length = 10; C Sample.Length = 20; D Console.WriteLine (Sample.Length); Answers Question Answer b A, b, d d C, d c a b d c 10 e

Ngày đăng: 27/10/2019, 10:21

w