wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Miestone-2

Total questions: 130

Worksheet time: 2hrs 10mins

Name
Class
Date
1.

What is the main motivation for using collection classes in C#?

a)

To reduce the size of arrays

b)

To provide flexible, dynamically resizing data structures

c)

To avoid using objects

d)

To enhance memory usage

2.

Which namespace contains nongeneric collections in C#?

a)

System.Generic

b)

System.Collections.Generic

c)

System.Collections

d)

System.Data

3.

What is the key disadvantage of nongeneric collections?

a)

They are type-safe

b)

They perform better than generic collections

c)

They operate on `System.Object` types, leading to type safety issues

d)

They require complex syntax

4.

Which of the following is an example of a generic collection?

a)

ArrayList

b)

Queue

c)

List

d)

Stack

5.

Why are generic collections preferred over nongeneric collections?

a)

They provide better type safety and performance by avoiding boxing and unboxing

b)

They allow any data type to be used without casting

c)

They only work with primitive data types

d)

They can store only objects

6.

What does the `ArrayList` collection in C# represent?

a)

A generic collection for fixed-size arrays

b)

A nongeneric collection that can hold different data types

c)

A stack-based collection

d)

A queue-based collection

7.

Which of the following is NOT a generic collection class in C#?

a)

List

b)

Dictionary

c)

ArrayList

d)

Stack

8.

What is the main purpose of the `List` class in C#?

a)

To store fixed-size data

b)

To provide a dynamically resizable collection of elements with type safety

c)

To represent a first-in, first-out (FIFO) collection

d)

To store key-value pairs

9.

Which method is used to add an item to a `List`?

a)

AddItem()

b)

Insert()

c)

Add()

d)

Enqueue()

10.

What is the primary difference between `Stack` and `Queue`?

a)

`Stack` is first-in, first-out (FIFO), while `Queue` is last-in, first-out (LIFO)

b)

`Stack` is last-in, first-out (LIFO), while `Queue` is first-in, first-out (FIFO)

c)

`Stack` stores only objects, while `Queue` stores primitives

d)

`Queue` is always sorted, but `Stack` is not

11.

Which method is used to retrieve and remove the first item in a `Queue`?

a)

Dequeue()

b)

Pop()

c)

Remove()

d)

Peek()

12.

What does the `Peek()` method do in a `Stack`?

a)

Removes the last element in the stack

b)

Returns the top element without removing it

c)

Adds a new element to the stack

d)

Clears all elements from the stack

13.

Which class is used to store key-value pairs in C#?

a)

List

b)

Dictionary

c)

Queue

d)

Stack

14.

What happens if you try to access a key that does not exist in a `Dictionary`?

a)

A default value is returned

b)

A compile-time error occurs

c)

An `ArgumentNullException` is thrown

d)

A `KeyNotFoundException` is thrown

15.

Which of the following collections is sorted by the key?

a)

Stack

b)

Queue

c)

Dictionary

d)

SortedSet

16.

What is the primary advantage of using a `SortedSet` over a `List`?

a)

It automatically sorts the elements

b)

It allows duplicate elements

c)

It provides faster access to elements by index

d)

It uses less memory

17.

How can you convert a `List` to an array in C#?

a)

`ToArray()`

b)

`ToList()`

c)

`Convert()`

d)

`ToCollection()`

18.

Which of the following is a problem associated with nongeneric collections?

a)

Lack of type safety and poor performance due to boxing and unboxing

b)

Inability to store objects

c)

They can only store one data type

d)

They are faster than generic collections

19.

What is the result of calling `Pop()` on an empty `Stack`?

a)

The stack is reset

b)

A `NullReferenceException` is thrown

c)

A `KeyNotFoundException` is thrown

d)

An `InvalidOperationException` is thrown

20.

Which collection class would be best for managing a list of unique items that need to be sorted automatically?

a)

Stack

b)

List

c)

Dictionary

d)

SortedSet

21.

What will be the output of the following code?

SortedList sortedlist=new SortedList()

{{2,True},

{1,"one"}};

