ACCP I10 SEMESTER PCS – PROGRAMMING IN C# MODULAR QUIZ FOR Session 03 Which of these statements about object-oriented programming and objects are true and which statements are false? A Object-oriented programming focuses on the data-based approach B An object stores its state in variables and implements its behavior through methods C Classes contain objects that may or may not have a unique identity D Declaration of classes involves the use of the class keyword E Creating objects involves the use of the new keyword Can you match the object-oriented programming (OOP) terms against their corresponding descriptions? A Represents the behavior of an object B Represents an instance of a class C Represents the state of an object D Defines the state and behavior for all objects belonging to a particular entity E Describes an entity Description Method Object Field Class Which of these statements about methods are true and which statements are false? A A static method can directly refer only to static variables of the class B A method definition includes the return type as null if the method does not return any value C A method name begins with the & symbol or an underscore D A static method uses the static keyword in its declaration E A method declaration can specify multiple parameters to be used in the method Can you match the keywords used for access modifiers against their corresponding descriptions? A Allows access to the member by all classes B Allows access to the members only in the same assembly C Allows access to the members only within the class D Provides the most permissive access level E Allows access to the base class members in the derived classes Access modifier public internal private protected Which of these statements about method overloading and the this keyword are true and which statements are false? A The return types of the overloaded methods should be the same B Overloaded methods should contain parameters of the same type C The ref and out keywords should not be part of the signature of overloaded methods D Overloaded methods should have the same method name but with different casing E The this keyword is used to pass the current object as a parameter to a method Can you match the terms about constructors and destructors against their corresponding description? A Initializes static data members within a class B Initializes variables and is automatically invoked when an object of a class is created C Manages memory for objects D Initializes variables of a class to zero E Implements statements that are to be executed during the garbage collection process Default constructor Garbage collector Static constructor Destructor Constructor Which of these statements about constructors and destructors in C# are true and which statements are false? A A constructor can have return types like int and void B A class can have more than one constructor C A static constructor can contain the public access modifier D A destructor can contain the private access modifier E A static constructor can refer to static variables only Can you match the terms, keywords and modifiers related to inheritance against their corresponding descriptions? A Is used to invoke methods B Is used to create new objects C Is used to access base class members only by the derived class D Is used to execute the inherited methods of the derived class E Is used to access the constructor of the base class new operator new modifier dot operator base keyword protected keyword Which of these statements about method overriding are true and which statements are false? A A method is overridden with the same name and signature as declared in the base class B A method that is overriding the method defined in the base class is preceded by the virtual keyword C A base class method is preceded with the override keyword in order to override it in the derived class D A method is known as overridden derived method when it is overridden in the derived class E A method is overridden by invoking it in the derived class 10 Which of these statements about sealed classes are true and which statements are false? A The seal keyword is used to declare a class as sealed B A sealed class is used to ensure security by preventing any modification to its existing methods C A sealed class is also referred to as final class in C# D A sealed class is a class whose data members cannot be modified E A sealed class is used to support the functioning of the virtual keyword 11 Which of these statements about polymorphism are true and which statements are false? A Polymorphism supports the existence of a single class in multiple forms B Polymorphism implements multiple methods with different names but with the same signature C Compile-time polymorphism allows the compiler to identify the methods to be executed D Run-time polymorphism allows you to execute overridden methods E Run-time polymorphism supports methods with different signatures Answers Question Answer a, b, d, e A method, B object, C field, D class, E class a, d, e A public, B internal, C private, D public, E protected e A 3, B 5, C 2, D 1, E b, e A 3, B 1, C 5, D 2, E a 10 b, d 11 d