You are on page 1of 15

An indexer can be declared inside a namespace or a method.

Parameters passed as out parameters has to be initialized before passing them to a method.

To catch any possible exception, we can use a catch block that omit the parameters data
type and just write catch.

All binary operators can be overloaded in C#.

Static functions of a class never receive this reference.

When calling an instance member method, we are not required to pass the this reference
explicitly to it.

Data members of an interface are by default public.

Indexers cannot be overloaded, and there are should be no more than one indexer in the
class.

A static constructor is executed after an instance constructor.

Static constructor can be used to initialize instance variables.

An instance object of a class can have more than one object reference.

Static members can be accessed/invoked inside instance methods.

Method overloading represents a simple form of polymorphism known as type


polymorphism.

To invoke any method, we must pass to it a fixed number of parameters.

Code in a finally block is executed even if an exception is thrown.

Indexers are always instance members; hence, an indexer cannot be declared static.

In C#, all objects are created from classes and passed to methods by reference.

A class can have one or more constructors.

Classes can be instantiated without a new operator.

A class is reference type.

An abstract class must have at least one abstract method.

A sealed class must have at least one sealed method.

In a(an) _________ relationship, an object of a derived class also can be treated as an object
of its base class.

Encapsulation

Polymorphism

Inheritance

Interface

Derived class constructors can call base-class constructors via _________


Base reference

this reference

parent reference

sub reference

________ is the default access specifier of a class member.

Private

Public

Protected

All mentioned

_______ is the process of hiding the implementation details of an object.

Encapsulation

Polymorphism

Inheritance

Interface

To pass an instance of the current object to a certain method to process it, we pass the
______ to this method.

The class's name

This reference

The indexer

None of mentioned

Method ________ is considered as a compile time polymorphism.

Overloading

Overriding

Overloading and overriding

None of all

Subtype polymorphism is considered as _______ polymorphism.

Compile-time

Run-time

Analysis-time

None of all

Object-oriented way of handling run-time errors is called _______


OnError Events

Exception handling

Error codes

None of all

_______ are blueprint or templates which are used to create objects, where these objects
can be passed by reference to methods.

Classes

Interfaces

Structures

All mentioned

Defining a variable using _______ access modifier enables using it from other classes.

Private

Public

Protected

All mentioned

In OOP, _______ enables the reuse of the properties and methods of preexisting classes.
With the ability to add and modify them.

Encapsulation

Polymorphism

Inheritance

Interface

______ assume the ability to use the same method name with different implementations in
the same class, but with different method signature.

Method overloading

Method overriding

Polymorphism

Abstraction

A(an) _______ class is a class that cannot be instantiated.

Sealed

Override

Abstract
Closed

The ______ keyword is used to change the data and behavior inherited from a base class by
replacing a suitable member of a base class with the new derived member.

New

Base

Overloads

Override

OOP languages provide the ad-hoc polymorphism using _______

Method overloading

Method overriding

Polymorphism

Abstraction

A(an) constructor is a constructor with no arguments ; and if no constructor are written in


the base class then, the compiler creates one of it.

Interfaces can have declaration of ______

Virtual method

Doubl Properties i(,ii,iii);

Methods only

Properties

_____ are inheireted from class from the a parent class .

Private

Publc

Protected all mentioned

IN C#,

In C#, all classes and inehreited by default fro m the class_______

System.class

Sysem.Object

System

System.failure

To be able to create objects of a class from another class, its constructor has to be declared
as ______

Public
Private

Protected

All mentioned

All objects created in C# are passed to methods by value.

A class can not have more than one indexer.

In C#, instance variables can be accessed rom both instance methods and static methods.

We have to declare a class as abstract when at least one of the methods in the class is
virtual.

It is possible to override private virtual methods.

A static property can be declared inside satic method.

Static members can be accessed using class name rather than through a particular object.

A class can have both public and private abstract methods.

All unary operators can be overloaded.

Static variables can be used without creating an object of the class.