foreach(DirectoryEntry de in sortedlist)

Console.Write(de.value);

a)

Compile-time Error

b)

Runtime Error

c)

12

d)

One true

22.

Which of the following is FIFO(First In FirstOut) Collection?

a)

Queue

b)

Stack

c)

ArrayList

d)

SortedList

23.

What will be the Output of the following code?

int[ , ] x=new int[ 3,2 ];

Console.WriteLine(x.Length);

a)

3

b)

6

c)

5

d)

7

24.

hich statement is correct in the following C#.NET code snippet?

  1. Stack st = new Stack();

  2. st.Push("Csharp");

  3. st.Push(7.3);

  4. st.Push(8);

  5. st.Push('b');

  6. st.Push(true);




a)

a) Unsimilar elements like “Csharp”, 7.3, 8 cannot be stored in the same stack collection

b)

b) Boolean values can never be stored in Stack collection

c)

c) Perfectly workable code

d)

d) All of the mentioned

25.

Among the given collections which one is I/O index based?



a)

a) ArrayList

b)

b) List

c)

c) Stack

d)

d) Queue

26.

A HashTable t maintains a collection of names of states and capital city of each state. Which among the following finds out whether “New delhi” state is present in the collection or not?

a)

a)

t.HasValue("New delhi");

b)

b)

t.ContainsKey("New delhi");

c)

c)

t.HasKey("New delhi");

d)

d)

t.ContainsValue("New delhi");

27.

Which statement is correct about the C#.NET code snippet given below?

  1. Stack st = new Stack();

  2. st.Push("Csharp");

  3. st.Push(7.3);

  4. st.Push(8);

  5. st.Push('b');

  6. st.Push(true);

a)

a) Unsimilar elements like “Csharp”,7.3,8 cannot be stored in the same stack collection.


b)

b) Boolean values can never be stored in Stack collection

c)

c) Perfectly workable code

d)

d) All of the mentioned

28.

What will be the output of the following code snippet when it is executed?
int x = 1;
float y = 1.1f;
short z = 1;
Console.Write.Line((float) x + y * z - (x += (short) y));

a)

0.1

b)

1.0

c)

1.1

d)

11

29.

Which of the following is the correct output for the C#.NET code snippet given below?

Console.WriteLine(13 / 2 + " " + 13 % 2);

a)

A) 6.5 1

b)

B) 6.5 0

c)

C) 6 0

d)

D) 6 1

30.

Which among the following is the correct way to access all the elements of the Stack collection created using the C#.NET code snippet given below?

  1. Stack st = new Stack();

  2. st.Push(10);

  3. st.Push(20);

  4. st.Push(-5);

  5. st.Push(30);

  6. st.Push(6);

a)

IEnumerable e; e = st.GetEnumerator(); while (e.MoveNext()) Console.WriteLine(e.Current);

b)

IEnumerator e; e = st.GetEnumerator(); while(e.MoveNext()) Console.WriteLine(e.Current);

c)

IEnumerable e; e = st.GetEnumerable(); while(e.MoveNext()) Console.WriteLine(e.Current);

d)

None of the mentioned

31.
Which of these is NOT a Sort algorithm
a)
Binary
b)
Merge
c)
Bubble
d)
Insertion
32.
Which type of sort algorithm is this?
a)
Bubble
b)
Merge
c)
Insertion
d)

Quick

33.
Using a binary search why will the number 9 never be found in the following list:
11, 8, 13, 9, 7, 3
a)
It does not work on numbers
b)
It only works on letters
c)
The list is not in order
d)

There are even numbers

34.
Which type of sort algorithm is this?
a)
Insertion
b)
Merge
c)
Bubble
d)

Quick

35.
Which sorting algorithm places each number into the right place one after the other until all are in the right place.
a)
Insertion
b)
Bubble
c)

Merge

d)

Quick

36.

Which of these algorithms compares consecutive pairs of items and swaps two items if they're not in order?

a)

Bubble sort

b)

Linear search

c)

Merge sort

d)

Binary search

