Professional Documents
Culture Documents
1.21
1) Which of the following is not a class?
a. A Ford Ikon car with the registration number XXXX
b. Fruit
c. Mammal
d. Fish
2) Which method displays the message “”Hello People” on the screen?
a. Console.WriteLine(“Hello People”);
b. System.WriteLine(“Hello People”);
c. Console(“Hello People”);
d. Console.writeline(“Hello People”);
3) Console is a .
a. Namespace
b. Class
c. Function
d. Escape sequence character
4) In a C# program, which is the first function to be executed?
a. Main()
b. main()
c. Console.WriteLine()
d. Void Accept_bike_Details()
5) Which of the following is used to denote a newline character?
a. \b
b. \n
c. \v
d. /n
2.14
6) In the statement, using System, System is a .
a. Namespace
b. Class
c. Object
d. Keyword
7) Which of the following is not an example of value type?
a. char
b. int
c. float
d. string
8) The compiler is used for c#.
a. cc
b. csc
c. c++
d. cs
9) The statement //Hello world in a c# program:
a. Displays the text Hello world on the screen
b. Is not executed by the compiler and will be treated as a comment
c. Declares a variable Hello world
d. Causes all code lines following it to be treated as comments
10) In which of the following datatype does the Console.Readline() function accept a
value?
a. int
b. float
c. bool
d. string
3.26
11) Consider the following code:
if (character == 'X')
Console.WriteLine("The characters is X");
else
Console.WriteLine("The character is not X");
Console.ReadLine();
}
Note: The Convert.ToChar() converts a value to the char datatype.
b. FileStream fs = new
FileStream("c:\\MyFile.txt",FileMode.CreateNew,
FileAccess.Write);
d. FileStream fs = new
FileStream("c:\\MyFile.txt",FileMode.OpenOrCreate,
FileAccess.Write);
43) The method that is used to alter the positions from where a read or write operation
can occur is . SeekOrigin
44) Match the following terms in column B to the description in Column A.
A B
45) John wants to perform a read/write operation on a file. He does not want the file to be
overwritten when he is performing the write operation. Which FileMode should he
use? Append
10.17
46) The base class of all exceptions is . System.Exception
47) The set of statements the need to be executed whether an exeption is thrown or not
thrown is included in the block. finally
48) Can a try block have more than one catch handler? Yes
49) State whether the following statement is true or false:
A try block ensures that an exception is handled. false
50) An attempt to divide by zero throws the exception.
System.DivideByZeroException
11.35
51) Which of the following is true about the ‘not runnable’ state of a thread?
a. A sleeping thread enters the ‘ not runnable’ state when the specified time has
elapsed.
b. A thread is in a ‘ not runnable’ state if it is dead.
c. When the Start() method is invoked. the thread enters the ‘not runable’ state.
d. When a thread is blocked by another thread. it enters the ‘not runnable’ state.
52) You need to create a spreadsheet application with automatic recalculation facility.
Which of the following statements is/are true with respect to the required application?
A. The application should be multithreaded.
B. A thread object has to be created for performing automatic recalculation.
C. The thread taking care of automatic recalculation should have the highest
a. A only
b. A. B. C
c. B. C
d. A. B
53) Which class is used to construct and access individual threads in a multithreaded
application?
a. System.Thread
b. System.Threading
c. System.Thread. Threading
d. System.Threading.Thread
54) You are creating an application, using the concept of multithreading, in which you
can play audio files and watch animated images at the same time. Which of the
following methods should be invoked for a thread to enter the runnable state?
a. start()
b. sleep()
c. Run()
d. Resume()
55) You are developing a multithreaded application. Which of the following will you use
to make a thread. animThread. enter the non-runnable state?
a. Thread animThread = new Thread(this);
b. animThread. Sleep(2000);
c. animThread. Resume();
d. animThread. Start();
12.19
56) Identify the correct statement about delegates.
a. Before you declare an event inside a class, you can optionally declare a delegate
by using the delegate keyword.
b. The delegate type consists of the set of arguments that it receives from the method
that handles the event.
c. Multiple events cannot share the same delegate.
d. By using a single-cast delegate, you can invoke only one method corresponding to
different events.
57) Which of the following code is correct to assign more than one method address to
a delegate?
a. Delegatevariable = new MyDelegate(Function1)
Delegatevariable += new MyDelegate(Function2)
b. Delegatevariable = MyDelegate(Function1);
Delegatevariable += MyDelegate(Function2);
c. Delegatevariable = new MyDelegate(Function1);
Delegatevariable += new MyDelegate(Function1 +Function2);
d. Delegatevariable = new MyDelegate(Function1);
Delegatevariable += new MyDelegate(Function2);
58) State whether the given statement is true or false.
A publisher is an object that contains the definition of the event and the delegate. false
59) Match the following delegate concepts with there implementation
Column A Column B
2.15
205) Which of the following option holds true for CLR?
A. It provides only memory allocation service.
B. It allows the execution of code across different platforms
C. It translates the code into Intermediate Language.
D. It consists of a set of common rules followed by all the languages of .NET
206) What happens during JIT compiletion?
A. Management allocation and deallocation of memory
B. Conversion of intermedia language into machine language.
C. Loading assemblies in the memory.
D. Identification of namespace in the assemblies
207) What happens during garbage collection?
A. Management of allocation and deallocation of memory
B. Conversion of intermedia language into machine language.
C. Loading assemblies in the memory.
D. Identification of namespace in the assemblies
208) Which of the following does NOT holds true for namespace?
A. They are single deployable units that contain all the information about the
implementation of classes, structures, and interfaces.
B. They are logical groups of related and interfaces.
C. Thay avoid any naming conflict between alasses, which have the same names.
D. They enable you to access the classes belonging to a namespace by simply
importing the namespace into the application.
209) Which of the following iis NOT a feature of the .NET framework?
A. Consistent programing model
B. Multi language intergration
C. Manual resource amanegement
D. Ease of deployment
2.16
210) Which of the following access specifiers allows a class to hide its member
variables and member functions from other class objects and function?
A. private
B. protected
C. internal
D. protected internal
211) Which of the following access specifiers allows a class to hide its member
variables and member functions from other class objects and function, except the
child class?
A. private
B. protected
C. internal
D. protected internal
212) Which of the following is the default access specifier for a class?
A. private
B. protected
C. internal
D. protected internal
213) Which of the following is NOT a parameter passing mechanism?
A. values
B. InputOutput
C. Reference
D. Output
214) Which of the following statement is NOT true ragarding the Output parameter?
A. The variable that is supplied for the output parameter need to be assigned a valu
before the call is made
B. Output parameter is a reference to a storage location subplied by the caller
C. Output parameters transfer data out of the method
D. Output paremeters can be used to return more than one value
215) Name of the feature of OOPs, which involves extracting only the relevant
information
A. Abstraction
B. Encapsulation
C. Inheritance
D. Polymorphism
216) Name the element of a method. which determines the extent to which a variable
or method can be accessed from another class?
A. Method name
B. Paremeter list
C. Method body
D. Access specifier
217) Name the element of a method. which needs to be unique and is case-sensitive?
A. Method name
B. Paremeter list
C. Method body
D. Access specifier
218) Name the element of a method. which contains the set of instructions needed to
complete the required activity?
A. Method name
B. Paremeter list
C. Method body
D. Access specifier
219) Identify the correct syntax for defining a method?
A. <Access specifier> <Return Type> <Method Name> (Parameter List)
B. <Access specifier> <Method Name> <Return Type> (Parameter List)
C. <Access specifier> (Parameter List) <Return Type> <Method Name>
D. <Return Type> <Method Name> (Parameter List)
3.15
220) John has to write code in C# in which he needs to implement a search operation
to search the details of a student on the basic of his/her roll number. Which of the
following class of the System.Collection namespace would be the most appropriate to
enable John to accomplish this task?
A. Hashtable
B. ArrayList
C. Queue
D. Stack
221) Which of the following is a correct syntax to initialize an array in C#?
A. int[ ] Score = new int[10];
B. int[10] Score = new int[ ];
C. int[10] Score = new int[10];
D. int[10] Score = new int[ ];
222) Henry is assigned the responsibility of writing a program to handle the booking
of tickets in a movie theatre. He needs to ensure that the request that came first for
booking tickets should be processed first before the next request. Which of the
following class of the System.Collection namespace would enable Henry to
accomplish this task?
A. Hashtable
B. ArrayList
C. Queue
D. Stack
223) Consider the following code snippet:
class Test
{
int a. b;
string str;
Test()
{
Console.WriteLine("Hello");
}
Test(int i)
{
a = i;
}
Test(int i, string s)
{
a = i;
str = s;
}
Test(string s)
{
str = s;
}
}
}
How will you initialize class, Test, if you just want to display “Hello” on the screen?
A. Test obj = new Test();
B. Test obj = new Test(17);
C. Test obj = new Test(17,”Hello”);
D. Test obj = new Test(“Hello”);
224) Which of the following holds true for the Finalize() method?
A. CLR calls the Finalize() destructor using a system called reference-tracing
garbage collection
B. The Idisposable interface constains the Finalize() method
C. The Finalize() destructor is called before the last reference to an object is released
from memory
D. The .NET Framwork cannot automatically call the Finalize() destructor to destroy
objects in memory
3.17
225) Which of the following statements is NOT true about constructor?
A. A constructor is used to initilize members of the class
B. A constructor is complementary to a destructor
C. A constructor is invoked when a new instance of a class is created
D. A constructor needs to be called explicitly
226) Which of the following statements is true about static constructors?
A. Static constructors are called whenever an instance of a class is created.
B. Static constructors have implicit private access
C. Static constructors are used to initialize all the variable of a class
D. The static keyword is optional while declaring a static constructor.
227) Which of the following statements is NOT true about destructors?
A. Destructors are used to release the instance of a class from memory
B. A programmer has no control on when to call the destructor
C. Destructors can be overloaded
D. A destructor has the same name as its class, but is prefixed with a~.
228) Which of the following statements is NOT true about function overloading?
A. The number of arguments and their types could be the same, but the return type
should be diffrent?
B. The number of arguments and their types could be the same, but thier sequence
C. The number of aguments or thier types must be different
D. The function must have the same name
229) Which of the following operators CANNOT be overloaded?
A. =
B. ++
C. -
D. +
230) Identify the correct syntax for creating an object?
A. Calculator c1 = new Calculator();
B. Calculator c1 = new Calculator;
C. Calculator c1 = new calculator();
D. calculator c1 = new Calculator();
231) Identify the correct syntax for creating a destructor for a class named Calculator
A. Calculator()
B. ~Calculator()
C. Calculator
D. ~Calculator
232) You need a function that converts distance in kilometers to miles, and kilometers
can either be an integer or a float. Which OOPs concept would you use?
A. Inhertance
B. Polymorphism
C. Encapsulation
D. Data Hiding
233) Identify the operator that takes two operands
A. ~
B. ++
C. --
D. +
234) Identify the operator that can be overload
A. =
B. ?:
C. .
D. ==
4.11
235) Consider a class, Student, which consists of different attributes and behaviors.
What will be the relationship between a student, John, and the class, Student?
A. Instantiation
B. Utilization relationship
C. Inheritance relationship
D. Composition relationship
236) Consider a class, Cat, Lions, Tigers, and Leopards belong to the cat family.
Identify the relationship between Cat and Lion.
A. Instantiation
B. Utilization relationship
C. Inheritance relationship
D. Composition relationship
237) Consider two classes, CPU and motherboard. Identify the relationship between
the two?
A. Instantiation
B. Utilization relationship
C. Inheritance relationship
D. Composition relationship
238) 4. Consider the following program:
class A
{
public A()
{
Console.WriteLine("Inside A");
}
}
class B : A
{
public B()
{
Console.WriteLine("Inside B");
}
}
class C : B
{
public C()
{
Console.WriteLine("Inside C");
}
public static void Main()
{
C obj = new C();
}
}
Identify the output of the program:
A. Inside A
Inside B
Inside C
B. Inside B
Inside A
Inside C
C. Inside C
Inside B
Inside A
D. Inside C
239) Consider the following program:
class A
{
public A()
{
Console.WriteLine("Welcome");
}
public A(string str1)
{
Console.WriteLine(str1);
}
public A(string str2)
{
Console.WriteLine(str2);
}
public static void Main()
{
A obj = new A("John");
}
}
Identify the output of the program
A. Welcome
John
B. John
Welcome
C. The code will give an error
D. John
4.13
240) Which namespace needs to be used for file handing?
A. System.Text
B. System.Generic
C. System.IO
D. System
241) Which member of the FileMode enumerator is used to open a file and then
delete its contents?
A. Create
B. CreateNew
C. Append
D. Truncate
242) Which member of the FileMode enumerator is used to open a file and add the
contents at the end?
A. Create
B. CreateNew
C. Append
D. Truncate
243) Which of the following is NOT a member of the FileAccess enumerator?
A. read
B. Write
C. ReadWrite
D. WriteRead
244) Identify the class that is used to write binary data to a stream
A. BinaryReader
B. BinaryWriter
C. StreamReaader
D. StreamWriter
245) Which access specifier allows a class to expose its member variables and
member function ro another function and objects?
A. private
B. internal
C. protected internal
D. friend
246) Which of the following code snippet is syntactically correct according to the
rules appliced for declaring the prefix and postfix notations for operator overloading?
A. internal static over operator++ (over X) { }
B. static static over operator++ (over X) { }
C. private static over operator++ (over X) { }
D. public static over operator++ (over X) { }
247) Constructor overloading is an approach to implement:
A. Inheriance
B. Abstraction
C. Static polymorphism
D. Dynamic polymorphism
248) Which of the following is not true about abstract classes?
A. cannot create an instance of an abstract class
B. Cannot declared an abstract method outside an abstract class
C. Cannot be declared sealed
D. Cannot be declared public
249) Identify the operator that cannot be overload
A. ?:
B. ==
C. !=
D. %
5.11
250) John is using the StreamWriter class in a program. He needs to write any
buffered data to the underlying stream. Which method of the StreamWriter class
should John use?
a. Flush
b. Close
c. Write
d. WriteLine
251) Mary needs to write code in C# that displays the names of all the files within
a specified directory. Identify the correct code snipper that would enable Mary to
accomplish this task.
a. DirectoryInfo MydirInfo = new DirectoryInfo(@”c:\WINDOWS”);
FileInfo FilesInDir = MydirInfo.GetFiles();
foreach (FileInfo file in FilesInDir)
{
Console.WriteLine (“File Name: {0}”; file.Name);
}
b. DirectoryInfo MydirInfo = new DirectoryInfo(@”c:\WINDOWS”);
FileInfo[] FilesInDir = MydirInfo.GetFiles();
foreach (FileInfo file in FilesInDir)
{
Console.WriteLine (“File Name: {0}”; file.Name);
}
c. DirectoryInfo MydirInfo = new DirectoryInfo(@”c:\WINDOWS”);
FileInfo[] FilesInDir = MydirInfo.GetFiles();
foreach (FileInfo file in MydirInfo)
{
Console.WriteLine (“File Name: {0}”; file.Name);
}
d. DirectoryInfo MydirInfo = new DirectoryInfo(@”c:\WINDOWS”);
FileInfo FilesInDir = DirectoryInfo.GetFiles();
foreach (FileInfo file in FilesInDir)
{
Console.WriteLine (“File Name: {0}”; file.Name);
}
252) Consider the following code snippet:
using System;
namespace ex
{
class exc_demo
{
int x = 0;
public void div(int a, int b)
{
try
{
x = a / b;
}
catch (DivideByZeroException e)
{
Console.WriteLine("exception {0}",e);
}
}
static void Main(string[] args)
{
exc_demo obj = new exc_demo();
obj.div(0, 10);
Console.ReadLine();
}
}
}
Identify the output of the preceding code snippet.
a. Will handle the exception occurred and display the result
b. Will not be able to handle the exception generated
c. Will display result = 0
d. It will compile but will not display any result
253) With regard to the FileInfo class, match the following properties with their
respective purpose
Column A Column B
5.13
254) Which of the following class should be inherited to create a user-defined
exception?
a. System.ApplicationException
b. SystemException
c. System.InvalidCasException
d. System.IO.IOException
255) Identify the type of error –“division by zero”?
a. Syntax error
b. Run-time error
c. Logical error
d. Compile-time error
256) Identify the method of the StreamReader class that allows the read/write
position to be moved to any position within the file.
a. Seek
b. Peek
c. Read
d. ReadLine
257) Sam has created a program. It is running properly but is not giving the results
accordingly. Which type of error could there be in the program?
a. Compilation error
b. Run-time error
c. Logical error
d. Syntax error
258) Sam wants certain lines of code to be executed whether an error occurs or not.
Which of the following block should he use to write the code?
a. try
b. catch
c. finally
d. both catch and finally
259) System.NullReferenceException exception class handles:
a. IO errors.
b. Errors generated when method refers to an array element.
c. Errors generated during the process of dereferencing a null object.
d. Memory allocation to the application errors.
260) Which of the following is the method of the StreamWriter class?
a. Flush
b. Seek
c. Peek
d. Read
261) System.IndexOutOfRangeException comes under the category:
a. Systax error
b. Run-time error
c. Logical error
d. Compile-time error
262) The following code has an error:
FileStream fs = new FileStream(“c:\Myfile.txt”, FileMode.Open, FileAccess.Read);
Identify the correct code.
a. FileStream fs = new FileStream(“c:\\Myfile.txt”, FileMode.Open,
FileAccess.Read);
b. FileStream fs = new FileStream(“c:\Myfile.txt”, FileMode.Read.
FileAccess.Open);
c. FileStream fs = new FileStream(“c:\Myfile.txt”, FileMode.Open,
FileAccess.Write);
d. FileStream fs = new FileStream(“c:\Myfile.txt”, FileMode.Write,
FileAccess.Read);
263) Identify the correct statement regarding exception handling.
a. A try block must be followed by a catch block and a finally block.
b. A program can have only catch block and a finally block.
c. A program can have only a catch block.
d. A Try block must have at least one catch block
6.10
264) Choose the correct code to define the event named ehello that invokes a
delegate named hello.
a. Pulic delegate hello(); private event delegate ehello();
b. Pulic delegate void hello(); private event delegate ehello();
c. Pulic delegate hello(); private event ehello hello;
d. Pulic delegate void hello(); private event hello ehello();
265) Which of the following code snippet will be used to initialize the delegate object
where a delegate, PrintData, is defined in a class and WiteConsole and WriteFile are
two methods defined to print a string to the console and print a string to the file
respectively?
a. Public static void Main(){ PrintData p = new PrintData(WriteConsole);PrintData
p1 = new PrintData(WriteFile);}
b. Public static void Main(){WriteConsole p = new WriteConsole(PrintData);
WriteFile p1 = new WriteFile(PrintData);}
c. Public static void Main(){WriteConsole p = new WriteConsole(); WriteFile p1 =
new WriteFile();}
d. Public static void Main(){PrintData WriteConsole = new
PrintData(WriteConsole); PrintData WriteFile = new PrintData(WriteConsole);
}
266) Identify the output of the following code:
using System;
using System.IO;
namespace dele
{
public class dele_demo
{
public delegate void PData(String s);
public static void WC(String str)
{
Console.WriteLine("{0} Console", str);
}
public static void DData(PData PMethod)
{
PMethod("This shoud go to the");
}
public static void Main()
{
WC MlDelegate = new WC(PData);
DData(MlDelegate);
}
}
}
a. Will compile successfully bit generate a runtime error
b. Will display “This should go to the”
c. Will display “This should go to the console”
d. Will give compilation error
267) Match the states of a theread in column A with their corresponding explanation
in column B.
Column A Column B