Static indexers cannot access instance variables.

The type of anobject reference can be of ________ only.

Its class

Its class or parent class

Its parent class

None of all

A derived class can stop virtual inheritance by declaring an veeride as

Stop

Sealed

Closed

Override

An indexer does not have a name. In place of the name is the keyword _______ and its
parameter are declared between square brackets, and there must be at least one parameter
declaration in the parameter list.

Indexer

this

index

none
__________ is an event that causes suspension of normal application execution.

Error code

Exception

Exception handler

None of all

In OOP, the use of inheritance supports the ______ polymorphism as inherited classes can
be seen as instance of itself or of its parent classes.

Ad-hoc

Parametric

Subtype

None of all

Static members obviously don’t have access to the _____ object reference.

this

base

this and base

none of all

In OOP, objects are characterized by _______

Identity

Behavior

State

All mentioned

_______ is the OOP concept for packaging the code and data in to a single unit to protect
data.

Encapsulation

Polymorphism

Inheritance

Interface

_______ parameters can be passed to methods without initialization.

ref

out

value

none of all
_______ is the base class for any type of exception class in C# exception types.

Handler.Exception

System.Exception

System.Error

None of all

A reference type _______ can be used as a reference to any object in C#.

System.Interface

System.Class

System.Object

None

For the following code segment:


1. class Emp {
2. public static int n=0; double salary; public double tax;
3. public Emp() { salary=double.Parse(Console.ReadLine()); tax=double.Parse(Console.ReadLine()); n++;}
4. public Emp(double s, double t) { salary=s; tax=t; n++;}
5. public double Net { get{return salary-tax;}}
6. public void Print() { Console.WriteLine("{0}:{1}", salary, Net); }
7. public static void Compare(Emp p1, Emp p2)
8. { if(p1.Net> p2.Net) Console.WriteLine("First is greater"); else Console.WriteLine("Second is greater"); }
9. public int Compare(Emp p) { if(this.Net > p.Net) return 1; elseif (this.Net < p.Net) return -1; else return 0;}
10. public static bool operator==(Emp p1, Emp p2) { return (p1.salary==p2.salary); }
11. public static bool operator!=(Emp p1, Emp p2) { return (p1.salary!=p2.salary); }
12. }

13. class Program {


14. static void Main() {
15. Emp p1=new Emp(); p1.Print();
16. Emp p2=new Emp(1000, 0.2); p2.Print();
17. Console.WriteLine(Emp.n);
18. Emp.Compare(p1, p2);
19. }
20. }

1. In line#15, suppose the user enter 1000 and 200 for the values of salary and tax respectively. The output of the
executing Line#15 will be ________
 1000:200
 1000:800
 800:200
 Other
2. After executing Line#16, the output will be ______
 1000:0.2
 1000:800
 1000:999.8
 Other
3. After executing Line#17, the output will be ______
 2
 1
 0
 Other
4. If we replace the statement that resides in Line#17 with Console.WriteLine(p2.n); the output will be _______
 2
 1
 0
 Other
5. After executing Line#18, the output will be ______
 First is greater
 Second is greater
 Equals
 Other
6. If we replace the statement that resides in Line#18 with Console.WriteLine(p1.Compare(p2)); the output will be
_______
 1
 -1
 0
 Other
7. If we replace the statement that resides in Line#18 with Console.WriteLine(p1==p2); the output will be _______
 1
 0
 true
 false
8. If we add the following statement inside Main method p2.salary=2000, p2.tax=5000; the statement p2.Print() will
display ________
 2000:500
 1500:500
 2000:1500
 Other
9. If we add the following statement inside Main method Emp.salary=2000, p2.tax=5000; the statement p2.Print()
will display ________
 2000:500
 1500:500
 2000:1500
 Other