37.

Which of these algorithms sorts items by first splitting the list of items down into smaller and smaller groups?

a)

Bubble sort

b)

Merge sort

c)

Linear search

d)

Binary search

38.

What algorithm does this image represent?

a)

Bubble sort

b)

Merge sort

c)

Linear search

d)

Binary search

39.
The following lists represent 3 passes of a sorting algorithm. Which algorithm is being used to sort the list?
 
4    5    9    6    2    7

4    5    6    2    7    9 
4    5    2    6    7    9
a)
Bubble Sort
b)
Selection Sort
c)
Insertion Sort
d)

Quick

40.

How many searches will it take to find 10 in [1,3,5,7,10,12,15] using BINARY search?

a)

3

b)

4

c)

5

d)

6

41.
How many passes will an insertion sort go through?
a)
Only one pass
b)
Two passes
c)
Several passes - until the data is fully ordered
d)

N-1 passes always

42.

Choose a CORRECT statement about pivot in quick sort method.

a)

A pivot divides the list evenly.

b)

A pivot can be chosen randomly.

c)

A pivot is chosen by using a fixed formula

d)

A pivot makes the searching method becomes slow

43.

Identify the INCORRECT statement about searching


i. Binary search starts by testing the largest data

ii. Linear search can be done for unsorted data only

iii. Linear search starts by testing data at the middle of list

iv. Binary search can be done for sorted homogeneous data

a)

i, ii and iii

b)

ii, iii and iv

c)

i, iii and iv

d)

i, ii, iii and iv

44.

Suppose a list is {2, 9, 5, 4, 8, 1}. After the first phase of bubble sort, the list becomes …

a)

2, 9, 5, 4, 8, 1

b)

2, 9, 5, 4, 1, 8

c)

2, 5, 9, 4, 8, 1

d)

2, 5, 4, 8, 1, 9

45.

Given a list is {7, 4, 5, 9, 8, 2, 1}. After the first phase of selection sort, the list becomes …

a)

1,2,4,9,8,5,7

b)

1,2,5,9,8,4,7

c)

1,4,5,9,8,2,7

d)

7,4,5,9,8,2,1

46.

If the number of records to be sorted is small, identify the suitable sorting to be used

a)

Quick sort

b)

Merge sort

c)

Selection sort

d)

Bubble sort

47.

The worst case occurs in linear search algorithm when ______________________

a)

Item is not in the array at all

b)

Item is somewhere in the middle of the array

c)

Item is the last element in the array or item is not there at all

d)

Item is the last element in the array

48.

Suppose we are sorting an array of eight integers using quick sort, and we have just finished the first partitioning with the array looking like this:

2 5 1 7 9 12 11 10

Identify the correct statement?

a)

Neither the 7 nor the 9 is the pivot.

b)

The pivot could be either the 7 or the 9.

c)

The pivot is not the 7, but it could be the 9.

d)

The pivot could be the 7, but it is not the 9.

49.

Which of the following is NOT a stable sorting algorithm in its typical implementation.

a)

Insertion sort

b)

Bubble sort

c)

Merge sort

d)

Quick sort

50.

You have to sort 1 GB of data with only 100 MB of available main memory. Which sorting technique will be most appropriate?

a)

Heap Sort

b)

Merge Sort

c)

Quick Sort

d)

All of the above

51.

Goal of unit testing is to ensure

(a)  

52.

Unit is

a)

a single cohesive function

b)

Can be compiled separately

c)

a task in WorkBenchStructure

d)

a one page code

53.

Tasks for the preparation of UNIT test

a)

Planning the approach for unit testing

b)

Establish relationships between the tests

c)

Preparation of the auxiliary code for unit test.

d)

Design the program code

54.

Drivers are

a)

functions that call the target code

b)

function that calls itself recursively

c)

function that calls the C:// drive

d)

function that call all drives

55.

Unit test designing specify

a)

test case

b)

test suite

c)

test plan

d)

test procedure

56.

Causes of Failure should be recorded in

(a)  

57.

