Classes And Objects In C Sharp

Name: _____________________

Date: _____________________

Instructions: Answer all questions. Write your answers clearly in the space provided.

Question 1:

What is the default access modifier for class members in C# if no access modifier is specified?

A. public
B. protected
C. internal
D. private
Answer: _________
Question 2:

What is the purpose of the readonly keyword when applied to a field in a class in C#?

A. To indicate that the field's value can only be set once
B. To indicate that the field's value cannot be changed
C. To indicate that the field's value is constant
D. To indicate that the field's value is null
Answer: _________
Question 3:

In C#, what is the method called automatically when an object is no longer in use and is being destroyed?

A. Destructor
B. Finalizer
C. Dispose
D. Garbage Collector
Answer: _________
Question 4:

What is the process of creating a new class based on an existing class in C# called?

A. Abstraction
B. Polymorphism
C. Encapsulation
D. Inheritance
Answer: _________
Question 5:

In C#, what is the keyword used to explicitly call a base class constructor from a derived class constructor?

A. parent
B. this.base
C. base
D. super
Answer: _________
Question 6:

What is the concept in OOP that allows a class to have more than one method with the same name but different parameters in C#?

A. Inheritance
B. Method Overloading
C. Encapsulation
D. None of the above
Answer: _________
Question 7:

In C#, which method is automatically called when an object is created to initialize the object's state?

A. Instantiate
B. Initialize
C. Constructor
D. Destructor
Answer: _________
Question 8:

What is the keyword used to create an alias for a data type in C#?

A. using
B. typedef
C. alias
D. class
Answer: _________
Question 9:

In C#, what is the process of defining a new class within another class called?

A. Inner Class
B. Subclass
C. Parent Class
D. Nested Class
Answer: _________
Question 10:

What is the access modifier used to declare a class member that is accessible only within its own class in C#?

A. internal
B. protected
C. private
D. public
Answer: _________
Question 11:

The process of defining two or more methods within the same class that have same name but different parameters list?

A. Method overloading
B. Method overriding
C. Encapsulation
D. None of the mentioned
Answer: _________
Question 12:

Which of these keywords is used to refer to member of base class from a sub class?

A. upper
B. base
C. this
D. none of the mentioned
Answer: _________
Question 13:

Which of the following functionality is facilitated by inheritance mechanism?

A. Use the existing functionality of base class
B. Override the existing functionality of base class
C. Implements new functionality in derived class
D. All of the mentioned
Answer: _________
Question 14:

What is the process of defining a method in terms of itself, that is a method that calls itself?

A. Polymorphism
B. Abstraction
C. Encapsulation
D. Recursion
Answer: _________
Question 15:

Which keyword is used to declare a base class method while performing overriding of base class methods?

A. this
B. virtual
C. override
D. extend
Answer: _________
Question 16:

The operator used to access member function of a class?

A. :
B. ::
C. .
D. #
Answer: _________
Question 17:

Which among the following cannot be used as a datatype for an enum in C#.NET?

A. short
B. double
C. int
D. all of the mentioned
Answer: _________
Question 18:

Which of the following statements about objects in "C#" is correct?

A. Everything you use in C# is an object, including Windows Forms and controls
B. Objects have methods and events that allow them to perform actions
C. All objects created from a class will occupy equal number of bytes in memory
D. All of the mentioned
Answer: _________
Question 19:

Which of these data types is used by the operating system to manage the Recursion in Csharp?

A. Array
B. Queue
C. Tree
D. Stack
Answer: _________
Question 20:

Select correct differences between '=' and '==' in C#.

A. '==' operator is used to assign values from one variable to another variable ''=' operator is used to compare value between two variables
B. '=' operator is used to assign values from one variable to another variable '==' operator is used to compare value between two variables
C. No difference between both operators
D. None of the mentioned
Answer: _________
Question 21:

The modifier used to hide the base class methods is?

A. Virtual
B. New
C. Override
D. Sealed
Answer: _________
Question 22:

Select the correct statement from the following?

A. Static methods can be a virtual method
B. Abstract methods can be a virtual method
C. When overriding a method, the names and type signatures of the override method must be the same as the virtual method that is being overridden
D. We can override virtual as well as nonvirtual methods
Answer: _________
Question 23:

The method called by clients of a class to explicitly release any resources like network, connection, open files etc. When the object is no longer required?

A. Finalize()
B. End()
C. Dispose()
D. Close()
Answer: _________
Question 24:

Correct way to define operator method or to perform operator overloading is?

A. public static op(arglist) { }
B. public static retval op(arglist) { }
C. public static retval operator op(arglist) { }
D. All of the mentioned
Answer: _________
Question 25:

Which of the following statements is correct about constructors in C#.NET?

A. A constructor cannot be declared as private
B. A constructor cannot be overloaded
C. A constructor can be a static constructor
D. None of the mentioned
Answer: _________
Question 26:

Which of the following keyword is used to overload user defined types by defining static member functions?

A. op
B. opoverload
C. operator
D. operatoroverload
Answer: _________
Question 27:

If base class consist of two private integers, one static integer and derived class consist of two static integers and one private integer. What would be the size of derived class object?

A. size of object depends on sizes of its non static data members
B. size of a derived class object is sum of sizes of non static data members of base class and derived class
C. size of object is calculated using sizeof() method
D. none of the mentioned
Answer: _________
Question 28:

Which among the following is the correct statement: Constructors are used to?

A. initialize the objects
B. construct the data members
C. initialize the objects & construct the data members
D. none of the mentioned
Answer: _________
Question 29:

What will be the correct statement of the following C# code? enum color:byte
{
yellow = 500,
green = 1000,
pink = 1300
}

A. byte value cannot be assigned to enum elements
B. enum elements should always take successive values
C. enum must always be of int type
D. When the valid range of byte exceeds, the compiler will report an error
Answer: _________
Question 30:

Choose the correct statement about enum used in C#.NET?

A. By default the first enumerator has a value equal to the number of elements present in the list
B. Values of the enum elements cannot be populated from database
C. The value of each successive enumerator is decreased by 1
D. An enumerator has a white space in its name
Answer: _________
Question 31:

What will be the output of the following C# expression? int a+= (float) b/= (long)c.

A. float
B. int
C. long
D. none of the mentioned
Answer: _________
Question 32:

Which of the following statements is correct?

A. Each derived class does not have its own version of a virtual method
B. If a derived class does not have its own version of virtual method then one in base class is used
C. By default methods are virtual
D. All of the mentioned
Answer: _________
Question 33:

Which statements are correct?

A. If a base class consists of a member function fun() and a derived class do not have any function with this name. An object of derived class can access fun()
B. A class D can be derived from class C, which is derived from class B which in turn is derived from class A
C. If a base class and a derived class each include a member function with same name, the member function of the derived class will be called by object of derived class
D. All of the mentioned
Answer: _________
Question 34:

How many values does a function return?

A. 0
B. 2
C. 1
D. any number of values
Answer: _________
Question 35:

Choose the correct statements about enum used in C#.NET?

A. An enum variable cannot have a private access modifier
B. An enum variable can be defined inside a class or a namespace
C. An enum variable cannot have a protected access modifier
D. An enum variable cannot have a public access modifier
Answer: _________
Question 36:

Which is the correct way to create an object of the given class abc?

A. Declaring existing class as sealed
B. Declaring existing class as override
C. Declaring existing class as overloads
D. Declaring existing class as shadows
Answer: _________
Question 37:

Which of these is not a correct statement?

A. A recursive method must have a base case
B. Recursion always uses stack
C. Recursion is always managed by C# Runtime environment
D. Recursive methods are faster that programmer written loop to call the function repeatedly using a stack
Answer: _________
Question 38:

Wrong statement about inheritance in C# .NET?

A. In inheritance chain, object construction begins from base class towards derived class
B. Inheritance cannot extend base class functionality
C. A derived class object contains all base class data
D. All of the mentioned
Answer: _________
Question 39:

What is the return type of constructors?

A. int
B. float
C. void
D. none of the mentioned
Answer: _________
Question 40:

Which keyword is used for correct implementation of an interface in C#.NET?

A. interface
B. Interface
C. intf
D. Intf
Answer: _________
Question 41:

Can the method add() be overloaded in the following ways in C#? public int add() { }
public float add(){ }

A. True
B. False
Answer: _________
Question 42:

When does a structure variable get destroyed?

A. When no reference refers to it, it will get garbage collected
B. Depends on whether it is created using new or without new operator
C. As variable goes out of the scope
D. Depends on either we free its memory using free() or delete()
Answer: _________
Question 43:

Select wrong statement about destructor in C#?

A. A class can have one destructor only
B. Destructors cannot be inherited or overloaded
C. Destructors can have modifiers or parameters
D. All of the mentioned
Answer: _________
Question 44:

Which of the following statements correctly define about the implementation of interface?

A. The calls to implementation of interface methods are routed through a method table
B. A class which implements an interface can explicitly implement members of that interface
C. One interface can be implemented in another interface
D. None of the mentioned
Answer: _________
Question 45:

Choose the correct statement among the following which supports the fact that C# does not allow the creation of empty structures?

A. C#.NET supports creation of abstract user-defined data types using structures
B. By having empty structures, it would mean that the new data types have no data associated with, which does not make any sense in C#.NET
C. Basic reason to create structures is the inability to represent real life objects using standard data types offered by the language
D. All of the mentioned
Answer: _________
Question 46:

Correct method to define + operator is?

A. public sample operator +(int a, int b)
B. public abstract operator +(int a, int b)
C. public static sample operator +(int a, int b)
D. public abstract sample operator +(int a, int b)
Answer: _________
Question 47:

What is the correct syntax to declare a method named Display inside a class named Person in C#?

A. Display { public void }
B. public void Display() { }
C. void Person::Display() { }
D. None of the above
Answer: _________
Question 48:

What is the concept in OOP that allows a class to have multiple methods with the same name but different parameters in C#?

A. Encapsulation
B. Inheritance
C. Method Overloading
D. Method Overriding
Answer: _________
Question 49:

What is the access specifier that restricts access to members of a class only within the same class and its derived classes in C#?

A. public
B. private
C. internal
D. protected
Answer: _________
Question 50:

What is the method used to destroy an object explicitly in C#?

A. Destructor
B. Dispose
C. Destroy
D. Finalize
Answer: _________
Question 51:

In C#, what is the process of creating a new class based on an existing class called?

A. Inheritance
B. Composition
C. Encapsulation
D. Abstraction
Answer: _________
Question 52:

In C#, which keyword is used to prevent a class from being inherited by other classes?

A. static
B. abstract
C. final
D. sealed
Answer: _________
Question 53:

What is the purpose of the static keyword when applied to members of a class in C#?

A. To make the member private
B. To make the member constant
C. To make the member accessible without creating an instance
D. To make the member abstract
Answer: _________
Question 54:

What is the correct way to access a static member of a class in C#?

A. ClassName->MemberName
B. ClassName.MemberName
C. MemberName
D. ClassName<-MemberName
Answer: _________
Question 55:

What is the process of hiding the implementation details of a class in C#?

A. Abstraction
B. Inheritance
C. Polymorphism
D. Encapsulation
Answer: _________
Question 56:

In C#, which keyword is used to declare a class member that can only be accessed within its own class and derived classes?

A. internal
B. protected
C. protected internal
D. private internal
Answer: _________
Question 57:

Choose the correct statement about structures as to why they are defined as value types but not reference types?

A. Since space required for structure variables is allocated on stack which is a form of memory that is automatically available when a variable to be used is in scope
B. Structures generally are used to represent user defined data types that consists of small amount of data in them. Hence using stack for declaration of such variables is not a problem
C. All of the mentioned
D. None of the mentioned
Answer: _________
Question 58:

Does C#.NET support partial implementation of interfaces?

A. True
B. False
C. Can't Say
D. None of the mentioned
Answer: _________
Question 59:

Which statement correctly defines Interfaces in C#.NET?

A. Interfaces cannot be inherited
B. Interfaces consists of data static in nature and static methods
C. Interfaces consists of only method declaration
D. None of the mentioned
Answer: _________
Question 60:

Which procedure among the following should be used to implement a 'Has a' or a 'Kind of' relationship between two entities?

A. Polymorphism
B. Inheritance
C. Templates
D. All of the mentioned
Answer: _________
Question 61:

The process of defining a method in a subclass having same name & type signature as a method in its superclass is known as?

A. Method overloading
B. Method overriding
C. Method hiding
D. None of the mentioned
Answer: _________
Question 62:

Wrong statement about enum used in C#.NET is?

A. An enum can be declared inside a class
B. An object cannot be assigned to an enum variable
C. An enum can be declared outside a class
D. An enum can have Single and Double values
Answer: _________
Question 63:

What is the return type of destructor?

A. int
B. void
C. float
D. none of the mentioned
Answer: _________
Question 64:

Access specifiers which can be used for an interface are?

A. Public
B. Protected
C. Private
D. All of the mentioned
Answer: _________
Question 65:

A class consists of two interfaces with each interface consisting of three methods. The class had no instance data. Which of the following indicates the correct size of object created from this class?

A. 12 bytes
B. 16 bytes
C. 0 bytes
D. 24 bytes
Answer: _________
Question 66:

Choose the correct statements among the following:

A. An abstract method does not have implementation
B. An abstract method can take either static or virtual modifiers
C. An abstract method can be declared only in abstract class
D. All of the mentioned
Answer: _________
Question 67:

In C#, what is the keyword used to create a reference to the current instance of a class?

A. self
B. current
C. instance
D. this
Answer: _________
Question 68:

In C#, what is the method called automatically when an object is no longer referenced and is ready to be removed from memory?

A. Destructor
B. Finalize
C. Dispose
D. Garbage Collector
Answer: _________
Question 69:

What is the default access modifier for a class in C# if no access modifier is specified?

A. internal
B. private
C. public
D. protected
Answer: _________
Question 70:

In C#, which keyword is used to declare a method that can be overridden by a derived class?

A. sealed
B. abstract
C. override
D. virtual
Answer: _________
Question 71:

In C#, what is the method used to explicitly release resources allocated by an object?

A. Free
B. Dispose
C. Deallocate
D. None of the above
Answer: _________
Question 72:

What is the access modifier used to declare a class member that is accessible only within its own class and any class derived from it in C#?

A. internal
B. protected
C. protected internal
D. private internal
Answer: _________
Question 73:

In C#, which keyword is used to explicitly call a base class constructor from a derived class constructor?

A. parent
B. this.base
C. super
D. base
Answer: _________
Question 74:

In C#, what is the method called automatically when an object is created to initialize the object's state?

A. Constructor
B. Destructor
C. Initialize
D. Instantiate
Answer: _________
Question 75:

What is the concept in OOP that allows a class to have more than one constructor in C#?

A. Method Overriding
B. Constructor Overriding
C. Method Overloading
D. Constructor Overloading
Answer: _________
Question 76:

What is the keyword used to create an instance of a class in C#?

A. object
B. new
C. instance
D. None of the above
Answer: _________
Question 77:

Which of the following cannot be used to declare an interface correctly?

A. Properties
B. Methods
C. Structures
D. Events
Answer: _________
Question 78:

In an inheritance chain through which of the following, the base class and its components are accessible to the derived class?

A. Scope resolution operator(:)
B. Class visibility modifiers (public,private etc.)
C. Dot operator (.)
D. All of the mentioned
Answer: _________
Question 79:

Which of the following is used to define the member of a class externally?

A. :
B. ::
C. #
D. none of the mentioned
Answer: _________
Question 80:

Which of these can be overloaded?

A. Constructors
B. Methods
C. Both Constructors & Methods
D. None of the mentioned
Answer: _________
Question 81:

Operator used to free the memory when memory is allocated?

A. new
B. free
C. delete
D. none of the mentioned
Answer: _________
Question 82:

Choose the statements which makes interface different from classes?

A. Unlike classes, interfaces consists of only declaration but not implementation
B. Interfaces cannot be used directly like classes to create new objects
C. Interfaces consists of declaration of methods, properties events and type definitions
D. All of the mentioned
Answer: _________
Question 83:

Which among the following differentiates enum in C#.NET from enum in C language?

A. C is strictly a typed language, C#.NET also is a strictly typed language
B. In C, language variables of enum types can be used interchangeably with integers using type casts while enum variables cannot be used as a normal integers in C#.NET
C. None of the mentioned
D. All of the mentioned
Answer: _________
Question 84:

Which of the following statements are correct about functions?

A. C# allows a function to have arguments with default values
B. Redefining a method parameter in the method's body causes an exception
C. C# allows function to have arguments with default values
D. Omitting the return type in method definition results into exception
Answer: _________
Question 85:

Which reference modifier is used to define reference variable?

A. &
B. ref
C. #
D. $
Answer: _________
Question 86:

"A mechanism that binds together code and data in manipulates, and keeps both safe from outside interference and misuse. In short it isolates a particular code and data from all other codes and data. A well-defined interface controls access to that particular code and data."

A. Abstraction
B. Polymorphism
C. Inheritance
D. Encapsulation
Answer: _________
Question 87:

To override a method in the subclass, the base class method should be defined as?

A. Virtual
B. Abstract
C. Override
D. All of the mentioned
Answer: _________
Question 88:

What is Recursion in CSharp defined as?