For the following code segment:
1. namespace CApplication
2. {
3. class Sample
4. {
5. int i;
6. int j;
7. public void SetData(int i, int j)
8. {
9. i = i;
10. j = j;
11. }
12. public void Display()
13. {
14. Console.WriteLine(i + " " + j);
15. }
16. }
17. class MyProgram
18. {
19. static void Main()
20. {
21. Sample s1 = new Sample();
22. s1.SetData(10, 5);
23. s1.Display();
24. }
25. }
26. }

The correct output for the given code is ______

00

10 5

0 10

5 10

If we change Line#9 to be this.i=i; the correct output for the given code will be _____

00

10 5

0 10

5 10

If we change Line#9 to be i=this.i; the correct output for the given code will be _____

00

10 5

0 10
5 10

1. Array elements can be of integer type only. (F)


2. The length of an Array is the number of dimensions in the Array. (F)
3. C# allows a function to have variable number of arguments. (T)
4. Omitting the return value type in method definition results into an exception. (F)
5. params is used to specify the syntax for a function with variable number of arguments.
(T)
6. An argument passed to a ref parameter need not be initialized first. (F)
7. Variables passed as out arguments need to be initialized prior to being passed. (F)
8. The signature of an indexer consists of the number and types of its formal parameters. (T)
9. Indexers are similar to properties except that their accessors take parameters. (T)
10. The type of an indexer and the type of its parameters must be at least as accessible as
the indexer itself. (T)
11. Indexer allow to index class, struct and interface the same ways as an array (T)
12. Unary operators such as true, false and + can be overloaded. (T)
13. It is not necessary that all operator overloads are static methods of the class. (F)
14. All operators in C#.NET can be overloaded. (F)
15. Operator overloading permits the use of symbols to represent computations for a
type.(T)
16. The conditional logical operators cannot be overloaded.(T)
17. Properties can be declared inside an interface. (T)
18. All types of exceptions can be caught using the Exception class. (T)
19. For every try block there must be a corresponding finally block. (F)
20. A class can have one destructor only (T)
21. Destructors can have modifiers or parameters. (F)
22. A property can be a static member whereas an indexer is always an instance member (T)
23. It is an error for indexer to declare a local variable with the same name as indexer
parameters (T)
24. An explicitly implemented member could be accessed from an instance of the interface
(T)
25. "Boxing" is the process of converting a value type to the reference type and "Unboxing"
is the process of converting reference to value type (T)
26. "Boxing" is the process of converting a reference type to value type and "Unboxing" is
the process of converting value type to reference type (F)
27. In "Boxing" we need explicit conversion and in "Unboxing" we need implicit conversion
(F)
28. Memory allocated to "Value type" is from heap and reference type is from "System.
ValueType" (F)
Memory allocated to "Value type" is from "System. ValueType" and reference
type is from "Heap" (T)

1. Declare a class member as --- ----, means that this member is available to classes that are
within the same assembly and derived from specified base class.
2. ---- ----- means having two or more methods with the same name but with different
signature.
3. Try{}… catch{} .. construct can be used to …… ….
4. --- ---, --- - and -- ---- are the three primary characteristics of OOP.
5. In OOP, methods, properties, constructors declared with --- --- access modifier get
access or visible only to all members of classes and projects.
6. In OOP, --- ---- are considered instances of -- ----.
7. The … …. Keyword is used to create instances of the class.
8. In OOP, --- -----,--- ---,--- --- are three characteristics of each object.
9. -- --- are blueprints of templates which are used to create objects.
10. In C#, objects created from classes are passed to methods by -----------, while primitive
data types are passed by ----------
11. –--------- class is at the top of .NET hierarchy, so it is a parent of all C# classes.
12. A ---------- class-level variable is only available to any sub-class derived from base class.
13. We can sort the elements of the array in descending order by calling the ------------
method and then the ------------ method from the System.Array class.
14. -------------- is the representation of only the essential features of an object and hiding
unessential features of an object.
15. ---------------- is the OOP technique for packaging the code and data into a single unit to
protect the data from the outside world.
16. ------------ is the characteristic of being able to assign a different meaning specifically, to
allow an entity such as a variable, a function, or an object to have more than one form.
17. In OOP, ------------- are considered instances of -------------, where a ------------ defines
properties and behavior for multiple instantiations.
18. In OOP, both data and operations on data are brought together into a single entity
called --------------.
19. -------------------is the process of creating an object whose implementation details are
hidden, however the object is used through a well-defined interface.
20. In OOP, ------------- enables the reuse of the properties and methods of preexisting
classes. With the ability to add and modify them.
21. -- -- of a certain class is a constructor that receives a single argument; this argument is a
reference of an object of this class.
22. OOP languages provide the ad-hoc polymorphism using -- --.
23. In C#, all object inherits from the –------ class, and all arrays inherit from the –------- class.
24. Object of references are created in the –---- memory, while their references are created
in the –------- memory.
25. We use the method -------- to get the number of rows in a 2-dimensional array object.
26. Defining a variable using –------- access modifier enables using it from other classes.
27. A write-only property has only -- -- block in its definition.