Test Results are recorded using

(a)  

58.

Unit tested by an independent user

a)

private unit test

b)

public unit test

c)

protected unit test

d)

independent unit test

59.

Test hareness is

a)

auxiliary code for design

b)

auxiliary code for plan

c)

auxiliary code for coding

d)

auxiliary code for testing

60.

Stubs are

a)

modules called by target unit

b)

modules that call the target code

61.

Choose the namespace which consists of classes that are part of .NET Reflection API?

a)

System.Text

b)

System.Name

c)

System.Reflection

d)

None of the mentioned

62.

Consider you need to write a code to create a file named "filename.txt" and write some content to it. Which code snippet will you use to perform this task without any errors? Analyze the given choices and select the correct option.

a)

string writeText = "Hello World!";

File.WriteAllText("filename.txt", writeText);

string readText = File.ReadAllText("filename.txt");

Console.WriteLine(readText);

b)

string writeText : "Hello World!";

File.WriteAllText("filename.txt", writeText);

string readText : File.ReadAllText("filename.txt");

Console.WriteLine(readText);

c)

string writeText = "Hello World!";

File.WriteText("filename.txt", writeText);

string readText = File.ReadText("filename.txt");

Console.Write(readText);

d)

File.WriteAllText("filename.txt", writeText);

string readText = File.ReadAllText("filename.txt");

Console.WriteLine(readText);

63.

The FileName property retrieves the name of a file selected

a)

True

b)

False

64.

A layered application may have a front end to handle the presentation and a ______________ to execute the business logic.

a)

Objects

b)

Database

c)

Front End

d)

Back End

65.

In NUnit What does "Assert" do?

a)

Initialize objects and set the value of the data that is passed to method being tested.

b)

Invokes the methods being tested

c)

Verifies that the methods being tested behave as expected

d)

None of the above

66.

In NUnit what does "Act" does?

a)

Initialize objects and set the value of the data that is passed to method being tested.

b)

Invokes the methods being tested.

c)

Verifies that the methods being tested behave as expected.

d)

All of the above

67.

Which of the following is not a type of software testing?

a)

System Testing

b)

Unit Testing

c)

Liver Function Test

d)

None of the above

68.

What is a Reflection?

a)

Reflection is the ability of inspecting an assembly metadata at runtime.

b)

Reflection is the ability of inspecting a method metadata at runtime.

c)

Reflection is the ability of inspecting any metadata at runtime.

d)

All of the above

69.

Select the namespace on which the stream classes are defined?

b)

System.Input

c)

System.Output

d)

All of the mentioned

70.

DirectoryInfo Class is used for?

a)

Manipulate a file.

b)

Getting random access with data represented as a stream of bytes.

c)

Provides detailed info regarding the drives of the manchine.

d)

support the manipulation of the system directory structure.

71.

How many kinds of RAID are there

a)

4

b)

5

c)

6

d)

7

72.

Mirroring is which kind of RAID

a)

RAID 0

b)

RAID 1

c)

RAID 2

d)

RAID 3

73.

Reason for Mirroring Databse

a)

Back up of the DB

b)

Running the Copy of the DB simultaniously

c)

To avoid slowness

d)

Provide ExraSecurity

74.

Advantages of Mirroring DB

a)

Quick access of the DB

b)

Less DownTime

c)

Automatic Failover

d)

All of the Above

75.

The back up that we take before Mirroring

a)

Full Backup

b)

Differential Backup

c)

Transactional Log Backup

d)

All of the Above

76.

If there are 2 Differential backup, a) taken on 4th

Sept and b) bckup taken on 8th Sept. Which bckup file will be considered for

"Restore"

a)

4th Sept

b)

8th Sept

c)

Both Backup

d)

None

77.

There are 3 Transaction Log Backup files take on

10th Sept, 14th Sept and 16th Sept. Which Backup files will be taken into account for Restoration

a)

16th Sept

b)

10th Sept

c)

14th Sept

d)

All of the Above

78.

Which of the Codd rule is associated with the

statement that changes in the data storage should not affect programs that access the data?

