WorksheetsMiestone-2
Total questions: 130
Worksheet time: 2hrs 10mins
What is the main motivation for using collection classes in C#?
To reduce the size of arrays
To provide flexible, dynamically resizing data structures
To avoid using objects
To enhance memory usage
Which namespace contains nongeneric collections in C#?
System.Generic
System.Collections.Generic
System.Collections
System.Data
What is the key disadvantage of nongeneric collections?
They are type-safe
They perform better than generic collections
They operate on `System.Object` types, leading to type safety issues
They require complex syntax
Which of the following is an example of a generic collection?
ArrayList
Queue
List
Stack
Why are generic collections preferred over nongeneric collections?
They provide better type safety and performance by avoiding boxing and unboxing
They allow any data type to be used without casting
They only work with primitive data types
They can store only objects
What does the `ArrayList` collection in C# represent?
A generic collection for fixed-size arrays
A nongeneric collection that can hold different data types
A stack-based collection
A queue-based collection
Which of the following is NOT a generic collection class in C#?
List
Dictionary
ArrayList
Stack
What is the main purpose of the `List` class in C#?
To store fixed-size data
To provide a dynamically resizable collection of elements with type safety
To represent a first-in, first-out (FIFO) collection
To store key-value pairs
Which method is used to add an item to a `List`?
AddItem()
Insert()
Add()
Enqueue()
What is the primary difference between `Stack` and `Queue`?
`Stack` is first-in, first-out (FIFO), while `Queue` is last-in, first-out (LIFO)
`Stack` is last-in, first-out (LIFO), while `Queue` is first-in, first-out (FIFO)
`Stack` stores only objects, while `Queue` stores primitives
`Queue` is always sorted, but `Stack` is not
Which method is used to retrieve and remove the first item in a `Queue`?
Dequeue()
Pop()
Remove()
Peek()
What does the `Peek()` method do in a `Stack`?
Removes the last element in the stack
Returns the top element without removing it
Adds a new element to the stack
Clears all elements from the stack
Which class is used to store key-value pairs in C#?
List
Dictionary
Queue
Stack
What happens if you try to access a key that does not exist in a `Dictionary`?
A default value is returned
A compile-time error occurs
An `ArgumentNullException` is thrown
A `KeyNotFoundException` is thrown
Which of the following collections is sorted by the key?
Stack
Queue
Dictionary
SortedSet
What is the primary advantage of using a `SortedSet` over a `List`?
It automatically sorts the elements
It allows duplicate elements
It provides faster access to elements by index
It uses less memory
How can you convert a `List` to an array in C#?
`ToArray()`
`ToList()`
`Convert()`
`ToCollection()`
Which of the following is a problem associated with nongeneric collections?
Lack of type safety and poor performance due to boxing and unboxing
Inability to store objects
They can only store one data type
They are faster than generic collections
What is the result of calling `Pop()` on an empty `Stack`?
The stack is reset
A `NullReferenceException` is thrown
A `KeyNotFoundException` is thrown
An `InvalidOperationException` is thrown
Which collection class would be best for managing a list of unique items that need to be sorted automatically?
Stack
List
Dictionary
SortedSet
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);
Compile-time Error
Runtime Error
12
One true
Which of the following is FIFO(First In FirstOut) Collection?
Queue
Stack
ArrayList
SortedList
What will be the Output of the following code?
int[ , ] x=new int[ 3,2 ];
Console.WriteLine(x.Length);
3
6
5
7
hich statement is correct in the following C#.NET code snippet?
Stack st = new Stack();
st.Push("Csharp");
st.Push(7.3);
st.Push(8);
st.Push('b');
st.Push(true);
a) Unsimilar elements like “Csharp”, 7.3, 8 cannot be stored in the same stack collection
b) Boolean values can never be stored in Stack collection
c) Perfectly workable code
d) All of the mentioned
Among the given collections which one is I/O index based?
a) ArrayList
b) List
c) Stack
d) Queue
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)
t.HasValue("New delhi");
b)
t.ContainsKey("New delhi");
c)
t.HasKey("New delhi");
d)
t.ContainsValue("New delhi");
Which statement is correct about the C#.NET code snippet given below?
Stack st = new Stack();
st.Push("Csharp");
st.Push(7.3);
st.Push(8);
st.Push('b');
st.Push(true);
a) Unsimilar elements like “Csharp”,7.3,8 cannot be stored in the same stack collection.
b) Boolean values can never be stored in Stack collection
c) Perfectly workable code
d) All of the mentioned
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));
0.1
1.0
1.1
11
Which of the following is the correct output for the C#.NET code snippet given below?
Console.WriteLine(13 / 2 + " " + 13 % 2);
A) 6.5 1
B) 6.5 0
C) 6 0
D) 6 1
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?
Stack st = new Stack();
st.Push(10);
st.Push(20);
st.Push(-5);
st.Push(30);
st.Push(6);
IEnumerable e; e = st.GetEnumerator(); while (e.MoveNext()) Console.WriteLine(e.Current);
IEnumerator e; e = st.GetEnumerator(); while(e.MoveNext()) Console.WriteLine(e.Current);
IEnumerable e; e = st.GetEnumerable(); while(e.MoveNext()) Console.WriteLine(e.Current);
None of the mentioned
Quick
11, 8, 13, 9, 7, 3
There are even numbers
Quick
Merge
Quick
Which of these algorithms compares consecutive pairs of items and swaps two items if they're not in order?
Bubble sort
Linear search
Merge sort
Binary search
Which of these algorithms sorts items by first splitting the list of items down into smaller and smaller groups?
Bubble sort
Merge sort
Linear search
Binary search
What algorithm does this image represent?
Bubble sort
Merge sort
Linear search
Binary search
4 5 9 6 2 7
4 5 6 2 7 9
4 5 2 6 7 9
Quick
How many searches will it take to find 10 in [1,3,5,7,10,12,15] using BINARY search?
3
4
5
6
N-1 passes always
Choose a CORRECT statement about pivot in quick sort method.
A pivot divides the list evenly.
A pivot can be chosen randomly.
A pivot is chosen by using a fixed formula
A pivot makes the searching method becomes slow
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
i, ii and iii
ii, iii and iv
i, iii and iv
i, ii, iii and iv
Suppose a list is {2, 9, 5, 4, 8, 1}. After the first phase of bubble sort, the list becomes …
2, 9, 5, 4, 8, 1
2, 9, 5, 4, 1, 8
2, 5, 9, 4, 8, 1
2, 5, 4, 8, 1, 9
Given a list is {7, 4, 5, 9, 8, 2, 1}. After the first phase of selection sort, the list becomes …
1,2,4,9,8,5,7
1,2,5,9,8,4,7
1,4,5,9,8,2,7
7,4,5,9,8,2,1
If the number of records to be sorted is small, identify the suitable sorting to be used
Quick sort
Merge sort
Selection sort
Bubble sort
The worst case occurs in linear search algorithm when ______________________
Item is not in the array at all
Item is somewhere in the middle of the array
Item is the last element in the array or item is not there at all
Item is the last element in the array
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?
Neither the 7 nor the 9 is the pivot.
The pivot could be either the 7 or the 9.
The pivot is not the 7, but it could be the 9.
The pivot could be the 7, but it is not the 9.
Which of the following is NOT a stable sorting algorithm in its typical implementation.
Insertion sort
Bubble sort
Merge sort
Quick sort
You have to sort 1 GB of data with only 100 MB of available main memory. Which sorting technique will be most appropriate?
Heap Sort
Merge Sort
Quick Sort
All of the above
Goal of unit testing is to ensure
(a)
Unit is
a single cohesive function
Can be compiled separately
a task in WorkBenchStructure
a one page code
Tasks for the preparation of UNIT test
Planning the approach for unit testing
Establish relationships between the tests
Preparation of the auxiliary code for unit test.
Design the program code
Drivers are
functions that call the target code
function that calls itself recursively
function that calls the C:// drive
function that call all drives
Unit test designing specify
test case
test suite
test plan
test procedure
Causes of Failure should be recorded in
(a)
Test Results are recorded using
(a)
Unit tested by an independent user
private unit test
public unit test
protected unit test
independent unit test
Test hareness is
auxiliary code for design
auxiliary code for plan
auxiliary code for coding
auxiliary code for testing
Stubs are
modules called by target unit
modules that call the target code
Choose the namespace which consists of classes that are part of .NET Reflection API?
System.Text
System.Name
System.Reflection
None of the mentioned
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.
string writeText = "Hello World!";
File.WriteAllText("filename.txt", writeText);
string readText = File.ReadAllText("filename.txt");
Console.WriteLine(readText);
string writeText : "Hello World!";
File.WriteAllText("filename.txt", writeText);
string readText : File.ReadAllText("filename.txt");
Console.WriteLine(readText);
string writeText = "Hello World!";
File.WriteText("filename.txt", writeText);
string readText = File.ReadText("filename.txt");
Console.Write(readText);
File.WriteAllText("filename.txt", writeText);
string readText = File.ReadAllText("filename.txt");
Console.WriteLine(readText);
The FileName property retrieves the name of a file selected
True
False
A layered application may have a front end to handle the presentation and a ______________ to execute the business logic.
Objects
Database
Front End
Back End
In NUnit What does "Assert" do?
Initialize objects and set the value of the data that is passed to method being tested.
Invokes the methods being tested
Verifies that the methods being tested behave as expected
None of the above
In NUnit what does "Act" does?
Initialize objects and set the value of the data that is passed to method being tested.
Invokes the methods being tested.
Verifies that the methods being tested behave as expected.
All of the above
Which of the following is not a type of software testing?
System Testing
Unit Testing
Liver Function Test
None of the above
What is a Reflection?
Reflection is the ability of inspecting an assembly metadata at runtime.
Reflection is the ability of inspecting a method metadata at runtime.
Reflection is the ability of inspecting any metadata at runtime.
All of the above
Select the namespace on which the stream classes are defined?
DirectoryInfo Class is used for?
Manipulate a file.
Getting random access with data represented as a stream of bytes.
Provides detailed info regarding the drives of the manchine.
support the manipulation of the system directory structure.
How many kinds of RAID are there
4
5
6
7
Mirroring is which kind of RAID
RAID 0
RAID 1
RAID 2
RAID 3
Reason for Mirroring Databse
Back up of the DB
Running the Copy of the DB simultaniously
To avoid slowness
Provide ExraSecurity
Advantages of Mirroring DB
Quick access of the DB
Less DownTime
Automatic Failover
All of the Above
The back up that we take before Mirroring
Full Backup
Differential Backup
Transactional Log Backup
All of the Above
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"
4th Sept
8th Sept
Both Backup
None
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
16th Sept
10th Sept
14th Sept
All of the Above
Which of the Codd rule is associated with the
statement that changes in the data storage should not affect programs that access the data?
Information Rule
Comprehensive Sub Language
Physical Data Independence Rule
Distribution Rule
The table emp has 56 records. This value
corresponds to which of the following term?
Relation
Degree
Cardinality
Domain
Main editions of SQL server
Entp Edition
Standard Edition
Business Intelligence Edition
All of the above
EXPAND : RDBMS
(a)
Row in a Table pointed as
Field
Record
Column in a Table pointed as
Field
Record
Expand : DDL
(a)
Expand : DML
(a)
Expand : TCL
(a)
With SQL, how do you select all the records from a table named "Persons" where the value of the column "FirstName" is "Peter"?
SELECT [all] FROM Persons WHERE FirstName LIKE 'Peter'
SELECT * FROM Persons WHERE FirstName like 'Peter'
SELECT * FROM Persons WHERE FirstName<>'Peter'
SELECT * FROM Persons WHERE FirstName<>'Peter'
SELECT * FROM Persons WHERE FirstName=='Peter'
Which one of the following sorts rows in SQL?
SORT BY
ALIGN BY
ORDER BY
GROUP BY
SORT
Select DDL commands from among the options...
SELECT
ALTER
DROP
DELETE
The DROP TABLE statement:
deletes the table structure only.
deletes the table structure along with the table data.
works whether or not referential integrity constraints would be violated.
is not an SQL statement.
deletes the data only.
The primary key of a table which is present in another table for referencing is known as (a)
The command which changes the structure of a table is (a)
An (a) is the secondary candidate key that contains all the property of a candidate key but is an alternate option
Which constraint(s) can be used to make sure that the column is not left empty?
NOT NULL
UNIQUE
PRIMARY KEY
ALL THE ABOVE
Which of the following is NOT an example of an Abstract Data Type?
Stack
Queue
int
Linked List
An Abstract Data Type is mainly defined in terms of:
Implementation details
User-defined behavior (operations)
Compiler directives
Memory structure
Which of the following about local classes is correct?
They can access static variables of the function
They cannot have static data members
They cannot define methods
They cannot create objects
If a global object is created, when is its constructor executed?
Before main() starts
Just before its first use
After main() finishes
When explicitly called
A local object created inside a block is destroyed:
Immediately after its use
At the end of the block
Only when program exits
Never destroyed automatically
Which of the following represents the identity of an object?
Memory location / reference
Data values
Member functions
Constructor
The behavior of an object is defined by:
Its methods (functions)
Its class name
Its attributes
Its constructor
Which of the following is the correct use of the scope resolution operator?
To call private members of a class directly
To define a function outside the class
To access global variables when local variables exist
Both b and c
Which of the following is FALSE about constructors?
They have the same name as the class
They can be overloaded
They can return values
They are automatically invoked at object creation
If an object is created globally, its destructor is called:
Immediately when main() exits
After main() exits
Before main() starts
Never
Which constructor is invoked in the following code? class Test { int x; public: Test(int i) { x = i; } }; int main() { Test t(5); }
Default constructor
Copy constructor
Parameterized constructor
Dynamic constructor
Which constructor is invoked here? class Demo { public: Demo() {} Demo(Demo &d;) {} }; int main() { Demo d1; Demo d2(d1); }
Default constructor only
Copy constructor only
Both default and copy constructor
Error
Static data members of a class are initialized:
Inside the class definition
In the constructor
Outside the class using scope resolution operator
Automatically by compiler
Which statement is TRUE?
Each object gets its own copy of static data
Static data is shared among all objects
Static data members must be public
Static data members cannot be used in functions
If a class has a constructor with parameters only, creating an array of objects requires:
Default constructor
Overloading new operator
Initialization list at declaration
Destructor
Consider: class Student { int roll; public: Student(int r) { roll = r; } }; Student arr[3] = { Student(1), Student(2), Student(3) }; What does this show?
Array of objects using parameterized constructor
Use of static members
Default constructor
Local class usage
Which of the following declarations is correct for a constant member function?
void display() constant;
void display() const;
const void display();
void const display();
What is the purpose of an indexer in C#?
To sort arrays
To access elements in a class using array-like syntax
To create loops
To define multiple constructors
Which keyword is used to define an indexer in a class?
index
getset
this
setget
What is operator overloading used for?
Changing the memory allocation
Redefining how operators work for custom types
Adding new methods to an object
Creating anonymous types
Which operator is being overloaded in this method: public static Point operator +(Point a, Point b)?
-
*
/
+
What type of structure is a 'struct' in C# considered?
Class
Method
Custom Value Type
Interface
Which one of the following is a correct example of defining a struct in C#?
structure Book { }
class Book { }
struct Book { }
public Book() { }
What are extension methods?
Methods that extend runtime memory
Methods added to existing types without modifying their source
Methods inside interfaces
Generic methods
Extension methods must be declared in which type of class?
Sealed class
Partial class
Static class
Abstract class
Which keyword must be used to allow pointer operations in C#?
fixed
unsafe
pointer
raw
Anonymous types are usually used when...
You want to use pointers
You need temporary read-only objects without a class
You want to use operator overloading
You are using extension methods