28. In C#, objects created from classes are passed to methods by reference, while primitive
data types are passed by value
29. –Object-- class is at the top of .NET hierarchy, so it is a parent of all C# classes.
30. A protected class-level variable is only available to any sub-class derived from base class.
31. The keyword Sealed can be used to prevent a class from being inherited.
32. A(n) abstract class is a class that cannot be instantiated.
33. A(n) Interface is essentially a blueprint for a class without any implementation.
34. Abstraction is the representation of only the essential features of an object and hiding
unessential features of an object.
35. Encapsulation is the OOP technique for packaging the code and data into a single unit
to protect the data from the outside world.
36. Polymorphism is the characteristic of being able to assign a different meaning
specifically, to allow an entity such as a variable, a function, or an object to have more
than one form.
37. Interfaces are definitions of operations applicable externally to an object.
38. The --abstract--- class cannot be used to create objects, while --sealed-- class cannot be
inherited.
39. Data Abstraction is the process of creating an object whose implementation details are
hidden, however the object is used through a well-defined interface.
40. --ADT(abstract data type)-- are objects whose implementations is encapsulated.
41. In OOP, --Inheritance-- enables the reuse of the properties and methods of preexisting
classes. With the ability to add and modify them.
42. The three common forms of polymorphism in OOP are –subtype--, --Ad-hoc-- and –
Parametric-- Polymorphism.
43. --Ad-hoc-- polymorphism assume the ability to use the same methods name with
different implementations in the same class, but with different method signatures.
44. –Parametric-- polymorphism allow classes and methods to accept types as parameters.
45. Subtype polymorphism is considered as --Run time-- polymorphism.
46. –Inheritance-- can be considered as away to establish IS-A relationship between objects.
47. --late/dynamic binding-- means that the caller may not know the exact type of the
called object before calling the method, i.e. the behavior is determined at run time
instead of design time.
48. OOP languages provide the ad-hoc polymorphism using --Method overloading--.
49. Object of references are created in the –Heap-- memory, while their references are
created in the –Stack-- memory.

The exception classes in C# are mainly directly or indirectly derived from the?

A. System.Exception class
B. Exception class
C. System.ApplicationException class
D. ApplicationException class

5. The ________________ class is the base class for all predefined system exception

A. System.ApplicationException
B. System.SystemException
C. System.IO.IOException
D. System.IndexOutOfRangeException

A. finally clause is used to perform cleanup operations of closing network and database
connections
B. a program can contain multiple finally clauses
C. the statement in final clause will get executed no matter whether an exception occurs or
not

Exceptions can be thrown even from a constructor, whereas error codes cannot be
returned from a constructor. [T]

User-defined exceptions can be created.

A try block must be associated with at least one catch or finally block.

Try block can be nested.

C) A program cannot contain multiple finally clauses.

finally clause is used to perform cleanup operations of closing network and database
connections

What will be the output of the given code snippet?

What will be the output of given code snippet?


A
b. B
c. Compile time error
d. Runtime error

You might also like