a)

Information Rule

b)

Comprehensive Sub Language

c)

Physical Data Independence Rule

d)

Distribution Rule

79.

The table emp has 56 records. This value

corresponds to which of the following term?

a)

Relation

b)

Degree

c)

Cardinality

d)

Domain

80.

Main editions of SQL server

a)

Entp Edition

b)

Standard Edition

c)

Business Intelligence Edition

d)

All of the above

81.

EXPAND : RDBMS

(a)  

82.

Row in a Table pointed as

a)

Field

b)

Record

83.

Column in a Table pointed as

a)

Field

b)

Record

84.

Expand : DDL

(a)  

85.

Expand : DML

(a)  

86.

Expand : TCL

(a)  

87.

With SQL, how do you select all the records from a table named "Persons" where the value of the column "FirstName" is "Peter"?

a)

SELECT [all] FROM Persons WHERE FirstName LIKE 'Peter'

b)

SELECT * FROM Persons WHERE FirstName like 'Peter'

c)

SELECT * FROM Persons WHERE FirstName<>'Peter'

d)

SELECT * FROM Persons WHERE FirstName<>'Peter'

e)

SELECT * FROM Persons WHERE FirstName=='Peter'

88.
With SQL, how can you insert a new record into the "Persons" table?
a)
INSERT INTO Persons VALUES ('Jimmy', 'Jackson')  
b)
INSERT ('Jimmy', 'Jackson') INTO Persons
c)
INSERT VALUES ('Jimmy', 'Jackson') INTO Persons
d)
INSERT VALUES ('Jimmy, Jackson') INTO Persons
e)
INSERT ('Jimmy', 'Jackson') VALUES into Persons
89.

Which one of the following sorts rows in SQL?

a)

SORT BY

b)

ALIGN BY

c)

ORDER BY

d)

GROUP BY

e)

SORT

90.

Select DDL commands from among the options...

a)

SELECT

b)

ALTER

c)

DROP

d)

DELETE

91.

The DROP TABLE statement:

a)

deletes the table structure only.

b)

deletes the table structure along with the table data.

c)

works whether or not referential integrity constraints would be violated.

d)

is not an SQL statement.

e)

deletes the data only.

92.

The primary key of a table which is present in another table for referencing is known as (a)  

93.

The command which changes the structure of a table is (a)  

94.

An (a)   is the secondary candidate key that contains all the property of a candidate key but is an alternate option

95.

Which constraint(s) can be used to make sure that the column is not left empty?

a)

NOT NULL

b)

UNIQUE

c)

PRIMARY KEY

d)

ALL THE ABOVE

96.
What are these?
a)
Fields
b)
Properties
c)
Classes
d)
Constructors
97.
How do you make a UserAccount object?
a)
UserAccount s1 = new UserAccount();
b)
UserAccount s1 = new UserAccount;
c)
UserAccount = new UserAccount();
d)
int s1 = new UserAccount();
98.
What type of class is Shape?
a)
Sub class
b)
Static
c)
Polymorphic
d)
Abstract
99.
Can you make an object from an abstract class?
a)
Yes
b)
No
100.
What word do you use for a method in an abstract class?
a)
Override
b)
Void
c)
Virtual
d)
Abstract
101.
What word do you use in a sub class method that uses an abstract class?
a)
Override
b)
Virtual
c)
Void
d)
Abstract
102.
What does the dotted line mean?
a)
Inherits abstract class
b)
Uses class
c)
Is my daddy
d)
Polymorphism
103.
What does this method return?
a)
Nothing
b)
Hello
c)
string
d)
int
104.

Which of the following is NOT an example of an Abstract Data Type?

a)

Stack

b)

Queue

c)

int

d)

Linked List

105.

An Abstract Data Type is mainly defined in terms of:

a)

Implementation details

b)

User-defined behavior (operations)

c)

Compiler directives

d)

Memory structure

106.

Which of the following about local classes is correct?

a)

They can access static variables of the function

b)

They cannot have static data members

c)