A. Recursion is another form of class
B. Recursion is another process of defining a method that calls other methods repeatedly
C. Recursion is a process of defining a method that calls itself repeatedly
D. Recursion is a process of defining a method that calls other methods which in turn calls this method
Answer: _________
Question 89:

Which keyword is used to refer baseclass constructor to subclass constructor?

A. This
B. Static
C. Base
D. Extend
Answer: _________
Question 90:

Which statements among following are correct?

A. We can derive a class from a base class even if source code of base class not available
B. Multiple inheritance is different from multiple levels of inheritance
C. It is legal to make objects of one class as members of another class
D. All of the mentioned
Answer: _________
Question 91:

Which of these can be used to fully abstract a class from its implementation?

A. Objects
B. Packages
C. Interfaces
D. None of the Mentioned
Answer: _________
Question 92:

Select the class visibility modifiers among the following:

A. Private, protected, public, internal
B. Private, protected, public, internal, protected internal
C. Private, protected, public
D. All of the mentioned
Answer: _________
Question 93:

Which of the following is the correct way of implementing an interface addition by class maths?

A. class maths : addition {}
B. class maths implements addition {}
C. class maths imports addition {}
D. none of the mentioned
Answer: _________
Question 94:

Which of the given modifiers can be used to prevent Method overriding?

A. Static
B. Constant
C. Sealed
D. final
Answer: _________
Question 95:

Which of the following keyword is used to change data and behavior of a base class by replacing a member of the base class with a new derived member?

A. Overloads
B. Overrides
C. new
D. base
Answer: _________
Question 96:

Choose the wrong statement about 'INTERFACE' in C#.NET?

A. An explicitly implemented member could be accessed from an instance of the interface
B. Interfaces are declared public automatically
C. An interface could not contain signature of the indexer
D. None of the mentioned
Answer: _________
Question 97:

Selecting appropriate method out of number of overloaded methods by matching arguments in terms of number, type and order and binding that selected method to object at compile time is called?

A. Static binding
B. Static Linking
C. Compile time polymorphism
D. All of the mentioned
Answer: _________
Question 98:

If no access modifier for a class is specified, then class accessibility is defined as?

A. public
B. protected
C. private
D. internal
Answer: _________
Question 99:

Number of constructors a class can define is?

A. 1
B. 2
C. Any number
D. None of the mentioned
Answer: _________
Question 100:

Correct way to overload +operator?

A. public sample operator + (sample a, sample b)
B. public abstract operator + (sample a,sample b)
C. public static sample operator + (sample a, sample b)
D. all of the mentioned
Answer: _________
Question 101:

The data members of a class by default are?

A. protected, public
B. private, public
C. private
D. public
Answer: _________
Question 102:

The capability of an object in Csharp to take number of different forms and hence display behaviour as according is known as . . . . . . . .

A. Encapsulation
B. Polymorphism
C. Abstraction
D. None of the mentioned
Answer: _________
Question 103:

What is the most specified using class declaration?

A. type
B. scope
C. type & scope
D. none of the mentioned
Answer: _________
Question 104:

Given class sample is inherited by class sample 1. Which are the correct statements about construction of object of class sample?

A. While creating the object firstly the constructor of class sample will be called followed by constructor of class sample 1
B. The constructor of only sample class will be called
C. While creating the object firstly constructor of class sample 1 will be called followed by constructor of class sample
D. The order of calling constructors depend on whether constructors in class sample and sample 1 are private or public
Answer: _________
Question 105:

Arrange the following overloaded operators in increasing order of precedence? %, <<, &, /, +

A. '%' < '<<' < '+' < '-' < '&' < '/'
B. '<<' < '&' < '%' < '-' < '/' < '+'
C. '&' < '-' <'%' < '<<' < '/' < '+'
D. '/' < '-' < '%' < '+' < '<<' < '&'
Answer: _________
Question 106:

When we call a constructor method among different given constructors. We match the suitable constructor by matching the name of constructor first, then the number and then the type of parameters to decide which constructor is to be overloaded. The process is also known as?

A. Method overriding
B. Inheritance
C. Polymorphism
D. Encapsulation
Answer: _________
Question 107:

Which method has the same name as that of its class?

A. delete
B. class
C. constructor
D. none of the mentioned
Answer: _________
Question 108:

Wrong statement about run time polymorphism is?

A. The overridden base method should be virtual, abstract or override
B. An abstract method is implicitly a virtual method
C. An abstract inherited property cannot be overridden in a derived class
D. Both override method and virtual method must have same access level modifier
Answer: _________
Question 109:

Which of the following statements are correct?

A. There is one garbage collector per program running in memory
B. There is one common garbage collector for all programs
C. To garbage collect an object set all references to it as null
D. Both There is one common garbage collector for all programs & To garbage collect an object set all references to it as null
Answer: _________
Question 110:

Correct statement about constructors in C#.NET is?

A. Constructors can be overloaded
B. Constructors are never called explicitly
C. Constructors have same name as name of the class
D. All of the mentioned
Answer: _________
Question 111:

Which of the following modifiers is used when an abstract method is redefined by a derived class?

A. Overloads
B. Override
C. Base
D. Virtual
Answer: _________
Question 112:

Choose the correct statement among the below mentioned statements.

A. Forgetting to declare an operator method as public
B. Forgetting to declare an operator method as static
C. Forgetting to return a bool type value while overloading a relational operator
D. All of the mentioned
Answer: _________
Question 113:

What is the vector in operator overloading?

A. class
B. method()
C. data type
D. none of the mentioned
Answer: _________
Question 114:

The number of levels of inheritance are?

A. 5
B. 4
C. 3
D. 2
Answer: _________
Question 115:

A class member declared protected becomes member of subclass of which type?

A. public member
B. private member
C. protected member
D. static member
Answer: _________
Question 116:

Select the wrong statement about 'ref' keyword in C#?

A. References can be called recursively
B. The 'ref' keyword causes arguments to be passed by reference
C. When 'ref' are used, any changes made to parameters in method will be reflected in variable when control is passed back to calling method
D. All of the mentioned
Answer: _________
Question 117:

Which of these operators must be used to inherit a class?

A. :
B. &
C. ::
D. extends
Answer: _________
Question 118:

The modifier used to define a class which does not have objects of its own but acts as a base class for its subclass is?

A. Sealed
B. Static
C. New
D. Abstract
Answer: _________
Question 119:

Correct statement about constructor overloading in C# is?

A. Overloaded constructors have the same name as the class
B. Overloaded constructors cannot use optional arguments
C. Overloaded constructors can have different type of number of arguments as well as differ in number of arguments
D. All of the mentioned
Answer: _________
Question 120:

Select the correct statement among the given statements?

A. One class could implement only one interface
B. Properties could be declared inside an interface
C. Interfaces cannot be inherited
D. None of the mentioned
Answer: _________
Question 121:

If a class inheriting an abstract class does not define all of its functions then it is known as?

A. Abstract
B. A simple class
C. Static class
D. None of the mentioned
Answer: _________
Question 122:

Select the wrong statements among the following?

A. A structure can contain properties
B. A structure can contain constructors
C. A structure can contain protected data members
D. A structure can contain constants
Answer: _________
Question 123:

Which of the following statements are correct in nature?

A. The conditional logical operators cannot be overloaded
B. The array indexing operator can be overloaded
C. A public or nested public preference type does not overload the equality operator
D. None of the mentioned
Answer: _________
Question 124:

Which form of inheritance is not supported directly by C# .NET?

A. Multiple inheritance
B. Multilevel inheritance
C. Single inheritance
D. Hierarchical inheritance
Answer: _________
Question 125:

Which of these will happen if the recursive method does not have a base case?

A. Infinite loop condition occurrence
B. System gets hanged
C. After 10000 executions program will be automatically stopped
D. None of the mentioned
Answer: _________
Question 126:

Which operator among the following signifies the destructor operator?

A. ::
B. :
C. ~
D. &
Answer: _________
Question 127:

In Inheritance concept, which of the following members of base class are accessible to derived class members?

A. static
B. protected
C. private
D. shared
Answer: _________
Question 128:

Choose the wrong statement about structures in C#.NET?

A. Structures can be declared within a procedure
B. Structures can implement an interface but they cannot inherit from another structure
C. Structure members cannot be declared as protected
D. A structure cannot be empty
Answer: _________
Question 129:

A type of class which does not have its own objects but acts as a base class for its subclass is known as?

A. Static class
B. Sealed class
C. Abstract class
D. None of the mentioned
Answer: _________
Question 130:

What is a class in C#?

A. A blueprint for creating objects
B. A method in C#
C. A variable in C#
D. A data type in C#
Answer: _________
Question 131:

Which keyword is used to create an object of a class in C#?

A. create
B. instance
C. object
D. new
Answer: _________
Question 132:

What is an object in C#?

A. A method in C#
B. A variable in C#
C. An instance of a class
D. A data type in C#
Answer: _________
Question 133:

What is the access specifier that allows members of a class to be accessed from any other class in the same assembly in C#?

A. public
B. private
C. protected
D. internal
Answer: _________
Question 134:

What is the purpose of a constructor in C#?

A. To define properties of a class
B. To initialize the object's state
C. To destroy the object
D. None of the above
Answer: _________
Question 135:

Which keyword is used to access members of a class from within the class itself in C#?

A. current
B. me
C. this
D. self
Answer: _________
Question 136:

In C#, what is the syntax to define a constructor for a class named Car that takes parameters make and model?

A. Car(string make, string model) { }
B. Car = (string make, string model) => { }
C. void Car(string make, string model) { }
D. public Car(string make, string model) { }
Answer: _________
Question 137:

What is the keyword used to inherit a class in C#?

A. :
B. inherits
C. extends
D. inherit
Answer: _________
Question 138:

In C#, what is the method called automatically when an object of a class is created?

A. Instantiate
B. Initialize
C. Destructor
D. Constructor
Answer: _________
Question 139:

What is the purpose of encapsulation in C#?

A. To make the class public
B. To expose the internal state of an object
C. To hide the internal state of an object
D. To destroy the object
Answer: _________
Question 140:

Name a method which has the same name as that of class and which is used to destroy objects also called automatically when application is finally on process of being getting terminated.

A. Constructor
B. Finalize()
C. Destructor
D. End
Answer: _________
Question 141:

Which statements are correct about operator overloading?

A. Mathematical or physical modeling where we use classes to represent objects such as vectors, matrices, complex-numbers etc
B. Graphical programs where coordinate related objects are used to represent positions on the screen
C. Financial programs where a class represents an amount of money
D. All of the mentioned
Answer: _________
Question 142:

Choose the wrong statement from the given set of statements?

A. All operators in C#.NET cannot be overloaded
B. We can use the new modifier to modify a nested type if the nested type is hiding another type
C. Operator overloading permits the use of symbols to represent computations for a type
D. In case of operator overloading all parameters must be of different type than the class or struct that declares the operators
Answer: _________
Question 143:

Operators that can be overloaded are?

A. ||
B. '+='
C. +
D. []
Answer: _________
Question 144:

Which of the following cannot be used to declare a class as a virtual?

A. Methods
B. Properties
C. Events
D. Fields
Answer: _________
Question 145:

What will be the output of the following C# code? static void Main(string[] args)
{
int []a = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10}

func(ref a)

Console.ReadLine()

}
static void func(ref int[] x)
{
Console.WriteLine(" numbers are:")

for (int i = 0

i < x.Length

i++)
{
if (x[i] % 2 == 0)
{
x[i] = x[i] + 1

Console.WriteLine(x[i])

}
}
}

A. numbers are : 2 4 6 8 10
B. numbers are : 3 5 7 9 11
C. numbers are : 2 3 4 5 6
D. none of the mentioned
Answer: _________
Question 146:

What will be the output of the following C# code? enum letters
{
a,
b,
c
}
letters l

l = letters.a

Console.writeline(l)

A. -1
B. 0
C. a
D. letters.a
Answer: _________
Question 147:

What will be the output of the following C# code? static void Main(string[] args)
{
int y = 3

y++

if (y <= 5)
{
Console.WriteLine("hi")

Main(args)

}
Console.ReadLine()

}

A. hi hi
B. hi
C. Stack overflow exception
D. None of the mentioned
Answer: _________
Question 148:

What will be the output of the following C# code? class maths
{
public int fun(int ii)
{
return(ii > 0 ? ii :ii * -1)

}
public long fun(long ll)
{
return(ll > 0 ? ll :ll * -1)

}
public double fun( double dd)
{
return(dd > 0 ? dd :dd * -1)

}
}
class Program
{
static void Main(string[] args)
{
maths obj = new maths()

int i = -25

int j

long l = -100000l

long m

double d = -12.34

double e

j = obj.fun(i)

m = obj.fun(l)

e = obj.fun(d)

Console.WriteLine(j + " " + m + " " + e)

Console.ReadLine()

}
}

A. 1 1 1
B. 0 0 0
C. 25 100000 12.34
D. -25 -100000 -12.34
Answer: _________
Question 149:

What will be the output of the following C# code? class maths
{
public int fun1(int k)
{
k = 20

return k

}
public Single fun1(float t)
{
t = 3.4f

return t

}
}
class Program
{
static void Main(string[] args)
{
maths obj = new maths()

int i

i = obj.fun1(30)

Console.WriteLine(i)

Single j

j = obj.fun1(2.5f)

Console.WriteLine(j)

Console.ReadLine()

}
}

A. 30 2.5f
B. 2.5f 30
C. 20 2.5f
D. 20 3.4f
Answer: _________
Question 150:

What will be the output of the following C# code? interface calc
{
void cal(int i)

}
public class maths :calc
{
public int x

public void cal(int i)
{
x = i * i

}
}
class Program
{
public static void Main(string[] args)
{
display arr = new display()

arr.x = 0

arr.cal(2)

Console.WriteLine(arr.x)

Console.ReadLine()

}
}

A. 0
B. 2
C. 4
D. None of the mentioned
Answer: _________
Question 151:

What will be the output of the following C# code? enum color:int
{
red,
green,
blue = 5,
cyan,
pink = 10,
brown
}
console.writeline((int)color.green)

console.writeline((int)color.brown)

A. 2 10
B. 2 11
C. 1 11
D. 1 5
Answer: _________
Question 152:

What will be the output of the following C# code? class maths
{
int i

public maths(int ii)
{
ii = -25

int g

g = ii > 0 ? ii : ii * -1

Console.WriteLine(g)

}
}
class maths1 :maths
{
public maths1(int ll) :base(ll)
{
ll = -1000

Console.WriteLine((ll > 0 ? ll : ll * -1))

}
}
class Program
{
static void Main(string[] args)
{
maths1 p = new maths1(6)

Console.ReadLine()

}
}

A. -25 -1000
B. -1000 -25
C. 25 1000
D. None of the mentioned
Answer: _________
Question 153:

What will be the output of the following C# code? class maths
{
public static void fun1()
{
Console.WriteLine("method 1 :")

}
public void fun2()
{
fun1()

Console.WriteLine("method 2 :")

}
public void fun2(int k)
{
Console.WriteLine(k)

fun2()

}
}
class Program
{
static void Main(string[] args)
{
maths obj = new maths()

maths.fun1()

obj.fun2(20)

Console.ReadLine()

}
}

A. method 1: method 2: 20 method 1:
B. method 2: 20 method 1: method 1:
C. method 1: 0 method 2: method 2:
D. method 1: 20 method 1: method 2:
Answer: _________
Question 154:

What will be the output of the following C# code? static void Main(string[] args)
{
int a = 10 , b = 20

Console.WriteLine("Result before swap is: "+ a +" "+b)

swap(ref a, ref b)

Console.ReadLine()

}
static void swap(ref int i, ref int j)
{
int t

t = i

i = j

j = t

Console.WriteLine("Result after swap is:"+ i +" "+j)

}

A. Result before swap is: 20 10 Result after swap is: 20 10
B. Result before swap is: 10 20 Result after swap is:20 10
C. Result before swap is: 10 20 Result after swap is:10 20
D. Result before swap is: 20 10 Result after swap is:10 20
Answer: _________
Question 155:

What will be the output of the following C# code? class A
{
public int i
private int j
}
class B :A
{
void display()
{
base.j = base.i + 1
Console.WriteLine(base.i + " " + base.j)
}
}
class Program
{
static void Main(string[] args)
{
B obj = new B()
obj.i = 1
obj.j = 2
obj.display()
Console.ReadLine()
}
}

A. 1, 3
B. 2, 3
C. 1, 2
D. compile time error
Answer: _________
Question 156:

What will be the output of the following C# code? static void Main(string[] args)
{
int a = 5
int s = 0, c = 0
Mul (a, ref s, ref c)
Console.WriteLine(s + "t " +c)
Console.ReadLine()
}
static void Mul (int x, ref int ss, ref int cc)
{
ss = x * x
cc = x * x * x
}

A. 125 25
B. 25 125
C. Compile time error
D. 0 0
Answer: _________
Question 157:

What will be the output of the following C# code? class z
{
public int X
public int Y
public const int c1 = 5
public const int c2 = c1 * 25
public void set(int a, int b)
{
X = a
Y = b
}

}
class Program
{
static void Main(string[] args)
{
z s = new z()
s.set(10, 20)
Console.WriteLine(s.X + " " + s.Y)
Console.WriteLine(z.c1 + " " + z.c2)
Console.ReadLine()
}
}

A. 10 20 5 25
B. 20 10 25 5
C. 10 20 5 125
D. 20 10 125 5
Answer: _________
Question 158:

Which C# statement should be added in function a() of class y to get output "i love csharp"? class x
{
public void a()
{
console.write("bye")
}
}
class y : x
{
public void a()
{
/* add statement here */
console.writeline(" i love csharp ")
}
}
class program
{
static void main(string[] args)
{
y obj = new obj()
obj.a()
}
}

A. x.a()
B. a()
C. base.a()
D. x::a()
Answer: _________
Question 159:

What will be the output of the following C# code? static void Main(string[] args)
{
int x = 8
int b = 16
int C = 64
x /= b /= C /= x
Console.WriteLine(x + " " + b+ " " +C)
Console.ReadLine()
}

A. 8 2 4
B. 2 4 8
C. 4 2 8
D. Compile time error
Answer: _________
Question 160:

What will be the output of the following C# code? interface i1
{
void fun()
}
interface i2
{
void fun()
}
public class maths :i1, i2
{
void i1.fun()
{
Console.WriteLine("i1.fun")
}
void i2.fun()
{
Console.WriteLine("i2.fun")
}
}
class Program
{
static void Main(string[] args)
{
Sample obj = new Sample()
i1 i = (i1) obj
i.fun()
i2 ii = (i2) obj
ii.fun()
}
}

A. i1.fun
B. i2.fun i1.fun
C. 0
D. i1.fun i2.fun
Answer: _________
Question 161:

What will be the output of the following C# code? class maths
{
public maths()
{
Console.WriteLine("constructor 1 :")
}
public maths(int x)
{
int p = 2
int u
u = p + x
Console.WriteLine("constructor 2: " +u)
}
}
class Program
{
static void Main(string[] args)
{
maths k = new maths(4)
maths t = new maths()
Console.ReadLine()
}
}

A. constructor 1: constructor 2: 6
B. constructor 2: 6 constructor 2: 6
C. constructor 2: 6 constructor 1:
D. none of the mentioned
Answer: _________
Question 162:

What will be the output of the following C# code? enum colors
{
red,
black,
pink
}
colors s = colors.black
type t
t = c.GetType()
string[] str
str = Enum.GetNames(t)
Console.WriteLine(str[0])

A. 0
B. black
C. red
D. 1
Answer: _________
Question 163:

What will be the output of the following C# code? class recursion
{
int fact(int n)
{
int result
if (n == 1)
return 1
result = fact(n - 1) * n
return result
}
}
class Program
{
public static void main(String args[])
{
recursion obj = new recursion()
Console.WriteLine(obj.fact(4))
}
}

A. 24
B. 30
C. 120
D. 144
Answer: _________
Question 164:

What will be the output of the following C# code? static void Main(string[] args)
{
int[] arr = new int[] {1, 2, 3, 4, 5}
fun1(ref arr)
Console.ReadLine()
}
static void fun1(ref int[] array)
{
for (int i = 0
i < array.Length
i++)
{
array[i] = array[i] + 5
Console.WriteLine(array[i] + " ")
}
}

A. 6 7 8 9 10
B. 15 17 8 8 20
C. 15 17 8 29 20
D. Syntax error while passing reference of array variable
Answer: _________
Question 165:

What will be the output of the following C# code? static void Main(string[] args)
{
int a = 5
fun1 (ref a)
Console.WriteLine(a)
Console.ReadLine()
}
static void fun1(ref int a)
{
a = a * a
}

A. 5
B. 0
C. 20
D. 25
Answer: _________
Question 166:

What will be the output of the following C# code? class sample
{
int i
double k
public sample (int ii, double kk)
{
i = ii
k = kk
double j = (i) + (k)
Console.WriteLine(j)
}
~sample()
{
double j = i - k
Console.WriteLine(j)
}
}
class Program
{
static void Main(string[] args)
{
sample s = new sample(8, 2.5)
Console.ReadLine()
}
}

A. 0 0
B. 10.5 0
C. Compile time error
D. 10.5 5.5
Answer: _________
Question 167:

What will be the output of the following C# code? class maths
{
int fact(int n)
{
int result
if (n == 1)
return 1
result = fact(n - 1) * n
return result
}
}
class Output
{
static void main(String args[])
{
maths obj = new maths()
Console.WriteLine(obj.fact(4)*(3))
}
}

A. 64
B. 60
C. 72
D. 84
Answer: _________
Question 168:

What will be the output of the following C# code? namespace ConsoleApplication4
{
class A
{
public int i
public void display()
{
Console.WriteLine(i)
}
}
class B: A
{
public int j
public void display()
{
Console.WriteLine(j)
}
}
class Program
{
static void Main(string[] args)
{
B obj = new B()
obj.j = 1
obj.i = 8
obj.display()
Console.ReadLine()
}
}
}

A. 8, 1
B. 8
C. 1
D. 1, 8
Answer: _________
Question 169:

What will be the output of the following C# code? enum per
{
a,
b,
c,
d,
}
per.a = 10
Console.writeline(per.b)

A. 11
B. 1
C. 2
D. compile time error
Answer: _________
Question 170:

What will be the output of the following C# code? 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()
}
}

A. Code executes successfully prints nothing
B. This is base class constructor
C. Compile time error
D. None of the mentioned
Answer: _________
Question 171:

What will be the output of the following C# code? class maths
{
public int x
public double y
public int add(int a, int b)
{
x = a + b
return x
}
public int add(double c, double d)
{
y = c + d
return (int)y
}
public maths()
{
this.x = 0
this.y = 0
}
}
class Program
{
static void Main(string[] args)
{
maths obj = new maths()
int a = 4
double b = 3.5
obj.add(a, a)
obj.add(b, b)
Console.WriteLine(obj.x + " " + obj.y)
Console.ReadLine()
}
}

A. 4, 3.5
B. 8, 0
C. 7.5, 8
D. 8, 7
Answer: _________
Question 172:

What will be the Correct statement in the following C# code? interface a1
{
void f1()
int f2()
}
class a :a1
{
void f1()
{
}
int a1.f2()
{
}
}

A. class a is an abstract class
B. A method table would not be created for class a
C. The definition of f1() in class a should be void a1.f1()
D. None of the mentioned
Answer: _________
Question 173:

What will be the output of the following C# code snippet? class maths
{
public int fact(int n)
{
int result
if (n == 2)
return 1
result = fact(n - 1) * n
return result
}
}
class Program
{
static void Main(string[] args)
{
maths obj = new maths()
Console.WriteLine(obj.fact(4))
Console.ReadLine()
}
}

A. 24
B. 0
C. 12
D. 1
Answer: _________
Question 174:

What will be the Correct statement in the following C# code? 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()
}
}

A. Index should be declared as protected if it is to become available in inheritance chain
B. Constructor of sample class does not get inherited in sample 1 class
C. During constructing an object referred to by z, Firstly constructor of sample class will be called followed by constructor of sample 1 class
D. All of the mentioned
Answer: _________
Question 175:

What will be the output of the following C# code? class A
{
public int i
public void display()
{
Console.WriteLine(i)
}
}
class B: A
{
public int j
public void display()
{
Console.WriteLine(j)
}
}
class Program
{
static void Main(string[] args)
{
B obj = new B()
obj.i = 1
obj.j = 2
obj.display()
Console.ReadLine()
}
}

A. 0
B. 2
C. 1
D. Compile time error
Answer: _________
Question 176:

What will be the correct statement in the following C# code? class trial
{
int i
float d
}
struct sample
{
private int x
private Single y
private trial z
}
sample s = new sample()

A. trial object referred by z is created on the stack
B. z is created on the heap
C. Both s and z will be created on the heap
D. s will be created on the stack
Answer: _________
Question 177:

What will be the output of the following C# code? namespace ConsoleApplication4
{
abstract class A
{
public int i
public int j
public abstract void display()
}
class B: A
{
public int j = 5
public override void display()
{
this.j = 3
Console.WriteLine(i + " " + j)
}
}
class Program
{
static void Main(string[] args)
{
B obj = new B()
obj.i = 1
obj.display()
Console.ReadLine()
}
}
}

A. 1, 5
B. 0, 5
C. 1, 0
D. 1, 3
Answer: _________
Question 178:

What will be the correct statement in the following C# code? struct book
{
private String name
private int pages
private Single price
}
book b = new book()

A. New structure can be inherited from struct book
B. When the program terminates, variable b will get garbage collected
C. The structure variable 'b' will be created on the stack
D. None of the above
Answer: _________
Question 179:

What will be the output of the following C# code? static void Main(string[] args)
{
int x = 8
int b = 16
int C = 64
x /= b /= C
Console.WriteLine(x + " " + b+ " " +C)
Console.ReadLine()
}

A. 8 2 32
B. 32 4 8
C. 32 2 8
D. Compile time error
Answer: _________
Question 180:

What will be the output of the following C# code? static void Main(string[] args)
{
int i = 10
double d = 35.78
fun(i)
fun(d)
Console.ReadLine()
}
static void fun(double d)
{
Console.WriteLine(d)
}

A. 35.78 10
B. 10 35
C. 10 35.78
D. None of the mentioned
Answer: _________
Question 181:

What will be the Correct statement in the following C# code? 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)
}
}
}

A. Compile time error
B. b a
C. a b
D. The program will work correctly if we replace base(a1) with base.baseclass(a1)
Answer: _________
Question 182:

What will be the output of the following C# code? class A
{
public int i
protected int j
}
class B : A
{
public int j
public void display()
{
base.j = 3
Console.WriteLine(i + " " + j)
}
}
class Program
{
static void Main(string[] args)
{
B obj = new B()
obj.i = 1
obj.j = 2
obj.display()
Console.ReadLine()
}
}

A. 2 1
B. 1 0
C. 0 2
D. 1 2
Answer: _________
Question 183:

What will be the output of the following C# code? class overload
{
public int x
int y
public int add(int a)
{
x = a + 1
return x
}
public int add(int a, int b)
{
x = a + 2
return x
}
}
class Program
{
static void Main(string[] args)
{
overload obj = new overload()
overload obj1 = new overload()
int a = 0
obj.add(6)
obj1.add(6, 2)
Console.WriteLine(obj.x)
Console.WriteLine(obj1.x)
Console.ReadLine()
}
}

A. 8 8
B. 0 2
C. 8 10
D. 7 8
Answer: _________
Question 184:

What will be the output of the following C# code? class maths
{
public int length
public int breadth
public maths(int x)
{
length = x + 1
}
public maths(int x, int y)
{
length = x + 2
}
}
class Program
{
static void Main(string[] args)
{
maths m = new maths(6)
maths k = new maths(6, 2)
Console.WriteLine(m.length)
Console.WriteLine(k.length)
Console.ReadLine()
}
}

A. 8, 8
B. 0, 2
C. 8, 10
D. 7, 8
Answer: _________
Question 185:

What will be the output of the following C# code? 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)
}
}

A. 100 150 10
B. 1000 150 1000
C. 100 150 1000
D. 100 150 100
Answer: _________
Question 186:

What will be the output of the following C# code? class box
{
public int volume
int width
int height
int length
public box ( int w, int h, int l)
{
width = w
height = h
length = l
}
public ~box()
{
volume = width * length * height
}
}
class Program
{
static void Main(string[] args)
{
box b = new box(4, 5, 9)
Console.WriteLine(b.volume)
Console.ReadLine()
}

}

A. 0
B. 180
C. Compile time error
D. None of the mentioned
Answer: _________
Question 187:

What will be the output of the following C# code? using System
public class BaseClass
{
public BaseClass()
{
Console.WriteLine("I am a base class")
}
}
public class ChildClass : BaseClass
{
public ChildClass()
{
Console.WriteLine ("I am a child class")
}
static void Main()
{
ChildClass CC = new ChildClass()
}
}

A. I am a base class I am a child class
B. I am a child class I am a base class
C. Compile time error
D. None of the mentioned
Answer: _________
Question 188:

What will be the output of the following C# code? class a
{
public void fun()
{
Console.WriteLine("base method")
}
}
class b: a
{
public new void fun()
{
Console.WriteLine(" derived method ")
}
}
class Program
{
static void Main(string[] args)
{
b k = new b()
k.fun()
Console.ReadLine()
}
}

A. Base method
B. Derived method
C. Code runs successfully prints nothing
D. Compile time error
Answer: _________
Question 189:

What will be the output of the following C# code? class sample
{
public int i
void display()
{
Console.WriteLine(i)
}
}
class sample1 : sample
{
public int j
public void display()
{
Console.WriteLine(j)
}
}
class Program
{
static void Main(string[] args)
{
sample1 obj = new sample1()
obj.i = 1
obj.j = 2
obj.display()
Console.ReadLine()
}
}

A. 1
B. 3
C. 2
D. Compile Time error
Answer: _________
Question 190:

What will be the output of the following C# code? class abc
{
public static void a()
{
console.writeline("first method")
}
public void b()
{
a()
console.writeline("second method")
}
public void b(int i)
{
console.writeline(i)
b()
}
}
class program
{
static void main()
{
abc k = new abc()
abc.a()
k.b(20)
}
}

A. second method 20 second method first method
B. first method 20 first method second method
C. first method 20
D. second method 20 first method
Answer: _________
Question 191:

What will be the output of the following C# code? class Program
{
static void Main(string[] args)
{
Console.WriteLine( vol(10))
Console.WriteLine( vol(2.5f, 5))
Console.WriteLine( vol( 5l, 4, 5))
Console.ReadLine()
}
static int vol(int x)
{
return(x * x * x)
}
static float vol(float r, int h)
{
return(3.14f * r * r * h)
}
static long vol(long l, int b, int h)
{
return(l * b * h)
}
}

A. 1000 0 100
B. 0 0 100
C. compile time error
D. 1000 98.125 100
Answer: _________
Question 192:

What will be the output of the following C# code? class maths
{
public int fun(int k, int y, int n)
{
Console.WriteLine(k + " " + y + " " + n)
return (k)
}
public int fun1(int t,float z)
{
Console.WriteLine(t + " " + z)
return t
}
}
class Program
{
static void Main(string[] args)
{
maths obj = new maths()
int b = 90
int c = 100
int d
float l
int i = obj.fun(b, c, 12)
int j = (obj.fun1(12, 14.78f))
Console.ReadLine()
}
}

A. 0, 0, 0 12, 14.78
B. 0, 0, 0 0, 0
C. 90, 100, 12 12, 14
D. 90, 100, 12 12, 14.78
Answer: _________
Question 193:

What will be the output of the following C# code? class sample
{
public int i
public int[] arr = new int[10]
public void fun(int i, int val)
{
arr[i] = val
}
}
class Program
{
static void Main(string[] args)
{
sample s = new sample()
s.i = 10
sample.fun(1, 5)
s.fun(1, 5)
Console.ReadLine()
}
}

A. sample.fun(1, 5) will not work correctly
B. s.i = 10 cannot work as i is 'public'
C. sample.fun(1, 5) will set value as 5 in arr[1]
D. s.fun(1, 5) will work correctly
Answer: _________
Question 194:

The correct way to define a variable of type struct abc in the following C# code? struct abc
{
public string name
protected internal int age
private Single sal
}

A. abc e = new abc()
B. abc()
C. abc e e = new abc
D. abc e = new abc
Answer: _________
Question 195:

What will be the output of the following C# code? static void Main(string[] args)
{
int X = 0
if (Convert.ToBoolean(X = 0))
Console.WriteLine("It is zero")
else
Console.WriteLine("It is not zero")
Console.ReadLine()
}

A. It is zero
B. It is not zero
C. Infinite loop
D. None of the mentioned
Answer: _________
Question 196:

What will be the output of the following C# code? class maths
{
int i
public maths(int x)
{
i = x
Console.WriteLine(" hello: ")
}
}
class maths1 : maths
{
public maths1(int x) :base(x)
{
Console.WriteLine("bye")
}
}
class Program
{
static void Main(string[] args)
{
maths1 k = new maths1(12)
Console.ReadLine()
}
}

A. hello bye
B. 12 hello
C. bye 12
D. Compile time error
Answer: _________
Question 197:

Calculate the number of bytes a structure variable s occupies in the memory if it is defined as follows. class abc
{
int i
Decimal d
}
struct sample
{
private int x
private Single y
private trial z
}
sample s = new sample()

A. 24 bytes
B. 8 bytes
C. 16 bytes
D. 12 bytes
Answer: _________
Question 198:

What will be the output of the following C# code? class maths
{
int i
public maths(int ii)
{
ii = 12
int j = 12
int r = ii * j
Console.WriteLine(r)
}
}
class maths1 : maths
{
public maths1(int u) :base(u)
{
u = 13
int h = 13
Console.WriteLine(u + h)
}
}
class maths2 : maths1
{
public maths2(int k) :base(k)
{
k = 24
int o = 6
Console.WriteLine(k /o)
}
}
class Program
{
static void Main(string[] args)
{
maths2 t = new maths2(10)
Console.ReadLine()
}
}

A. 4, 26, 144
B. 26, 4, 144
C. 144, 26, 4
D. 0, 0, 0
Answer: _________
Question 199:

What will be the output of the following C# code? class test
{
public void print()
{
Console.WriteLine("Csharp:")
}
}
class Program
{
static void Main(string[] args)
{
test t
t.print()
Console.ReadLine()
}
}

A. Code runs successfully prints nothing
B. Code runs and prints "Csharp"
C. Syntax error as t is unassigned variable which is never used
D. None of the mentioned
Answer: _________
Question 200:

Which return statement correctly returns the output?

A. public int cube(int x) { return (x + x) }
B. public int cube(int x) return (x + x)
C. public int cube(int x) { return x + x }
D. None of the mentioned
Answer: _________
Question 201:

What will be the output of the following C# code? namespace ConsoleApplication4
{
abstract class A
{
int i
public abstract void display()
}
class B: A
{
public int j
public override void display()
{
Console.WriteLine(j)
}
}
class Program
{
static void Main(string[] args)
{
B obj = new B()
obj.j = 2
obj.display()
Console.ReadLine()
}
}
}

A. 0
B. 2
C. Compile time error
D. 1
Answer: _________
Question 202:

What will be the output of the following C# code? class maths
{
static maths()
{
int s = 8
Console.WriteLine(s)
}
public maths(int f)
{
int h = 10
Console.WriteLine(h)
}
}
class Program
{
static void Main(string[] args)
{
maths p = new maths(0)
Console.ReadLine()
}
}

A. 10, 10
B. 0, 10
C. 8, 10
D. 8, 8
Answer: _________
Question 203:

What will be the output of the following C# code? enum days:int
{
sunday = -3,
monday,
tuesday
}
Console.WriteLine((int)days.sunday)
Console.WriteLine((int)days.monday)
Console.WriteLine((int)days.tuesday)

A. -3 0 1
B. 0 1 2
C. -3 -2 -1
D. sunday monday tuesday
Answer: _________
Question 204:

What will be the output of the following C# code? static void Main(string[] args)
{
int X = 6,Y = 2
X *= X / Y
Console.WriteLine(X)
Console.ReadLine()
}

A. 12
B. 6
C. 18
D. Compile time error
Answer: _________
Question 205:

What does the following C# code signify? class a
{



}
class b : a
{
variable declaration
method declaration
}

A. Declaration of a base class
B. Declaration of a subclass
C. Declaration of base class & subclass and how subclass inherits the base class
D. None of the mentioned
Answer: _________
Question 206:

What will be the Correct statement in the following C# code? interface abc
{
String FirstName
{
get
set
}
String LastName
{
get
set
}
void print()
void stock()
int fun()
}

A. Functions should be declared inside an interface
B. It is workable code
C. Properties cannot be declared inside an interface
D. None of the mentioned
Answer: _________
Question 207:

What will be the output of the following C# code? interface i1
{
void f1()
}
interface i2 :i1
{
void f2()
}
public class maths :i2
{
public void f2()
{
Console.WriteLine("fun2")
}
public void f1()
{
Console.WriteLine("fun1")
}
}
class Program
{
static Void Main()
{
maths m = new maths()
m.f1()
m.f2()
}
}

A. fun2
B. fun1
C. fun1 fun2
D. fun2 fun1
Answer: _________
Question 208:

What will be the output of the following C# code? namespace ConsoleApplication4
{
abstract class A
{
public int i
public abstract void display()
}
class B: A
{
public int j
public int sum
public override void display()
{
sum = i + j
Console.WriteLine(+i + "
" + +j)
Console.WriteLine("sum is:" +sum)
}
}
class Program
{
static void Main(string[] args)
{
A obj = new B()
obj.i = 2
B obj1 = new B()
obj1.j = 10
obj.display()
Console.ReadLine()
}
}
}

A. 2, 10 12
B. 0, 10 10
C. 2, 0 2
D. 0, 0 0
Answer: _________
Question 209:

What will be the output of the following C# code? class maths
{
public int length
public int breadth
public maths(int x, int y)
{
length = x
breadth = y
Console.WriteLine(x + y)
}
public maths(double x, int y)
{
length = (int)x
breadth = y
Console.WriteLine(x * y)
}
}
class Program
{
static void Main(string[] args)
{
maths m = new maths(20, 40)
maths k = new maths(12.0, 12)
Console.ReadLine()
}
}

A. 60, 24
B. 60, 0
C. 60, 144
D. 60, 144.0
Answer: _________
Question 210:

What will be the output of the following C# code? static void Main(string[] args)
{
int x = 4 ,b = 2
x -= b/= x * b
Console.WriteLine(x + " " + b)
Console.ReadLine()
}

A. 4 2
B. 0 4
C. 4 0
D. 2 2
Answer: _________
Question 211:

What will be the output of the following C# code? class z
{
public string name1
public string address
public void show()
{
Console.WriteLine("{0} is in city{1}", name1, " ", address)
}
}
class Program
{
static void Main(string[] args)
{
z n = new z()
n.name1 = "harsh"
n.address = "new delhi"
n.show()
Console.ReadLine()
}
}

A. Syntax error
B. {0} is in city{1} harsh new delhi
C. harsh is in new delhi
D. Run successfully prints nothing
Answer: _________
Question 212:

Which of the following is the correct result for the given statement in the C#.NET statement given below? p = q struct employee
{
private int employee id
private string city
}
employee q = new employee()
employee p
p = q

A. Elements of 'q' will be copied into corresponding elements of p
B. Address stored in q will get copied into p
C. Address of first element of q will get copied into p
D. Once assignment is over. q will go out of scope and hence get exited forever
Answer: _________
Question 213:

Select the statement which should be added to the current C# code to get the output as 10 20? class baseclass
{
protected int a = 20
}
class derived : baseclass
{
int a = 10
public void math()
{
/* add code here */
}
}

A. Console.writeline( a + " " + this.a)
B. Console.Writeline( mybase.a + " " + a)
C. console.writeline(a + " " + base.a)
D. console.writeline(base.a + " " + a)
Answer: _________
Question 214:

What will be the output of the following C# code? interface calc
{
void cal(int i)
}
class displayA :calc
{
public int x
public void cal(int i)
{
x = i * i
}
}
class displayB :calc
{
public int x
public void cal(int i)
{
x = i / i
}
}
class Program
{
public static void Main(string[] args)
{
displayA arr1 = new displayA()
displayB arr2 = new displayB()
arr1.x = 0
arr2.x = 0
arr1.cal(2)
arr2.cal(2)
Console.WriteLine(arr1.x + " " + arr2.x)
Console.ReadLine()
}
}

A. 0 0
B. 2 2
C. 4 1
D. 1 4
Answer: _________
Question 215:

What will be the output of the following C# code? class box
{
public int volume
int width
int height
int length
public box ( int w, int h, int l)
{
this.width = w
this.height = h
this.length = l
}
~ box()
{
volume = this.width * this.length * this.height
console.writeline(volume)
}
}
class Program
{
public static void Main(string[] args)
{
box b = new box(4, 5, 9)
Console.ReadLine()
}
}

A. 0
B. Code executes successfully but prints nothing
C. Compile time error
D. 180
Answer: _________
Question 216:

Correct way to define object of sample class in which C# code will work correctly is: class abc
{
int i
float k
public abc(int ii, float kk)
{
i = ii
k = kk
}
}

A. abc s1 = new abc(1)
B. abc s1 = new abc()
C. abc s2 = new abc(1.4f)
D. abc s2 = new abc(1, 1.4f)
Answer: _________
Question 217:

What will be the output of the following C# code? class maths
{
public int fun(int k, int y)
{
return k + y
}
public int fun1(int t, float z)
{
return (t+(int)z)
}
}
class Program
{
static void Main(string[] args)
{
maths obj = new maths()
int i
int b = 90
int c = 100
int d = 12
float l = 14.78f
i = obj.fun(b, c)
Console.WriteLine(i)
int j = (obj.fun1(d, l))
Console.WriteLine(j)
Console.ReadLine()
}
}

A. 190, 26.78f
B. 0, 26.78f
C. 190, 26
D. 190, 0
Answer: _________
Question 218:

What will be the output of the following C# code? static void Main(string[] args)
{
int i = 5
int j = 6
add(ref i)
add(6)
Console.WriteLine(i)
Console.ReadLine()
}
static void add(ref int x)
{
x = x * x
}
static void add(int x)
{
Console.WriteLine(x * x * x)
}

A. Compile time error
B. 25 0
C. 216 0
D. 216 25
Answer: _________
Question 219:

What will be the output of the following C# code? class sample
{
public int i
public int j
public void fun(int i, int j)
{
this.i = i
this.j = j
}
}
class Program
{
static void Main(string[] args)
{
sample s = new sample()
s.i = 1
s.j = 2
s.fun(s.i, s.j)
Console.WriteLine(s.i + " " + s.j)
Console.ReadLine()
}
}

A. Error while calling s.fun() due to inaccessible level
B. Error as 'this' reference would not be able to call 'i' and 'j'
C. 1 2
D. Runs successfully but prints nothing
Answer: _________
Question 220:

What will be size of the object created depicted by C# code snippet? 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()
}
}