They cannot define methods

d)

They cannot create objects

107.

If a global object is created, when is its constructor executed?

a)

Before main() starts

b)

Just before its first use

c)

After main() finishes

d)

When explicitly called

108.

A local object created inside a block is destroyed:

a)

Immediately after its use

b)

At the end of the block

c)

Only when program exits

d)

Never destroyed automatically

109.

Which of the following represents the identity of an object?

a)

Memory location / reference

b)

Data values

c)

Member functions

d)

Constructor

110.

The behavior of an object is defined by:

a)

Its methods (functions)

b)

Its class name

c)

Its attributes

d)

Its constructor

111.

Which of the following is the correct use of the scope resolution operator?

a)

To call private members of a class directly

b)

To define a function outside the class

c)

To access global variables when local variables exist

d)

Both b and c

112.

Which of the following is FALSE about constructors?

a)

They have the same name as the class

b)

They can be overloaded

c)

They can return values

d)

They are automatically invoked at object creation

113.

If an object is created globally, its destructor is called:

a)

Immediately when main() exits

b)

After main() exits

c)

Before main() starts

d)

Never

114.

Which constructor is invoked in the following code? class Test { int x; public: Test(int i) { x = i; } }; int main() { Test t(5); }

a)

Default constructor

b)

Copy constructor

c)

Parameterized constructor

d)

Dynamic constructor

115.

Which constructor is invoked here? class Demo { public: Demo() {} Demo(Demo &d;) {} }; int main() { Demo d1; Demo d2(d1); }

a)

Default constructor only

b)

Copy constructor only

c)

Both default and copy constructor

d)

Error

116.

Static data members of a class are initialized:

a)

Inside the class definition

b)

In the constructor

c)

Outside the class using scope resolution operator

d)

Automatically by compiler

117.

Which statement is TRUE?

a)

Each object gets its own copy of static data

b)

Static data is shared among all objects

c)

Static data members must be public

d)

Static data members cannot be used in functions

118.

If a class has a constructor with parameters only, creating an array of objects requires:

a)

Default constructor

b)

Overloading new operator

c)

Initialization list at declaration

d)

Destructor

119.

Consider: class Student { int roll; public: Student(int r) { roll = r; } }; Student arr[3] = { Student(1), Student(2), Student(3) }; What does this show?

a)

Array of objects using parameterized constructor

b)

Use of static members

c)

Default constructor

d)

Local class usage

120.

Which of the following declarations is correct for a constant member function?

a)

void display() constant;

b)

void display() const;

c)

const void display();

d)

void const display();

121.

What is the purpose of an indexer in C#?

a)

To sort arrays

b)

To access elements in a class using array-like syntax

c)

To create loops

d)

To define multiple constructors

122.

Which keyword is used to define an indexer in a class?

a)

index

b)

getset

c)

this

d)

setget

123.

What is operator overloading used for?

a)

Changing the memory allocation

b)

Redefining how operators work for custom types

c)

Adding new methods to an object

d)

Creating anonymous types

124.

Which operator is being overloaded in this method: public static Point operator +(Point a, Point b)?

a)

-

b)

*

c)

/

d)

+

125.

What type of structure is a 'struct' in C# considered?

a)

Class

b)

Method

c)

Custom Value Type

d)

Interface

126.

Which one of the following is a correct example of defining a struct in C#?

a)

structure Book { }

b)

class Book { }

c)

struct Book { }

d)

public Book() { }

127.

What are extension methods?

a)

Methods that extend runtime memory

b)

Methods added to existing types without modifying their source

c)

Methods inside interfaces

d)

Generic methods

128.

Extension methods must be declared in which type of class?

a)

Sealed class

b)

Partial class

c)

Static class

d)

Abstract class

129.

Which keyword must be used to allow pointer operations in C#?

a)

fixed

b)

unsafe

c)

pointer

d)

raw

130.

Anonymous types are usually used when...

a)

You want to use pointers

b)

You need temporary read-only objects without a class

c)

You want to use operator overloading

d)

You are using extension methods