A. 20 bytes
B. 12 bytes
C. 16 bytes
D. 24 bytes
Answer: _________
Question 221:

When a function fun() is to receive an int, a single & a double and it is to return a decimal, then the correct way of defining this C# function is?

A. static fun(int i, single j, double k) { return decimal }
B. static decimal fun(int i, single, double k) { }
C. decimal fun(int i, single j, double k) { }
D. decimal static fun(int i, single j, double k) { }
Answer: _________
Question 222:

Which of the following is the correct way to settle down values into the structure variable 'e' defined in the following C# code snippet? struct emp
{
public String name
public int age
public Single sal
}
emp e = new emp()

A. e.name = "Jone" e.age = 24 e.sal = 200
B. With emp e { .name = "Jone" .age = 24 .sal = 200 }
C. name = "Jone" age = 24 sal = 200
D. All of the mentioned
Answer: _________
Question 223:

What will be the output of the following C# code snippet? class maths
{
int fact(int n)
{
int result
if (n == 1)
return 1
result = fact(n - 1) * n
return result
}
}
class Output
{
static void main(String args[])
{
maths obj = new maths()
Console.WriteLine(obj.fact(4)*obj.fact(2))
}
}

A. 64
B. 60
C. 120
D. 48
Answer: _________
Question 224:

What will be the output of the following C# code? static void Main(string[] args)
{
Mul()
m()
Console.ReadLine()
}
static void Mul()
{
Console.WriteLine("4")
}
static void m()
{
Console.WriteLine("3")
Mul()
}

A. 4 3 3
B. 4 4 3
C. 4 3 4
D. 3 4 4
Answer: _________
Question 225:

What will be the output of the following C# code? {
struct abc
{
int i
}
class Program
{
static void Main(string[] args)
{
abc x = new abc()
abc z
x.i = 10
z = x
z.i = 15
console.Writeline(x.i + " " + y.i)
}
}
}

A. 10 10
B. 10 15
C. 15 10
D. 15 15
Answer: _________
Question 226:

What will be the output of the following C# code snippet? class maths
{
public int fact(int n)
{
int result
result = fact(n - 1) * n
return result
}
}
class Program
{
static void Main(string[] args)
{
maths obj = new maths()
Console.WriteLine(obj.fact(4))
Console.ReadLine()
}
}

A. 24
B. 30
C. Compile time error
D. Runtime Error
Answer: _________
Question 227:

What will be the output of the following C# code? namespace ConsoleApplication4
{
public abstract class A
{
public int i = 7
public abstract void display()
}
class B: A
{
public int j
public override void display()
{
Console.WriteLine(i)
Console.WriteLine(j)
}
}
class Program
{
static void Main(string[] args)
{
B obj = new B()
A obj1 = new B()
obj.j = 1
obj1.i = 8
obj.display()
Console.ReadLine()
}
}
}

A. 0, 8
B. 1, 8
C. 1, 7
D. 7, 1
Answer: _________
Question 228:

What does the following C# code imply? csharp abc
abc = new charp()

A. Object creation on class csharp
B. Create an object of type csharp on heap or on stack depending on the size of object
C. create a reference c on csharp and an object of type csharp on heap
D. create an object of type csharp on stack
Answer: _________
Question 229:

What will be the output of the following C# code? class A
{
public virtual void display()
{
Console.WriteLine("A")
}
}
class B: A
{
public override void display()
{
Console.WriteLine(" B ")
}
}
class Program
{
static void Main(string[] args)
{
A obj1 = new A()
B obj2 = new B()
A r
r = obj1
r.display()
r = obj2
r.display()
Console.ReadLine()
}
}

A. A, A
B. B, B
C. Compile time error
D. A, B
Answer: _________
Question 230:

Correct way of declaration of object of the following class is? class name

A. name n = new name()
B. n = name()
C. name n = name()
D. n = new name()
Answer: _________
Question 231:

Select the sequence of execution of function f1(), f2() & f3() in C# .NET CODE? 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 ()
}
}

A. f1() of derived class get executed f2() of derived class get executed f3() of base class get executed
B. f1() of base class get executed f2() of derived class get executed f3() of base class get executed
C. f1() of base class get executed f2() of derived class get executed f3() of derived class get executed
D. f1() of derived class get executed f2() of base class get executed f3() of base class get executed
Answer: _________
Question 232:

The following C# code is run on single level of inheritance. What will be the Correct statement in the following C# code? 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()
}
}

A. 10, 20, 30 base method
B. 10, 20, 0
C. compile time error
D. base method
Answer: _________
Question 233:

What will be the output of the following C# code? public static void Main(string[] args)
{
p()
void p()
{
Console.WriteLine("hi")
}
}

A. Compile time error
B. hi
C. hi infinite times
D. None of the mentioned
Answer: _________
Question 234:

What will be the output of the following C# code? static void Main(string[] args)
{
m()
Console.ReadLine()
}
static void m()
{
Console.WriteLine("HI")
m()
}

A. HI HI HI
B. HI
C. Stack overflow exception
D. Compile time error
Answer: _________
Question 235:

What will be the Correct statement of the following C# code? public class maths
{
public int x
public virtual void a()
{
}
}
public class subject : maths
{
new public void a()
{
}
}

A. The subject class version of a() method gets called using sample class reference which holds subject class object
B. subject class hides a() method of base class
C. The code replaces the subject class version of a() with its math class version
D. None of the mentioned
Answer: _________
Question 236:

What will be the output of the following C# code? {
struct abc
{
public int i
}
class Program
{
static void Main(string[] args)
{
sample a = new sample()
a.i = 10
fun(ref a)
Console.WriteLine(a.i)
}
public static voidn fun(ref sample x)
{
x.i = 20
Console.WriteLine(x.i)
}
}
}

A. 10 10
B. 20 10
C. 10 20
D. 20 20
Answer: _________
Question 237:

What will be the output of the following C# code? class maths
{
int fact(int n)
{
int result
if (n == 1)
return 1
result = fact(n - 1) * n
return result
}
}
class Output
{
static void main(String args[])
{
maths obj = new maths()
Console.WriteLine(obj.fact(1))
}
}

A. 2
B. 10
C. 1
D. 0
Answer: _________
Question 238:

What will be the Correct statement in the following C# code? interface a1
{
void f1()
void f2()
}
class a :a1
{
private int i
void a1.f1()
{
}
}

A. Class a could not have an instance data
B. Class a is an abstract class
C. Class a fully implements the interface a1
D. None of the mentioned
Answer: _________

Answer Key

1: D
2: A
3: C
4: D
5: C
6: B
7: C
8: C
9: D
10: C
11: A
12: B
13: D
14: D
15: B
16: C
17: B
18: D
19: D
20: B
21: B
22: C
23: C
24: C
25: C
26: C
27: A
28: A
29: D
30: B
31: B
32: C
33: D
34: C
35: C
36: A
37: C
38: B
39: D
40: A
41: B
42: C
43: C
44: A
45: D
46: C
47: B
48: C
49: D
50: D
51: A
52: D
53: C
54: B
55: D
56: C
57: C
58: B
59: D
60: B
61: B
62: D
63: D
64: A
65: D
66: D
67: D
68: C
69: C
70: D
71: B
72: C
73: D
74: A
75: D
76: B
77: C
78: B
79: B
80: C
81: C
82: D
83: B
84: A
85: B
86: D
87: D
88: C
89: C
90: D
91: C
92: B
93: A
94: C
95: C
96: C
97: D
98: C
99: C
100: D
101: C
102: B
103: C
104: C
105: B
106: C
107: C
108: C
109: D
110: D
111: B
112: D
113: C
114: B
115: D
116: A
117: A
118: D
119: C
120: B
121: A
122: C
123: A
124: A
125: A
126: C
127: B
128: A
129: C
130: A
131: D
132: C
133: D
134: B
135: C
136: D
137: A
138: D
139: C
140: C
141: D
142: D
143: C
144: D
145: B
146: C
147: C
148: C
149: D
150: C
151: C
152: C
153: D
154: B
155: D
156: B
157: C
158: C
159: C
160: D
161: C
162: C
163: A
164: A
165: D
166: D
167: C
168: C
169: D
170: C
171: D
172: C
173: C
174: D
175: B
176: D
177: D
178: C
179: D
180: C
181: C
182: D
183: D
184: D
185: C
186: C
187: A
188: B
189: C
190: B
191: D
192: D
193: A
194: A
195: B
196: A
197: D
198: C
199: C
200: A
201: B
202: C
203: C
204: C
205: C
206: B
207: C
208: C
209: C
210: C
211: C
212: A
213: C
214: C
215: D
216: D
217: C
218: D
219: C
220: D
221: B
222: A
223: D
224: C
225: B
226: D
227: D
228: C
229: D
230: A
231: B
232: C
233: A
234: C
235: D
236: D
237: C
238: B