Vous êtes sur la page 1sur 911

MCQS SUMMATIVE 1

////////////////////////////////////////////////////////////////////////////////////////////////////////

1) What is the significance of document type definition(DTD)? please select all relevant options?

1. is a set of markup declarations that define a document type

2. it's syntax declares precisely which elements and references may appear where in the
document

3. it declares precisely the programming logic used for each element in the document

4. it declares entities which may be used in the HTML document

5. it declares what the contents and attributes are for each element

select one:

a. 3&4&5

b. 1&3&4

c. 1&2&4&5

d. 2&5

e. 1&2&3&4

Ans c

2) which all data types cannot be return types of a scalar function?

1. text

2. ntext

3. integer

4. image

5. cursor

select one:

a. 1&2&3&4
b. 2&4&5

c. 1&3&5

d. 1&2&4

e. 1&2&4&5

Ans e

3) what does the CSS box model consist of?

1. layouts

2. margins

3. borders

4. padding

5. actual content

select one:

a. 2&3&4&5

b. 1&3&4&5

c. 3&4

d. 1&3&4

e. 1&2

Ans a

4) which of the statements are true for read-only fields?

1. read-only fields cannot be changed during program execution

2. read-only fields have to be declared at the namespace level

3. read-only fields are initialized during runtime

4. read-only fields can be read as many times as needed


select one:

a. 2&3

b. 1&3&4

c. 2&4

d. 1&2

Ans b

5. On what conditions can you perform concurrent online index operations on the same table?

1.creating multiple clustered indexes

2.Creating multiple nonclustered indexes

3.Reorganizing different indexes on the same table

4.Reorganizing unique indexes on the same tables

5.Reorganizing different indexes while rebuilding nonoverlapping indexes on the same table

Select one:

a. 1&3&5

b. 2&3&5

a. 1&2&4

a. 3&4&5

a. 2&4

Ans b

6. Which of the following statements is correct about classes and objects in C#.NET?

Select one:

a. Objects of smaller size are created on the heap.

b. Objects are always nameless


c. Since objects are typically big in size, they are created on the stack

d. Class is a value type.

Ans b

7. Which are the basic types of a subquery?

1. Those that operate on lists introduced with IN

2. Those that a comparison operator modified by ALL or NOT

3. Those that are introduced with an unmodified relational operator and must return a
computed value

4. Those that are introduced with an unmodified comparison operator and must return a single
value

5. Those that are existence tests introduced with EXISTS

Select one:

a. 3&4

b. 1&5

c. 1&4&5

d. 2&3&5

e. 1&3&5

Ans c

8. What does the following code denote?

var premium= from customer in Customers where customer.Grade=="Premium" select


customer.Name;

1. The following code is an example of Database Query

2. The following code is an example of LINQ Query

3. The following code shows the syntax for Ordering data

4. The following code shows the syntax for Filtering data


Select one:

a.3&4

b.1&3

c.2&4

d.1&4

Ans c

Q9 Which of the following statements are true for Protected Internal Access?

1.Protected Internal members can be accessed by objects in the same assembly

2. Protected Internal members are exactly same as private members in the same assembly

3. Protected Internal members can be accessed by derived classes inside and outside the
assembly

4.Protected Internal members are exactly same as internal members in the same assembly

Select one

a.1&4

b.2&3&4

c.1&2&3

d.1&3

ans 1&3

Q10 How do you convert an existing aspx page with two drop-down list boxes to become Ajax
compliant?

1.By rewriting the page to implement Ajax


2.By wrapping the controls in a ScriptManager control

3.By wrapping the controls in UpdatePanel control

4.By adding ScriptManager control to the page

Select one

a.1&2&3

b.1&3

c.3&4

d.2&3&4

ans 3&4

Q11 Which control can be used to ensure that the user does not miss an entry?

Select one

a.RequiredfieldValidator

b.CustomValidator

c.CompareValidator

d.RangeValidator

ans a

Q12 When you execute user-defined functions that return scalar values,how are the parameters
specified?

1.The argument values are enclosed in paranthesis

2.The argument values are not enclosed in paranthesis


3.Parameter names can be specfied

4.If parameter names are specified,the argument values do not have to be in the same sequence
as the parameters.

Select one

a.1&2&3&4

b.1&3

c.1&2&4

d.2&3&4

Ans 2&3&4

Q13 Which statements are true about Directives?

1 a directive begin with a <%

2 a directive ends with a%>

3 Dirrectives are used to directly compile an ASP.NET page

4 Directive are used primarily to provide the compiler with the information it need to compile the
page.

select

a 1&2

b 1&3

c 3&4

d 1&2&4
ans 1&2&4

Q14 Which of the following statements are correct about an enum used in c#.NET?

1 To used the keyword enum, we should either use [enum] or nsystem.Enum.

2 enum is a keyword.

3 Enum is class declared in system.Type namespace

4 Enum is a class declared in system namespace.

select one:

1 1&2

2 2&4

3 1&2&3

4 3&4

ans 2&4

Q15 Which are the conditions when indexes of views can provide significant performance
advantage?

1. When the view contains aggregations

2 When the view contains compositions

3 When the view contain table joins

4 When the view contains a combination of aggregation & joins


5 when the view contains locks

select one:

a 3&5

b 2&5

c 1&2&4

d 1&3&4

e 1&5

ans 1&3&4

Q16 Which of the following statements are correct about exception handling in C#.NET?

1 if our program does not catch an exception then the .NET CLR catches it.

2 it is possible to create use-defined exceptions.

3 All types of exceptions can be caught using the Exception class

4 CLRException is the base class for all classes.

select one:

a 1&3&4

b 1&3

c 2&4
d 1&2&3

ans 1&2&3

17.

Why are catalog views the preferred choice for accessing the information in systems calogs?

1.They provide access to all the metadata

2.The metadata information is presented in a format that is independent of any catalog table
implementation

3. The metadata information is presented in a format that is dependent on system tables,hence is


in a fixed format which is easy to understand.

4. They provide the most direct way to obtain, tansform & present customized forms of the
catalog metadata.

5. Catalog view names as well as the names of their columns are descriptive

Ans.- 1&2&4&5

--------------------------------------------------------

18.What is a document type with respect to HTML ?

a. The object which represents the content area of the browser window where HTML documents
appear is a document object

b. Each HTML document that gets loaded into a window is a document object

c. Each javascript represents a document object

d. Each logical form element in a HTML window represents a document object.

Ans.-b

--------------------------------------------------------
19.What is the significance of cir enabled option?

1.It is used to specify whether user assemblies can be run by SQL server

2. The cir enabled option can be set o value False to denote that assembly execution is not
allowed on SQL server.

3. The cir enabled can be set to value TRUE to denote that assembly execution is not allowed on
SQL server.

4. The cir enabled can be set to value 0 to denote that assembly execution is not allowed on SQL
server.

5.The cir enabled can be set to value 1 to denote that assembly execution is not allowed on SQL
server.

Ans.-1&4&5

-------------------------------------------------------

20.Which of the following statements are true for protected access?

1.Protected members can be accessed by all the code

2.Protected members can be accessed by members of the same class or through inheritance

3.Protected access is less restrictive than private access but more restrictive than public access

4.Protected access is more restrictive than private access but less restrictive than public access

Ans.-2&3

21.

Which of he following statments are correct?

1.c# allows a function to have arguments with default values.

2.c# allows a function to have variable number of arguments.

3. ommiting the return value type in method definition results into an exception.

4. params is used to specify the syntax for a function with variable number of arguments.
Select one:

a. 1&3

b. 1&2&3

c. 2&4

d. 3&4

ans--c

-------------------------------------------------------------------------------

22

what enables clients to interact with UDDI directories & Web Services?

Select One:

a. SOAP

b. XML

c. WSDL

d. UDDI

ans-- a

------------------------------------------------------------------------------

23

Identify the statements that are applicable to the Literal control.

1. Literal control does not support CssClass

2. Literal control does not support BackColor

3. Contents of a Literal Control are contained in a <span> tag


4. Contents of a Literal Control are not contained in a <span> tag

select one:

a.1&3

b.1&2&4

c.1&3&4

d.2&4

ans-- b

--------------------------------------------------------------------------------

24

What does the following culture name denote:en-GB?

select one:

a. it denotes that the language is English & Country is Global

b.it denotes that the language is English & Country is United States

c.it denotes that the language is English & Country is United Kingdom

d.it denotes that the language is English & Country is India

ans--c

-----------------------------------------------------------------------------

25:

What is the significance of the <area> tag?


1:The <area> tag defines an area inside a form

2:The <area> tag defines an area inside an image-map

3:The <area> tag is always nested inside a <form> tag

4:The <area> tag is always nested inside a <map> tag

Select One:

a:2&4

b:3&4

c:2&3

d:1&2&3

ANS:a

===============================================

26:

Which statements are true about Table-valued parameters?

1:They are user-defined scalar values that are passed into a procedure or function

2:They are user-defined table types that are passed into a procedure or function

3:They provide an efficient way to pass multiple rows of data to the server

4:They provide an efficient way to pass a connection to the server

Select one:

a: 1&3&4

b: 2&4

c: 2&3

d: 1&4

ANS:c
=================================================

27:

How do you implement code behind?

1:All the user interface related code is written in a .aspx file

2:All the user interface related code is written in a .cs or .vb file

3:All the business logic is written in a .cs or .vb file

4:All the business logic is written in a .aspx file

select one:

a:3&4

b:1&2

c:2&3&4

d:1&3

ANS: d

==============================================

28:

Which two properties of a page class have an effect on localization?

1.Culture

2.Localize

3.UICulture

4.Globalize

select one:

a: 1&2

b: 3&4
c: 1&3

d: 2&4

ANS:c

29) SQL Server consists of which of the following three types of files?

1.Primary data files

2.Secondary data files

3.Hidden files

4.Log Files

select one

a.1&3&4

b.1&2&4-ANS

c.1&2&3&4

d.only 4

30) Which all statements are true about Entity Framework ?

1.It takes care of relational databases.

2.It takes care of impedance mismatch.

3.It allows applications to be written against conceptual models and not directly against the
database.

4.It takes care of memory mismatch.

select one

a 2&3&4
b.1&3

c.2&3-ANS

d.1&4

31) Which of the securables are contained in the Database scope?

1.Login

2.User

3.Role

4.Assembly

5.end point

select one

a.3&4&5

b.1&2&3

c.2&3&4-ANS

d.1&3&5

e.1&2&5

32) What attributes does the @ Register contain?

1.Tagprefix

2.TagName

3.Cntrl

4.Src

a 3&4
b.1&2&4-ANS

c.1&2

d.2&3&4

33

which control lets you display a progress while an update


panel is updating its content.

1. update status control

2. script manager control

3. update panel control.

4. update progress control.

ANS....4

34

how are BLOB string and pointer sored in a row of a table.

1.BLOB strings and pointers stored in the row of a table are treated similarly to fixed lngth
strings .

2.SQL servr uses fixed no. of bytes rquierd to store the string or the pointer .

3. just like fixed length strings........

4. BLOB strings and pointers strored in the row of a tabl are treated similarly to variable length
strings.

5. SQL server uses only the nu. of bytes required to store the strings or the pointer ...

ANS.......4&5

35. Which all languages can be used to develop a ASP.NET application ?

1. c#

2.Visual basic .net


3.Visual basic

4. c language

select one

a. 2&4

b.1&2

c.1&3&4

d.3&4

answer: b

36. which are the basc steps for separating a ASP.NET web page?

1. create a file for user interface

2.create a file for data base

3.create a file for interface logic

4. use page directive to link the two files

5. call procedures in the code-behind page

select one:

a. 2&5

b. 1&3&4&5

c. 1&2&3&5
d.1&2&4

e. 3&4

answer: b

37) ___________ are small amounts of data sent by a program to the browser and stored on the
user's machine to be retrived later.

a. objects

b. Application variables

c.session variables

d.Cokkies (CORRRECT)

--------------------------------------------------------------------------------

38) Identify the different types of stored procedures:

1)User-defined stored pocedures-Transcat SQL & CLR

2)Compiled stored pocedures


3)Extended stored procedures

4)System stored procedures

Ans: select one:

a. 1&2&4

b.1&3

c.3&4

d.1&3&4(CORRECT)

---------------------------------------------------------------------------------

39) How can you load data into a Dataset so that it can be queried using LINQ?

1.By using DataAdapter Class

2.By using LINQ to Dataset

3.By using LINQ to SQL

4.By using LINQ to XML


a. 1&4

b. 1&3(CORRECT)

c. 2&4

d. 2&3

---------------------------------------------------------------------------------

40) How can the execution plan of queries on partitioned tables and indexes to be examined?

1. By using th Transcat-SQL SET SHOWPLAN_XML

2.By using th Transcat-SQL SET STATISTICS_XML

3.By using th Transcat-SQL SET PARTITION_XML

4.By using th Transcat-SQL SET INDEX_XML

a. 1&4

b. 3&4

c. 1&2(CORRECT)
d. 2&3

41. which all values can a bool type have?

1. TRUE

2. FALSE

3. 0

4. 1

Select one:

a. 1&4

b. only 2

c. only 1

d. 2&3

e. 1&2

ans- e. 1&2

42. which event is raised at the end of the event-handling stage of the page life cycle?

Select one:

a. InitComplete

b. Init

c. LoadComplete

d. Unload
ans- d. Unload

43. What does the following code snippet denote?

<asp:TextBox

SkinID="DashedTextBox"

BorderStyle="Dashed"

BorderWidth="5px"

Runat="Server"/>

Select one:

a. Usage of a Default skin

b. Usage of a Named skin

c. Usage of a stylesheet

d. Usage of a Master page

ans- b. Usage of a Named skin

44. How do you create a Client proxy class in C# for XML web services using the wsdl tool?

Select one:

a. wsdl/WSDL http://hostServer/WebserviceRoot/WebServiceName.asmx

b. wsdl http://hostServer/WebserviceRoot/WebServiceName.asmx?XML

c. wsdl http://hostServer/WebserviceRoot/WebServiceName.asmx

d. wsdl http://hostServer/WebserviceRoot/WebServiceName.asmx?WSDL
ans- d.wsdl http://hostServer/WebserviceRoot/WebServiceName.asmx?WSDL

45. How do you create a persistent cookie?

Select one:

a. By using the PersistentCookie attribute of the Role Manager

b. By using the CreateCookie attribute of the Role Manager

c. By using the CreatePersistentCookie attribute of the Role Manager

d. By using the CookieProtection attribute of the Role Manager

ans- c. By using the CreatePersistentCookie attribute of the Role Manager

46. How do FORWARD_ONLY cursor work?

1. Data is fetched in bulk

2. data is fetched sequentially from the first to last row

3. FETCH NEXT is the only fetch option supported

4. FETCH PREVIOUS is the only fetch option supported

select one:

a. 2&3

b. 1&4

c. 1&3&4

d. 2&3&4
ans- a. 2&3

47. What does the following example denote?

<div style="color:#00FF00">

<h3>This is a sample paragraph</h3>

<p>This is a Sample Paragraph yo demonstrate how....</p>

</div>

1. It denotes the usage of <div> tag

2. It has 1 heading defined by a <h3> tag

3. It has 1 heading defined by a <p> tag

4. It has 1 paragraph defined by a <h3> tag

5. It has 1 paragraph defined by a <p> tag

Select one:

a. 1&2&3&5

b. 1&4&5

c. 2&3

d. 1&2&5

e. 2&3&4&5

ans- d. 1&2&5

48. Which statements are true about APPLY operator?

1. The APPLY operator allows you to join two table expressions

2. The APPLY operator allows you to join two columns from the same table
3. The right table expression is processed every time for each row from the left table
expression

4. The left table expression is processed every time for each row from the right table
expression

Select one:

a. 2&3

b. 2&4

c. 1&4

d. 1&3

ans- d. 1&3

49. Which statements are true about Data Integrity?

1. It refers to each occurrence of a column having a correct data value

2. It indicates that the relationship between tables have been correctly maintained

3. The data value must be of right type

4. The data value must be in the correct domain

Select one:

a. 1&3&4

b. 3&4

c. 1&2

d. 2&3&4
ans- c. 1&2

50. Which all collections can be implemented using Generics?

1. Arrays

2. Dictionaries

3. Lists

4. Stacks

Select One:

a. 1&3&4

b. 2&3

c. 1&2

d. 2&3&4

ans- d. 2&3&4

51. SQL Server supports cursor functionality for which Database APIs?

1.DAO

2.ADO

3.OLEDB

4.ODBC

5.RDO

Select One:
a.1&4&5

b.2&3&4

c.1&3&4

d.2&4&5

e.3&5

ans- b.2&3&4

52. Which statements are true about sysname?

1. sysname is a system-supplied user-defined data type that is functionally equivalent to


nvarchar(128)

2. sysname is a system-supplied user-defined data type that is functionally equivalent to


nvarchar(256)

3. sysname is not nullable

4. Sysname can hold Null & negative values

5. sysname is used to reference database object names

Select one:

a. 1&2&5

b. 1&3&4

c. 3&4&5

d. 2&4&5

e. 1&3&5

ans- e. 1&3&5
53. What are your observations on the following code?

private void CheckForReferenceType<T>(T type) where T:class,|HoldVal|

type.Val=5;

1.Code Denotes usage of Generics Constraint

2.Code Denotes Base Class Generics constraint

3.Code Denotes Interface Generics Constraint

4.Code Denotes Reference Type Generics Constraint

Select one:

a.1&3&4

b.2&4

c.1&2

d.1&4

ans- d.1&4

54. Which of the following problems of non-generic collection does generic solve?

1. Lack of flexibility

2. Lack of type safety

3. Lack of security

4. Lack of performance while using value types

Select one:
a. 1&4

b. 2&4

c. 1&2&3

d. 1&3

ans- b. 2&4

55. what does the following code denote?

foreach(var day in enum.GetValues(typeof(Weekday)))

console.writeline(day);

select one:

a.Following code iterates through an Array.

b.Following code iterates through an ArrayList.

c.Following code iterates through each member of an enum.

d.Following code iterates through a HashTable.

Ans : C

56. Which statements are true about CROSS APPLY operator?

1. CROSS APPLY operator is a mechanism that allow a developer to correlate a table valued
function to another table

2.The set of rows can be either a number or percntag an decimal value

3.specifies that only the last set of rows will be returned from query result

4.Top clause cannot be apply with the variables.


select one:

a. 1&4

b.1&2

c.2&3&4

d.only 1

Ans:D

57. XPath consists of which of the following three types of

files?

1.Integer

2.String

3.number

4.boolean

select one:

a.1,2,3

b.1,4

c.2,4

d.2,3,4

Ans:D

58. what is the significance of INSTEAD OF argument of th CREATE TRIGGER statement?


1. Specifies that the DML trigger is executed intead of the triggering SQL statement.

2. It overrides th actions of th trigering statements.

3. It can be specified for DDL or logon triggers

4. It cannot be specified for DDL or logon triggers.

select one:

a.1,2,3

b.1,4

c.3,4

d.1,2,4

Ans D

59. which of the following is the root of the .NET type hierarchy?

select one:

a.System.Parent

b.System.Base

c.System.Object

d.System.Type

Ans C

60.Suppose a generic class called SortObjects is to be made capable of sorting objects of any
type(integer,single,Byte etc..).Which of the following programming constructs should be used to
implement the comapision function?

select one
a.Interface

b.Delegate

c.Encapsulation

d.Namespace

Ans B

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

MCQS SUMMATIVE 2

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

1. Which statement is true about DENSE_RANK function?

1.returns the rank of rows within the partition of data set ,without any gaps in the ranking.

2.the rank of a row is one plus the number of distinct ranks that come before the row in question.

3.returns the rank of each row within the partition of a result set.

4.the rank of a row is one plus the number of ranks that come before the row in questions

select one:

a.1&3

b.1&2

c.3&4

d.2&4

answer:b.1&2

2. What all happens before & during the rendering stage of the page life cycle?
1.page load event is triggered

2.view state is saved for page and all controls

3.control properties are loaded with information recovered from view state and control state

4.the render method for each control is called by the page.

select one

a.2&4

b.3&4

c.1&2&3

d.1&3

answer: a :2&4

3.Which are the different types of button that can be used in html forms?

1.submit button

2control button

3reset button

4push button

select one

a.1&2&3

b.1&3&4

c.2&3

d.1&4
answer b.1&3&4

4.Which is/are the statement true about the TOP clause?

1.The Top Expression can be applied in select,insert,updat and delete statements

2.the where clause of the outer query tests whether data exists in the subquerry for each row of
the outer qurery

3.the subquerry returns a list of rows that match the criteria

4.the subquerry returns a value of TRUE or FALSE

select one

a.1&2&4

b.1&2

c.3&4

d.1&3&4

answer: 1 & 2& 4

5: Which statements are applicable to CHECK

constraint?

1.Specifies that the column does not accept

NULL values

2.Enforces domain integrity by limiting the

values that can be put in a column

3.Specifies a Boolean search condition that is


applied to all values that are entered for the

column

4.Enforces the uniqueness of the values in a

set of columns

Select one:

a. 1&2&3

b. 2&3

c. 1&4

d. 3&4

Answer: a. 1&2&3

6:Which all statements are true about Properties?

1.Properties encapsulate access to public fields

2.Properties encapsulate access to private fields

3.With Properties even if the implementation of private state changes, the implementation is not
broken

4.With Properties even the implementation of private state cannot change

Select one:

a. 1&2&3

b. 1&3

c. 1&4
d. 2&4

Answer: a. 1&2&3

7: Which all languages can be used to develop

a ASP.NET application?

1.C#

2.Visual Basic .NET

3.Visual Basic

4.C Language

Select one:

a. 2&4

b. 3&4

c. 1&3&4

d. 1&2

Answer: d. 1&2

8:Which are the different mechanisms to handle collections of objects?

1.Arrays

2.Enums

3.ArrayLists

4.Generics
Select one:

a. 1&4

b. 2&3

c. 1&2&3

d. 1&3&4

Answer: d. 1&3&4

Q 9. The ------ property is used to specify which resource files are loaded for the page.

select one:

a. Culture

b. Localize

c. UICulture

d. Globalize

Ans. Culture

Q 10. What are the advantages of partial classes

1. When multiple depolyments are required'

2. When working on large projects,spreading a class over separate files allows multiple
prgrammers to work on it simultaneously

3. When multiple versions of assembly are required

4. When working with automatically generated source,code can be added to the class
without having to recrreate the source file

select one:
a. 2&4

b. 1&3&4

c. 1&3

d. 2&3

Ans. 2&4

Q 11. What all elements can a struct contain?

1.Constructors

2.Constants

3.Namespaces

4.Fields

5.Methods

select one:

a. 3&4

b. 2&4

c. 1&2&4&5

d. 1&3&5

e. 1&2&3&5

Ans 1&2&4&5

Q 12. In ASP.NET which class does the code behind page inherit from?

select one:
a. System.Web.UI.WebPage

b. System.Web.UI.Control

c. System.Web.UI.Page

d. System.Web.UI.WebControl

Ans. C. System.Web.UI.Page

13.Which statements are true about Entity Framework.

1.It takes care of relational databases.

2.It takes care of impedance mismatch.

3.It allows applications to be written against conceptual models.

4.It takes care of memory mismatch.

Answer-2&3

14.What does following code denote,choose multiple if applicable?

string strVal="Y";

while (strVal=="Y);

1.Conditional statement
2.Looping statement

3.Unending loop

4.Unreachable loop

Answer-1,2,3

15.Integration Services include three types of containers that you can use in a control flow,which
are they?

1.The DoWhile Loop container

2.The Foreach Loop container

3.The For Loop container

4.The Sequence container

5.The Switch Container

Answer-2&3& 4

16.What are your observations on the following

body{background-color:#b0c4de}

1.The background-color property specifies the background color of an element,

2..The background-color property specifies the background color of all elements of the website

3.The background color of a page is defined in the body selector.

4.The background color of a page is defined in the head selector.


Answer-1&3

17

which statements are true about Primary XML index?

1.It is shredded and persisted representation of the XML BLOBS in the xml data type column

2.For each XML binary large object(BLOB) in the column, the index creates several rows of
data

3.for each Xml binary large object(BLOB) in the row, the index creates several columns of data

4.The number of rows in the index is approximately equal to the number of nodes in the XML
binary large object

5.The number of columns in the index is approximately equal to the number of nodes in the
XML binary large object

select one:

a.3&4

b.2&5

c.1&3&5

d.1&2&4

e.1&2&3&5

ans---d

18
Which statements are true about a multistatement scalar function?

1.There is no function body

2.The function body defined in BEGIN...END block contains a series of T-SQL statements

3.The scalar value is a result of a single statement

4.The scalar value is a result of all the statements in the BEGIN...END block

Select one:

a.1&3&4

b.2&3

c.2&4

d.1&4

ans---2&3 statements

19

What are your observations on the following code?

<select>

<option value="volkeswagon">VolkesWagon</option>

<option value="mercedes">Mercedes</option>

<option value="BMW">BMW</option>

<option value="audi">Audi</option>
</select>

1.The<select>tag is used to create a drop-down list

2.The<select>tag is used to create a display list

3.The<select>tag inside the select element define the available options in the list

4.The<select>tag inside the select element displays a option-button list

Select one:

a.2&3

b.3&4

c.1&3

d.1&2&3

ans---1&2&3

20

What are your observations on the following code?

<html>

<head>

<script language="JavaScript">

function showMsg(msg){

alert("Following message was sent:"+msg)


}

</SCRIPT>

</head>

</body>

<form>

<input type="button"value="Click to Vote"

onClick="showMsg('I want world peace')">

</form>

</body>

</html>

1.A function is called from an assembly

2.A function is called from an event handler

3.A parameter is passed to the funtion

4.The function returns a string value

Select one:

a.3&4

b.1&4

c.2&3

d.1&2&4

ans ---2&3

21. A function returns a value, whereas a subroutine cannot return a value. State true or false
select one:

a. false

b. true (ans)

22. _______ is a numerical label assigned to each device like a computer,a participating in a
computer, a printer etc participating in a computer network that uses the internet protocol for
communication.

select one:

a. url

b. xml

c. html

d. ip address (ans)

23. What all statements are true about System.Enumstruct?

1. Using System.Enumstruct you can convert string to enum

2. Using System.Enumstruct you can convert object to enum

3.loop through a list of enum members

4. 1. Using System.Enumstruct you can convert ArrayList to enum

select one:

a. 1&2

b. 2&4

c. 1&3 (ans)

d. 1&3&4
24: What are the query considerations for using clustered indexes ?

1.Use clustered index when a query returns a range of values by using operators such as
BETWEEN,>,>=,<,<=

2.Use clustered index when a query returns large resultsets

3.Use clustered index when a query needs to handle NULL values

4.Use clustered index when a query uses JOIN clauses

5.Use clustered index when a query uses GROUP BY or ORDER BY clauses

Select one:

a.2&3&5

b.2&4

c.1&3

d.1&2&4&5

e.1&4

ANS:d-1&2&4&5

25:Why are catalog views the preferred choice for accessing the information in system catalogs?

1.They provide access to all metadata

2.The metadata information is presented in a format that is independent of any catalog table
implementation

3.The metadata information is presented in a format that is dependent on system tables, hence is
in a fixed format which is easy to understand

4.They provide the most direct way to obtain, transform & present customised forms of the
catalog metadata
5.Catalog view names as well as the names of their columns are descriptive

Select one:

a.1&2&4&5

b.2&4

c.3&4&5

d.1&3&5

e.1&2&3&4

ANS:a-1 & 2 & 4 & 5

26:_______ is the process of customizing your application for a given culture and locale.

Select one:

a.Localization

b.Culturalization

c.Customization

d.Globalization

ANS:a-Localization

27:Which all statements are true about SOAP Header element?

1.SOAP Header element contains verbose description of a message

2.SOAP Header element contains application-specific information , like authentication, payment,


etc, about the SOAP message

3.SOAP Header is optional


4.SOAP Header is mandatory

5.SOAP Header element must be the first child element of the Envelope element

Select one

a.1&2&3&4

b.2&3&4

c.1&4

d.3&5

e.2&3&5

ANS:e- 2 & 3 & 5

28. Which of the following statments is correct about classes and objects in c#.Net?

select one:

a.Since objects are typically big in size,they are created on the stack.

b.Objects are always nameless.

c.Class is a value type.

d.Objects of smaller size are created on the heap.

ANS- Objects are always nameless.

29.What is the significance of INSTEAD argument of the CREATE TRIGGER statement?

1.Specifies thet the DML trigger is execute instead of the triggering SQL statement

2.It overrides the actions of the triggering statements

3.It can be specified for DDL or logon triggers


4.It cannot be specified for DDL or logon triggers

select one:

a.3&4

b.1&2&3

c.1&2&4

d.1&4

ANS-b.1&2&4

30.What are your observations on the following code?

int iEmpNo=10;

string strEmpName="John Miller";

ArrayList arrlstValues=new ArrayList();

arrlstValues.Add(iEmpNo);

arrlstValues.Add(strEmpName);

select one:

a.The code has errors

b.You cannot assign two different data types to the same ArrayList

c.The ArrayList can hold both values

d.The ArrayList can hold only integer values

ANS-c.arraylist can hold both values.

31.identify steps in handling errors in a stored procedure.

1.When an error conditions is detected in a T-SQL statement the is inside a TRY block,Control is
immidiately passed to the CATCH block
2.The Errors is processed in the TRY block

3.The Errors is processed in the CATCH block

4.T-SQL statement in the TRY block that generated the error are not executed

select one:

a.1&3&4

b.2&4

c.1&3

d.2&3&4

ANS- a.1&3&4

32

which of the modifiers are applicable to objects?

1 Public

2 Private

3 Protected

4 Internal

ANS: 1&2&3

33 which statement are true about RollBack TRANSACTION statement?


1 Rolls back an implicit transaction to the beginning of the transaction or to a savepoint in side
the transaction.

2 Rolls back an explicit transaction to the beginning of the transaction or to a savepoint in side
the transaction.

3 it caches all data modification & then erases fromthe start of the transaction or to a save ponit.

4 it eraser all data modification made from the start of the transaction or to a savepoint

5 it reverses all the modification made before the commit transaction statement.

ANS:1&2&4

34 which statement are true about disabling CLR integration in SQL server

1 you can disable CLR intergration by setting the clr enable option to FALSE

2 you can disable CLR intergration by setting the clr enable option to 0

3 when you disable CLR integration,SOL server unload all CLR routines.

4 when you disable CLR integration,SOL server stops executing all CLR routiness

5 when you disable CLR integration,SOL server unload all application domains

ANS:2&4&5

35 how dose EXTERNAL_ACCESS permission set work?

1 Allows access only to external assemblies with minimal with access to internal computation.

2 Allows access to internal computations

3 Allows access to external system resource such as files,network & environment variables.

4 Allows access to Registry.


ANS: 2&3&4

36. which control manages client script for AJAX- enabled ASP.NET web pages

select one

a. update control

b. script manager control

c. update panel control

d. run script control

answer: b

37.which statements are true about parameters to user-defined functions?

1. user-defined function takes zero or mpore input parameters and return either a scalar value
or a table

2. user-defined function takes zero or mpore input parameters and return only an integer

3. a function can have a maximum of 1024 input parameters

4. when a parameter of the function has a default value,the keyword DEFAULT must be
specified when calling the function to get the default value

select one

a. 3&4

b. 2&3&4

c. 1&2
d. 1&3&4

answer: d 1&3&4

38. which attribute of the @register directive indicates the name space you want to associate
with the user control for the current page?

select one

a. Src

b. TagPrefix

c. Cntrl

d. TagName

answer: b

39. how is a web service different from an aspx page?

1. a web service runs on the server

2. a web service is based on XMLdate transfer

3. a web service file extension is .asmx

4. methods of a web service are tagged as web methods

5. a web service is same as an aspx page

select one:

a. 1&3&4
b. 1&2&4&5

c. 2&1&5

d. 2&3&4

e. 1&2&3

answer: e 1&2&3

40. Which statements are true in difference between primary key and unique key?

1. Primary key is also a unique key internally,but it cannot allow null

2. Primary key is also a unique key internally,but it can allow null

3. Unique key on the other hand allow a single null and a multiple null in a column

4. Unique key on the other hand allow a single null but not multiple null over the column

Select one:

a. 1&2

b. 1&2&4

c. 1&4

d. 2&3

ans: c. 1&4

41. Which are the different types of controls that you can use in ASP.NET web pages?

1. ActiveX OCX controls

2. HTML Server controls


3. Web Server controls

4. Validation controls

5. User controls

Select one:

a. 1&2&4&5

b. 1&3&5

c. 1&4&5

d.2&3&4&5

e. 2&3&4

ans. d.2&3&4&5

42. What does the following listing denote?

<configuration>

<system.web>

<pages theme="Website"/>

</system.web>

</configuration>

Select one:

a. Registering a MasterPage in web.config

b. Registering a Skin in web.config

c. Registering a theme in web.config

d. Registering a StyleSheet Theme in web.config


ans. b.Registering a Skin in web.config

43. Which of the following statements is correct about an interface used in C# .NET?

Select one:

a. From two base interfaces a new interface cannot bne inherited.

b. One class can implement only one interface.

c. In a program if one class implements an interface then no other class in the same program can
implement this interface.

d. Properties can be declared inside an interface.

ans. d. Properties can be declared inside an interface.

Q 44

What does the following code denote?

Public class CustomerList:List<Customer>

public int Distinct cities

get

// compute number of unique cities

//that customer live in


return 7;

select one:

a) A class that derives from a generic type

b) A class that implement an interface

c) A class that derives from a value type

d) A class that derives from an indexer

ans a) A class that derives from a generic type

Q 45

What does the redirect url parameterof Authentication service.login method do?

select one

a) it redirect thwe user to the logout page after unsuccessful authentication

b) it redirects the user to an error page on unsuccessful login attempt

c) it redirects the user to a functional page after successful authentication

d) it redirects the user to login page on successful login attempt

ans c) it redirects the user to a functional page after successful authentication


Q 46

What does the following code denote?

var query =from o in orders

where o.onlineorderflag=true

select new{o.salesorderid,o.orderdate,o.salesordernumber};

1 usage of linq to query dataset

2 usage of linq to query typed.dataset

3 usage of linq to query multiple table s

4 usage of linq to query a single table

select one

a) 1&4

b) 3&1

c) 2&3

d) 2&4

ans d) 2&4

Q 47

which are the two ways of requesting a cursor?

1 Transact-sql

2 Events handling

3 database application programming interface (api) cursor function

4 windows programming interface(api) cursor function


select one

a) 2&3&4

b) 3&4

c) 1&3

d) 1&4

ans c) 1&3

48) What are the advantages of using SQL server authentication?

1. Allows SQL server to support Web-based applicatins where users create their own identities.

2. Allows software developers to distribute their applicatins by using a complex permission


hierarchy based on known,preset SQL server logins.

3. Can also use Kerberos Security protocol.

4.Users can connect from unknown or untrusted domains.

5. Additional paasword policies offered by windows can be inherited for SQL server logins.

a. 1,2 & 4

b. 1,2 & 5

c. 1,3 & 4

d. 2,3 & 5

e. 2,4 & 5

ANS a 1,2,4

49) How are the transaction locks acquired by a SELECT statement controlled?
1. Controlled by the transaction concurrency setting for the connection.

2. Controlled by the transaction isolation level setting for the connection.

3. controlled by any locking hints specified in the WHERE clause

4. controlled by any locking hints specified in the FROM clause

Select one:

a. 1&2

b. 2&4

c. 1&2&3

d. 3&4

ANS b:2,4

50) Which tag is designed to be used for putting in the top banner of a window?

Select one:

a. <title>

b. <heading>

c. <banner>

d. <name>

ANS c <banner>

51) How is the support for XML integrated into SQL server?

1. Support for xml data type


2. Ability to specify an XQuery query against XML data stored in columns and variables of the
xml type

3. Ability to handle bulk loading of XML data

4. Ability to merge XML

Select one:

a. 2&4

b. 1&3

c. 1&3&4

d. 1&2&3

ANS d

52)

How does subquery with EXISTS work?

1. The subquery functions as an existence test

2. The WHERE clause of the outer query tests wheter data exists in the subquery for each row of
the outer query

3. The subquery returns a list of rows that mach he criteria

4. The subquery returns a value of TRUE or FALSe

select one

a.1,2,4

b.1,3

c.2,3,4

d.2,4

ANS A
53)

What does the following code snippet do?

<configuration>

<system.web>

<authentication mode='Windows'/>

<roleManager enabled="true"defaultProvider="MyRoleProvider">

<providers>

<add

name="MyRoleProvider"

type="System.Web.Security.WindowsTokenRoleprovider"/>

</providers>

</roleManager>

</system.web>

</configuration>

select one

a.The configuration file configures the ActiveDirectoryRoleProvider as the default provider

b.The configuration file configures the AuthorizationStoreRoleProvider as the default provider

c.The configuration file configures the WindowsTokenRoleProvider as the default provider

d.The configuration file configures the SqlRoleProvider as the default provider

ANS B

54)
Which of the following two are name types of SQL Server files?

1.physical_file_name

2.logical_file_name

3.primary_file_name

4.os_file_name

select one

a.2,4

b.1,2,4

c.1,3

d.3,4

ANS A

55)

What statements are applicable to panel control?

1.It can be used as a container to other controls

2.It is rendered as an HTML <span> element

3.It is rendered as an HTML <div> element

4.It displays a link to another page

select one

a.2,3,4

b.1,3

c.1,2
d.1,3,4

ANS B

56)

Which of the following is the root of the >NET type hierarchy?

select one

a.System.Base

a.System.Parent

a.System.Type

a.System.Object

ANS D

57) In ADO.NET which objects are involved in connected mode operations?

1.DataSet

2.Data Reader

3.Command

4.Connection.

ANS 2&3

58) With which of the following can the ref keyword be used?

1.Static Data

2.Instance Data
3.Static function/subroutine

4.Instance function/Subroutine

ANS - 3 & 4

59) Which of the following statement is corrrect about the C#.net program given bellow?
Using System;

namespace IndiabixConsoleApplication

class MyProgram

static void Main(string[] args)

int index = 6;

int val = 44;

int[] a = new int[5];

try

a[index] = val;

catch (IndexOutOfRangeException e)

Console.Write("Index out of bound");

Console.Write("Remaining Program");
}

ANS - A) Index out of bound Remaining Program

60) How does ASP.NET leverage on the .NET framework?

1.By using the Framework Class Library (FCL) of .NET

2.By using configuration files

3.By taking advantage of Common Language Runtime (CLR)

4.By executing in web browser

ANS - 1 & 3

ARRAYS

1. Which of the following statements are correct about the C#.NET code snippet given below?

int[ , ] intMyArr = {{7, 1, 3}, {2, 9, 6}};


1. intMyArr represents rectangular array of 2 rows and 3 columns.
2. intMyArr.GetUpperBound(1) will yield 2.
3. intMyArr.Length will yield 24.
4. intMyArr represents 1-D array of 5 integers.
5. intMyArr.GetUpperBound(0) will yield 2.

A. 1, 2

B. 2, 3

C. 2, 5

D. 1, 4

E. 3, 4

Answer & Explanation

Answer: Option A

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

2. Which of the following statements are correct about the C#.NET code snippet given below?

int[] a = {11, 3, 5, 9, 4};

1. The array elements are created on the stack.


2. Refernce a is created on the stack.
3. The array elements are created on the heap.
4. On declaring the array a new array class is created which is derived
fromSystem.Array Class.
5. Whether the array elements are stored in the stack or heap depends upon the size of the
array.

A. 1, 2

B. 2, 3, 4

C. 2, 3, 5
D. 4, 5

E. None of these

Answer & Explanation

Answer: Option B

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

3. Which one of the following statements is correct?

A. Array elements can be of integer type only.

B. The rank of an Array is the total number of elements it can contain.

C. The length of an Array is the number of dimensions in the Array.

D. The default value of numeric array elements is zero.

E. The Array elements are guaranteed to be sorted.

Answer & Explanation

Answer: Option D

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

4. If a is an array of 5 integers then which of the following is the correct way to increase its size to
10 elements?

int[] a = new int[5];


A. int[] a = new int[10];

int[] a = int[5];
B. int[] a = int[10];
int[] a = new int[5];
C. a.Length = 10 ;

int[] a = new int[5];


D. a = new int[10];

int[] a = new int[5];


E. a.GetUpperBound(10);

Answer & Explanation

Answer: Option D

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

5. How will you complete the foreach loop in the C#.NET code snippet given below such that it
correctly prints all elements of the array a?

int[][]a = new int[2][];


a[0] = new int[4]{6, 1 ,4, 3};
a[1] = new int[3]{9, 2, 7};
foreach (int[ ] i in a)
{
/* Add loop here */
Console.Write(j + " ");
Console.WriteLine();
}

A. foreach (int j = 1; j < a(0).GetUpperBound; j++)

B. foreach (int j = 1; j < a.GetUpperBound (0); j++)

C. foreach (int j in a.Length)

D. foreach (int j in i)

E. foreach (int j in a.Length -1)

Answer & Explanation


Answer: Option D

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

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

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


Console.WriteLine(a.Length);

A. 20 B. 4

C. 18 D. 10

E. 5

Answer & Explanation

Answer: Option C

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

7. Which of the following statements are correct about arrays used in C#.NET?

1. Arrays can be rectangular or jagged.


2. Rectangular arrays have similar rows stored in adjacent memory locations.
3. Jagged arrays do not have an access to the methods of System.Array Class.
4. Rectangular arrays do not have an access to the methods of System.ArrayClass.
5. Jagged arrays have dissimilar rows stored in non-adjacent memory locations.

A. 1, 2

B. 1, 3, 5

C. 3, 4

D. 1, 2, 5
E. 4, 5

Answer & Explanation

Answer: Option D

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

8. Which of the following statements are correct about the C#.NET code snippet given below?

int[][]intMyArr = new int[2][];


intMyArr[0] = new int[4]{6, 1, 4, 3};
intMyArr[1] = new int[3]{9, 2, 7};

A. intMyArr is a reference to a 2-D jagged array.

B. The two rows of the jagged array intMyArr are stored in adjacent memory locations.

intMyArr[0] refers to the zeroth 1-D array and intMyArr[1] refers to the first 1-D
C.
array.

D. intMyArr refers to intMyArr[0] and intMyArr[1].

E. intMyArr refers to intMyArr[1] and intMyArr[2].

Answer & Explanation

Answer: Option C

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

9. Which of the following are the correct ways to define an array of 2 rows and 3 columns?

1. int[ , ] a;
2. a = new int[2, 3]{{7, 1, 3},{2, 9, 6}};
3. int[ , ] a;
4. a = new int[2, 3]{};
5. int[ , ] a = {{7, 1, 3}, {2, 9,6 }};
6. int[ , ] a;
7. a = new int[1, 2];
8. int[ , ] a;
9. a = new int[1, 2]{{7, 1, 3}, {2, 9, 6}};

A. 1, 2 , 3

B. 1, 3

C. 2, 3

D. 2, 4, 5

E. 4, 5

Answer & Explanation

Answer: Option B

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

10. Which of the following statements is correct about the array declaration given below?

int[][][] intMyArr = new int[2][][];

A. intMyArr refers to a 2-D jagged array containing 2 rows.

B. intMyArr refers to a 2-D jagged array containing 3 rows.

C. intMyArr refers to a 3-D jagged array containing 2 2-D jagged arrays.

D. intMyArr refers to a 3-D jagged array containing three 2-D jagged arrays.

E. intMyArr refers to a 3-D jagged array containing 2 2-D rectangular arrays.

Answer & Explanation

Answer: Option C

Explanation:
No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

Prev 123 Next

11. Which of the following statements is correct about the C#.NET code snippet given below?

int[] intMyArr = {11, 3, 5, 9, 4};

A. intMyArr is a reference to an object of System.Array Class.

intMyArr is a reference to an object of a class that the compiler derives


B.
fromSystem.Array Class.

C. intMyArr is a reference to an array of integers.

D. intMyArr is a reference to an object created on the stack.

E. intMyArr is a reference to the array created on the stack.

Answer & Explanation

Answer: Option B

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

12. Which of the following is the correct way to define and initialise an array of 4 integers?

1. int[] a = {25, 30, 40, 5};


2. int[] a;
3. a = new int[3];
4. a[0] = 25;
5. a[1] = 30;
6. a[2] = 40;
7. a[3] = 5;
8. int[] a;
9. a = new int{25, 30, 40, 5};
10. int[] a;
11. a = new int[4]{25, 30, 40, 5};
12. int[] a;
13. a = new int[4];
14. a[0] = 25;
15. a[1] = 30;
16. a[2] = 40;
17. a[3] = 5;

A. 1, 2

B. 3, 4

C. 1, 4, 5

D. 2, 4, 5

E. 5, 5

Answer & Explanation

Answer: Option C

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

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

int[][] a = new int[2][];


a[0] = new int[4]{6, 1, 4, 3};
a[1] = new int[3]{9, 2, 7};
Console.WriteLine(a[1].GetUpperBound(0));

A. 3 B. 4

C. 7 D. 9

E. 2

Answer & Explanation

Answer: Option E

Explanation:

No answer description available for this question. Let us discuss.


View Answer Workspace Report Discuss in Forum

14. Which of the following is the correct way to obtain the number of elements present in the array
given below?

int[] intMyArr = {25, 30, 45, 15, 60};

1. intMyArr.GetMax;
2. intMyArr.Highest(0);
3. intMyArr.GetUpperBound(0);
4. intMyArr.Length;
5. intMyArr.GetMaxElements(0);

A. 1, 2

B. 3, 4

C. 3, 5

D. 1, 5

E. 4, 5

Answer & Explanation

Answer: Option B

Explanation:

using System;

public class Test


{
public static void Main()
{
int[] intMyArr = { 25, 30, 45, 15, 60, 78, 99 };
Console.WriteLine(intMyArr.Length);
Console.WriteLine(intMyArr.GetUpperBound(0)+1);
}
}
/*
Output :
7
7
*/
View Answer Workspace Report Discuss in Forum

15. What will be the output of the C#.NET code snippet given below?

namespace IndiabixConsoleApplication
{
class SampleProgram
{
static void Main(string[ ] args)
{
int i, j;
int[ , ] arr = new int[ 2, 2 ];
for(i = 0; i < 2; ++i)
{
for(j = 0; j < 2; ++j)
{
arr[i, j] = i * 17 + i * 17;
Console.Write(arr[ i, j ] + " ");
}
}
}
}
}

A. 0 0 34 34

B. 0 0 17 17

C. 0000

D. 17 17 0 0

E. 34 34 0 0

Answer & Explanation

Answer: Option A

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum


ATTRIBUTES

1. The [Serializable()] attribute gets inspected at

A. Compile-time

B. Run-time

C. Design-time

D. Linking-time

E. None of the above

Answer & Explanation

Answer: Option B

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

2. Which of the following are correct ways to specify the targets for a custom attribute?

A. By applying AttributeUsage to the custom attribute's class definition.

B. By applying UsageAttribute to the custom attribute's class definition.

C. Once an attribute is declared it applies to all the targets.

D. By applying AttributeUsageAttribute to the custom attribute's class definition.

E. None of the above.

Answer & Explanation

Answer: Option D

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum


3. Which of the following are correct ways to pass a parameter to an attribute?

1. By value
2. By reference
3. By address
4. By position
5. By name

A. 1, 2

B. 1, 2, 3

C. 4, 5

D. All of the above

Answer & Explanation

Answer: Option C

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

4. Which of the following statements are correct about inspecting an attribute in C#.NET?

1. An attribute can be inspected at link-time.


2. An attribute can be inspected at compile-time.
3. An attribute can be inspected at run-time.
4. An attribute can be inspected at design-time.

A. 1, 2

B. 3, 4

C. 1, 3, 4

D. All of the above

E. None of the above

Answer & Explanation


Answer: Option A

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

5. Which of the following is correct ways of applying an attribute?

[WebService (Name = "IndiaBIX", Description = "BIX WebService")]


A. class AuthenticationService: WebService
{ /* .... */}

<WebService ( Name : "IndiaBIX", Description : "BIX WebService" )>


B. class AuthenticationService: inherits WebService
{ /* .... */}

<WebService ( Name = "IndiaBIX", Description = "BIX WebService" )>


C. class AuthenticationService: extends WebService
{ /* .... */}

[WebService ( Name := "IndiaBIX", Description := "BIX


WebService")]
D. class AuthenticationService: inherits WebService
{ /* .... */}

Answer & Explanation

Answer: Option A

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

123 Next

6. Which of the following statements are correct about Attributes used in C#.NET?

A. If there is a custom attribute BugFixAttribute then the compiler will


look ONLY for the BugFix attribute in the code that uses this attribute.

To create a custom attribute we need to create a custom attribute


B.
structure and derive it from System.Attribute.

To create a custom attribute we need to create a class and


C.
implementIAttribute interface in it.

If a BugFixAttribute is to receive three parameters then


D. theBugFixAttribute class should implement a zero-argument
constructor.

The CLR can change the behaviour of the code depending upon the
E.
attributes applied to it.

Answer & Explanation

Answer: Option E

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

7. Which of the following forms of applying an attribute is correct?

< Serializable() > class sample


A. { /* ... */ }

(Serializable()) class sample


B. { /* ... */ }

[ Serializable() ] class sample


C. { /* ... */ }

Serializablef) class sample


D. { /* ... */ }

E. None of the above

Answer & Explanation

Answer: Option C
Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

8. Which of the following statements are correct about Attributes in C#.NET?

1. On compiling a C#.NET program the attibutes applied are recorded in the


metadata of the assembly.
2. On compilation all the attribute's tags are deleted from the program.
3. It is not possible to create custom attributes..
4. The attributes applied can be read from an assembly using Reflection
class.
5. An attribute can have parameters.

A. 1 and 2 only

B. 2 and 4 only

C. 1, 4 and 5 only

D. All of the above

E. None of the above

Answer & Explanation

Answer: Option C

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

9. Which of the following correctly describes the contents of the filename


AssemblyInfo.cs?

A. It contains method-level attributes.

B. It contains class-level attributes.

C. It contains assembly-level attributes.


D. It contains structure-level attributes.

E. It contains namespace-level attributes.

Answer & Explanation

Answer: Option C

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

10. It possible to create a custom attribute that can be applied only to specific
programming element(s) like ____ .

A. Classes

B. Methods

C. Classes and Methods

D. Classes, Methods and Member-Variables

Answer & Explanation

Answer: Option C

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

11. Which of the following CANNOT be a


target for a custom attribute?

A. Enum B. Event

C. Delegate D. Interface

E. Namespace

Answer & Explanation

Answer: Option E
Explanation:

No answer description available for this


question. Let us discuss.

View Answer Workspace Report Discuss in


Forum

12. Once applied which of the following CANNOT inspect the applied attribute?

A. CLR

B. Linker

C. ASP.NET Runtime

D. Visual Studio.NET

E. Language compilers

Answer & Explanation

Answer: Option B

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

13. Which of the following is the correct way to apply an attribute to an Assembly?

A. [ AssemblyDescription("DCube Component Library") ]

B. [ assembly : AssemblyDescription("DCube Component Library") ]

C. [ Assemblylnfo : AssemblyDescription("DCube Component Library") ]

D. < Assembly: AssemblyDescription("DCube Component Library") >

E. (Assembly: AssemblyDescription("DCube Component Library"))

Answer & Explanation

Answer: Option B
Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

14. Which of the following is the correct way of applying the custom attribute called Tested which
receives two-arguments - name of the tester and the testgrade?

1. Custom attribute cannot be applied to an assembly.


2. [assembly: Tested("Sachin", testgrade.Good)]
3. [Tested("Virat", testgrade.Excellent)]
class customer { /* .... */ }
4. Custom attribute cannot be applied to a method.
5. Custom attribute cannot be applied to a class.

A. 1 only

B. 1, 5

C. 2, 3

D. 4, 5

E. None of the above

Answer & Explanation

Answer: Option C

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

15. Attributes can be applied to

1. Method
2. Class
3. Assembly
4. Namespace
5. Enum

A. 1 and 2 only
B. 1, 2 and 3

C. 4 and 5 only

D. All of the above

E. None of the above

Answer & Explanation

Answer: Option B

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

CLASSES AND OBJECTS

1. Which of the following statements is correct about the C#.NET code snippet given below?

class Student s1, s2; // Here 'Student' is a user-defined class.


s1 = new Student();
s2 = new Student();

A. Contents of s1 and s2 will be exactly same.

B. The two objects will get created on the stack.

C. Contents of the two objects created will be exactly same.

D. The two objects will always be created in adjacent memory locations.

E. We should use delete() to delete the two objects from memory.

Answer & Explanation

Answer: Option C

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum


2. Which of the following statements is correct about the C#.NET code snippet given below?

class Sample
{
private int i;
public Single j;
private void DisplayData()
{
Console.WriteLine(i + " " + j);
}
public void ShowData()
{
Console.WriteLine(i + " " + j);
}
}

A. j cannot be declared as public.

B. DisplayData() cannot be declared as private.

C. DisplayData() cannot access j.

D. ShowData() cannot access to i.

E. There is no error in this class.

Answer & Explanation

Answer: Option E

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

3. Which of the following statements are correct?

1. Instance members of a class can be accessed only through an object of thatclass.


2. A class can contain only instance data and instance member function.
3. All objects created from a class will occupy equal number of bytes in memory.
4. A class can contain Friend functions.
5. A class is a blueprint or a template according to which objects are created.

A. 1, 3, 5
B. 2, 4

C. 3, 5

D. 2, 4, 5

E. None of these

Answer & Explanation

Answer: Option A

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

4. Which of the following statements is correct?

A. Procedural Programming paradigm is different than structured programming paradigm.

Object Oriented Programming paradigm stresses on dividing the logic into smaller parts
B.
and writing procedures for each part.

C. Classes and objects are corner stones of structured programming paradigm.

Object Oriented Programming paradigm gives equal importance to data and the
D.
procedures that work on the data.

E. C#.NET is a structured programming language.

Answer & Explanation

Answer: Option D

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

5. Which of the following is the correct way to create an object of the class Sample?

1. Sample s = new Sample();


2. Sample s;
3. Sample s; s = new Sample();
4. s = new Sample();

A. 1, 3

B. 2, 4

C. 1, 2, 3

D. 4, 5

E. None of these

Answer & Explanation

Answer: Option A

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

6. Which of the following will be the correct output for the C#.NET program given below?

namespace IndiabixConsoleApplication
{
class Sample
{
int i;
Single j;
public void SetData(int i, Single j)
{
i = i;
j = j;
}
public void Display()
{
Console.WriteLine(i + " " + j);
}
}
class MyProgram
{
static void Main(string[ ] args)
{
Sample s1 = new Sample();
s1.SetData(10, 5.4f);
s1.Display();
}
}
}

A. 00

B. 10 5.4

C. 10 5.400000

D. 10 5

E. None of the above

Answer & Explanation

Answer: Option A

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

7. The this reference gets created when a member function (non-shared) of a class is called.

A. True B. False

Answer & Explanation

Answer: Option A

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

8. Which of the following statements are correct?

1. Data members ofa class are by default public.


2. Data members of a class are by default private.
3. Member functions of a class are by default public.
4. A private function of a class can access a public function within the same class.
5. Member function of a class are by default private.
A. 1, 3, 5

B. 1, 4

C. 2, 4, 5

D. 1, 2, 3

E. None of these

Answer & Explanation

Answer: Option C

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

9. Which of the following statements is correct about the C#.NET code snippet given below?

namespace IndiabixConsoleApplication
{
class Sample
{
public int index;
public int[] arr = new int[10];

public void fun(int i, int val)


{
arr[i] = val;
}
}

class MyProgram
{
static void Main(string[] args)
{
Sample s = new Sample();
s.index = 20;
Sample.fun(1, 5);
s.fun(1, 5);
}
}
}
A. s.index = 20 will report an error since index is public.

B. The call s.fun(1, 5) will work correctly.

C. Sample.fun(1, 5) will set a value 5 in arr[ 1 ].

D. The call Sample.fun(1, 5) cannot work since fun() is not a shared function.

E. arr being a data member, we cannot declare it as public.

Answer & Explanation

Answer: Option B

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

10. Which of the following statements are correct about the C#.NET code snippet given below?

sample c;
c = new sample();

1. It will create an object called sample.


2. It will create a nameless object of the type sample.
3. It will create an object of the type sample on the stack.
4. It will create a reference c on the stack and an object of the type sample on the heap.
5. It will create an object of the type sample either on the heap or on the stack depending on
the size of the object.

A. 1, 3

B. 2, 4

C. 3, 5

D. 4, 5

E. None of these

Answer & Explanation


Answer: Option B

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

11. Which of the following statements is correct about the C#.NET code snippet given below?

int i;
int j = new int();
i = 10;
j = 20;
String str;
str = i.ToString();
str = j.ToString();

A. This is a perfectly workable code snippet.

B. Since int is a primitive, we cannot use new with it.

C. Since an int is a primitive, we cannot call the method ToString() using it.

D. i will get created on stack, whereas j will get created on heap.

E. Both i and j will get created on heap.

Answer & Explanation

Answer: Option A

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

12. Which of the following statements are correct about the this reference?

1. this reference can be modified in the instance member function of a class.


2. Static functions of a class never receive the this reference.
3. Instance member functions of a class always receive a this reference.
4. this reference continues to exist even after control returns from an instance member
function.
5. While calling an instance member function we are not required to pass the thisreference
explicitly.

A. 1, 4

B. 2, 3, 5

C. 3, 4

D. 2, 5

E. None of these

Answer & Explanation

Answer: Option B

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

13. Which of the following will be the correct output for the C#.NET program given below?

namespace IndiabixConsoleApplication
{
class Sample
{
int i;
Single j;
public void SetData(int i, Single j)
{
this.i = i;
this.j = j;
}
public void Display()
{
Console.WriteLine(i + " " + j);
}
}
class MyProgram
{
static void Main(string[ ] args)
{
Sample s1 = new Sample();
s1.SetData(36, 5.4f);
s1.Display();
}
}
}

A. 0 0.0

B. 36 5.4

C. 36 5.400000

D. 36 5

E. None of the above

Answer & Explanation

Answer: Option B

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

14. Which of the following statements are correct about objects of a user-defined class calledSample?

1. All objects of Sample class will always have exactly same data.
2. Objects of Sample class may have same or different data.
3. Whether objects of Sample class will have same or different data depends upon a Project
Setting made in Visual Studio.NET.
4. Conceptually, each object of Sample class will have instance data and instance member
functions of the Sample class.
5. All objects of Sample class will share one copy of member functions.

A. 1, 3

B. 2, 4

C. 4, 5

D. 3, 5

E. None of these

Answer & Explanation


Answer: Option C

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

15. Which of the following statements are correct about the C#.NET code snippet given below?

namespace IndiabixConsoleApplication
{
class Sample
{
int i, j;
public void SetData(int ii, int jj)
{
this.i = ii;
this.j = jj
}
}
class MyProgram
{
static void Main(string[ ] args)
{
Sample s1 = new Sample();
s1.SetData(10, 2);
Sample s2 = new Sample();
s2.SetData(5, 10);
}
}
}

A. The code will not compile since we cannot explicitly use this.

B. Using this in this program is necessary to properly set the values in the object.

The call to SetData() is wrong since we have not explicitly passed the thisreference
C.
to it.

The definition of SetData() is wrong since we have not explicitly collected


D.
thethis reference.

E. Contents of this will be different during each call to SetData().

Answer & Explanation


Answer: Option E

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

Prev 1234 Next

16. Which of the following statements is correct about classes and objects in C#.NET?

A. Class is a value type.

B. Since objects are typically big in size, they are created on the stack.

C. Objects of smaller size are created on the heap.

D. Smaller objects that get created on the stack can be given names.

E. Objects are always nameless.

Answer & Explanation

Answer: Option E

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

COLLECTION CLASSES

1. Which of the following statements are correct about an ArrayList collection that implements
the IEnumerable interface?

1. The ArrayList class contains an inner class that implements the IEnumeratorinterface.
2. An ArrayList Collection cannot be accessed simultaneously by different threads.
3. The inner class of ArrayList can access ArrayList class's members.
4. To access members of ArrayList from the inner class, it is necessary to
passArrayList class's reference to it.
5. Enumerator's of ArrayList Collection can manipulate the array.

A. 1 and 2 only

B. 1 and 3 and 4 only

C. 2 and 5 only

D. All of the above

E. None of the above

Answer & Explanation

Answer: Option B

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

2. How many enumerators will exist if four threads are simultaneously working on
anArrayList object?

A. 1

B. 3

C. 2

D. 4

E. Depends upon the Project Setting made in Visual Studio.NET.

Answer & Explanation

Answer: Option D

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum


3. In which of the following collections is the Input/Output index-based?

1. Stack
2. Queue
3. BitArray
4. ArrayList
5. HashTable

A. 1 and 2 only

B. 3 and 4 only

C. 5 only

D. 1, 2 and 5 only

E. All of the above

Answer & Explanation

Answer: Option B

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

4. In which of the following collections is the Input/Output based on a key?

1. Map
2. Stack
3. BitArray
4. HashTable
5. SortedList

A. 1 and 2 only

B. 2 and 3 only

C. 1, 2 and 3 only

D. 4 and 5 only
E. All of the above

Answer & Explanation

Answer: Option D

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

5. In a HashTable Key cannot be null, but Value can be.

A. True B. False

Answer & Explanation

Answer: Option A

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace

6. Which of the following statements are correct about the C#.NET code snippet given below?

Stack st = new Stack();


st.Push("hello");
st.Push(8.2);
st.Push(5);
st.Push('b');
st.Push(true);

Dissimilar elements like "hello", 8.2, 5 cannot be stored in the


A.
same Stackcollection.

B. Boolean values can never be stored in Stack collection.

C. In the fourth call to Push(), we should write "b" in place of 'b'.

To store dissimilar elements in a Stack collection, a method PushAnyType()should be


D.
used in place of Push().

E. This is a perfectly workable code.

Answer & Explanation


Answer: Option E

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

7. Which of the following statements are correct about the Stack collection?

1. It can be used for evaluation of expressions.


2. All elements in the Stack collection can be accessed using an enumerator.
3. It is used to maintain a FIFO list.
4. All elements stored in a Stack collection must be of similar type.
5. Top-most element of the Stack collection can be accessed using the Peek()method.

A. 1 and 2 only

B. 3 and 4 only

C. 1, 2 and 5 only

D. All of the above

E. None of the above

Answer & Explanation

Answer: Option C

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

8. A HashTable t maintains a collection of names of states and capital city of each state. Which of
the following is the correct way to find out whether "Kerala" state is present in this collection or
not?

A. t.ContainsKey("Kerala");

B. t.HasValue("Kerala");
C. t.HasKey("Kerala");

D. t.ContainsState("Kerala");

E. t.ContainsValue("Kerala");

Answer & Explanation

Answer: Option A

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

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

Queue q = new Queue();


q.Enqueue("Sachin");
q.Enqueue('A');
q.Enqueue(false);
q.Enqueue(38);
q.Enqueue(5.4);

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

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

IEnumerator e;
e = q.GetEnumerable();
C. while (e.MoveNext())
Console.WriteLine(e.Current);

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

Answer & Explanation

Answer: Option A

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

10. Which of the following is NOT an interface declared in System.Collectionsnamespace?

A. IComparer

B. IEnumerable

C. IEnumerator

D. IDictionaryComparer

E. IDictionaryEnumerator

Answer & Explanation

Answer: Option D

Explanation:

No answer d
11. Suppose value of the Capacity property of ArrayList Collection is set to 4. What will be the
capacity of the Collection on adding fifth element to it?

A. 4 B. 8

C. 16 D. 32

Answer & Explanation

Answer: Option B

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum


12. Which of the following is an ordered collection class?

1. Map
2. Stack
3. Queue
4. BitArray
5. HashTable

A. 1 only

B. 2 and 3 only

C. 4 and 5 only

D. All of the above

E. None of the above

Answer & Explanation

Answer: Option B

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

13. Which of the following is the correct way to find out the number of elements currently present in
an ArrayList Collection called arr?

A. arr.Count

B. arr.GrowSize

C. arr.MaxIndex

D. arr.Capacity

E. arr.UpperBound

Answer & Explanation

Answer: Option A
Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

14. Which of the following statements are correct about a HashTable collection?

1. It is a keyed collection.
2. It is a ordered collection.
3. It is an indexed collection.
4. It implements a IDictionaryEnumerator interface in its inner class.
5. The key - value pairs present in a HashTable can be accessed using
the Keysand Values properties of the inner class that implements
theIDictionaryEnumerator interface.

A. 1 and 2 only

B. 1, 2 and 3 only

C. 4 and 5 only

D. 1, 4 and 5 only

E. All of the above

Answer & Explanation

Answer: Option D

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

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

Stack st = new Stack();


st.Push(11);
st.Push(22);
st.Push(-53);
st.Push(33);
st.Push(66);
IEnumerable e;
e = st.GetEnumerator();
A. while (e.MoveNext())
Console.WriteLine(e.Current);

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

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

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

Answer & Explanation

Answer: Option C

Explanation:

No answer description available for this question. Let us discuss.

View Answer

Which of the following statements are correct about the Collection Classes available in Framework
Class Library?

A. Elements of a collection cannot be transmitted over a network.

B. Elements stored in a collection can be retrieved but cannot be modified.

C. It is not easy to adopt the existing Collection classes for newtype of objects.

D. Elements stored in a collection can be modified only if allelements are of similar types.

They use efficient algorithms to manage the collection, thereby improving the
E.
performance of the program.

Answer & Explanation


Answer: Option E

DATATYPES

1. Which of the following statements are correct about data types?

1. If the integer literal exceeds the range of byte, a compilation error will occur.
2. We cannot implicitly convert non-literal numeric types of larger storage size tobyte.
3. Byte cannot be implicitly converted to float.
4. A char can be implicitly converted to only int data type.
5. We can cast the integral character codes.

A. 1, 3, 5

B. 2, 4

C. 3, 5

D. 1, 2, 5

Answer & Explanation

Answer: Option D

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

2. Which of the following is an 8-byte Integer?

A. Char

B. Long

C. Short

D. Byte

E. Integer

Answer & Explanation


Answer: Option B

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

3. Which of the following is NOT an Integer?

A. Char

B. Byte

C. Integer

D. Short

E. Long

Answer & Explanation

Answer: Option A

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

4. Which of the following statements is correct?

A. Information is never lost during narrowing conversions.

B. The CInteger() function can be used to convert a Single to an Integer.

C. Widening conversions take place automatically.

D. Assigning an Integer to an Object type is known as Unboxing.

E. 3.14 can be treated as Decimal by using it in the form 3.14F.

Answer & Explanation

Answer: Option C
Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

5. Which of the following are value types?

1. Integer
2. Array
3. Single
4. String
5. Long

A. 1, 2, 5

B. 1, 3, 5

C. 2, 4

D. 3, 5

Answer & Explanation

Answer: Option B

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

1234 Next

6. Which of the following does not store a sign?

A. Short

B. Integer

C. Long

D. Byte
E. Single

Answer & Explanation

Answer: Option D

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

7. What is the size of a Decimal?

A. 4 byte

B. 8 byte

C. 16 byte

D. 32 byte

Answer & Explanation

Answer: Option C

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

8. 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.WriteLine((float) x + y * z - (x += (short) y));

A. 0.1 B. 1.0

C. 1.1 D. 11

Answer & Explanation

Answer: Option A
Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

9. Which of the following statements is correct about the C#.NET code snippet given below?

short s1 = 20;
short s2 = 400;
int a;
a = s1 * s2;

A. A value 8000 will be assigned to a.

B. A negative value will be assigned to a.

During arithmetic if the result exceeds the high or low value of the range the value
C.
wraps around till the other side of the range.

D. An error is reported as widening conversion cannot takes place.

An overflow error will be reported since the result of the multiplication exceeds the
E.
range of a Short Integer.

Answer & Explanation

Answer: Option A

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

10. Which of the following is the correct size of a Decimal datatype?

A. 8 Bytes

B. 4 Bytes

C. 10 Bytes

D. 16 Bytes
E. None of the above.

Answer & Explanation

Answer: Option D

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

Prev 1234 Next

11. Which of the following statements are correct?

1. We can assign values of any type to variables of type object.


2. When a variable of a value type is converted to object, it is said to be unboxed.
3. When a variable of type object is converted to a value type, it is said to be boxed.
4. Boolean variable cannot have a value of null.
5. When a value type is boxed, an entirely new object must be allocated and constructed.

A. 2, 5

B. 1, 5

C. 3, 4

D. 2, 3

Answer & Explanation

Answer: Option B

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

12. Which of the following is the correct ways to set a value 3.14 in a variable pi such that it cannot
be modified?

A. float pi = 3.14F;
B. #define pi 3.14F;

C. const float pi = 3.14F;

D. const float pi; pi = 3.14F;

E. pi = 3.14F;

Answer & Explanation

Answer: Option C

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

13. Which of the following statements are correct about data types?

1. Each value type has an implicit default constructor that initializes the default value of that
type.
2. It is possible for a value type to contain the null value.
3. All value types are derived implicitly from System.ValueType class.
4. It is not essential that local variables in C# must be initialized before being used.
5. Variables of reference types referred to as objects and store references to the actual data.

A. 1, 3, 5

B. 2, 4

C. 3, 5

D. 2, 3, 4

Answer & Explanation

Answer: Option A

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum


14. Which of the following are the correct way to initialise the variables i and j to a value 10 each?

1. int i = 10; int j = 10;


2. int i, j;
3. i = 10 : j = 10;
4. int i = 10, j = 10;
5. int i, j = 10;
6. int i = j = 10;

A. 2, 4

B. 1, 3

C. 3, 5

D. 4, 5

Answer & Explanation

Answer: Option B

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

15. Which of the following statement correctly assigns a value 33 to a variable c?

byte a = 11, b = 22, c;

A. c = (byte) (a + b);

B. c = (byte) a + (byte) b;

C. c = (int) a + (int) b;

D. c = (int)(a + b);

E. c = a + b;

Answer & Explanation

Answer: Option A
Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

Prev 1234 Next

16. Which of the following statements are correct about datatypes in C#.NET?

1. Every datatype is either a value type or a reference type.


2. Value types are always created on the heap.
3. Reference types are always created on the stack.
4. Mapping of every value type to a type in Common Type System facilitates Interoperability
in C#.NET.
5. Every reference type gets mapped to a type in Common Type System.

A. 1, 3

B. 2, 5

C. 1, 4

D. 3, 4

Answer & Explanation

Answer: Option C

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

17. Which of the following is the correct default value of a Boolean type?

A. 0 B. 1

C. True D. False

E. -1

Answer & Explanation


Answer: Option D

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

Prev 1234

ENUMERATION

1. Which of the following statements are correct about an enum used inC#.NET?

1. By default the first enumerator has the value equal to the number of elements present in
the list.
2. The value of each successive enumerator is decreased by 1.
3. An enumerator contains white space in its name.
4. A variable cannot be assigned to an enum element.
5. Values of enum elements cannot be populated from a database.

A. 1, 2

B. 3, 4

C. 4, 5

D. 1, 4

Answer & Explanation

Answer: Option C

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

2. Which of the following statements is correct about the C#.NET code snippet given below?
int a = 10;
int b = 20;
int c = 30;
enum color: byte
{
red = a,
green = b,
blue = c
}

A. Variables cannot be assigned to enum elements.

B. Variables can be assigned to any one of the enum elements.

C. Variables can be assigned only to the first enum element.

D. Values assigned to enum elements must always be successive values.

E. Values assigned to enum elements must always begin with 0.

Answer & Explanation

Answer: Option A

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

3. Which of the following statements is true about an enum used in C#.NET?

A. An implicit cast is needed to convert from enum type to an integral type.

B. An enum variable cannot have a public access modifier.

C. An enum variable cannot have a private access modifier.

D. An enum variable can be defined inside a class or a namespace.

E. An enum variable cannot have a protected access modifier.

Answer & Explanation

Answer: Option D
Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

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

enum color
{
red,
green,
blue
}
color c;
c = color.red;
Console.WriteLine(c);

A. 1 B. -1

C. red D. 0

E. color.red

Answer & Explanation

Answer: Option C

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

5. Which of the following statements are correct about an enum used inC#.NET?

1. To use the keyword enum, we should either use [enum] or System.Enum.


2. enum is a keyword.
3. Enum is class declared in System.Type namespace.
4. Enum is a class declared in the current project's root namespace.
5. Enum is a class declared in System namespace.

A. 1, 3

B. 2, 4
C. 2, 5

D. 3, 4

Answer & Explanation

Answer: Option C

Explanation:
6. Which of the following will be the correct output for the C#.NET code snippet given below?

enum color : int


{
red = -3,
green,
blue
}
Console.Write( (int) color.red + ", ");
Console.Write( (int) color.green + ", ");
Console.Write( (int) color.blue );

A. -3, -2, -1

B. -3, 0, 1

C. 0, 1, 2

D. red, green, blue

E. color.red, color.green, color.blue

Answer & Explanation

Answer: Option A

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

7. An enum that is declared inside a class, struct, namespace or interface is treated as public.

A. True B. False

Answer & Explanation


Answer: Option A

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

8. Which of the following statements is correct about the C#.NET code snippet given below?

enum per
{
married,
unmarried,
divorced,
spinster
}
per.married = 10;
Console.WriteLine(per.unmarried);

A. The program will output a value 11.

B. The program will output a value 1.

C. The program will output a value 2.

The program will report an error since an enum element cannot be assigned a value
D.
outside the enum declaration.

E. The enum elements must be declared private.

Answer & Explanation

Answer: Option D

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

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

enum color: int


{
red,
green,
blue = 5,
cyan,
magenta = 10,
yellow
}
Console.Write( (int) color.green + ", " );
Console.Write( (int) color.yellow );

A. 2, 11

B. 1, 11

C. 2, 6

D. 1, 5

E. None of the above

Answer & Explanation

Answer: Option B

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

10. An enum can be declared inside a class, struct, namespace or interface.

A. True B. False

Answer & Explanation

Answer: Option A

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Re

11. Which of the following CANNOT be used as an underlying datatype for an enum in C#.NET?

A. byte
B. short

C. float

D. int

Answer & Explanation

Answer: Option C

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

12. Which of the following statements are correct about enum used in C#.NET?

1. Every enum is derived from an Object class.


2. Every enum is a value type.
3. There does not exist a way to print an element of an enum as a string.
4. Every enum is a reference type.
5. The default underlying datatype of an enum is int.

A. 1, 2, 5

B. 1, 4

C. 3, 5

D. 2, 3, 4

Answer & Explanation

Answer: Option A

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

13. Which of the following statements is correct about the C#.NET code snippet given below?

enum color : byte


{
red = 500,
green = 1000,
blue = 1500
}

A. byte values cannot be assigned to enum elements.

B. enum elements should always take successive values.

C. Since 500, 1000, 1500 exceed the valid range of byte compiler will report an error.

D. enum must always be of int type.

E. enum elements should be declared as private.

Answer & Explanation

Answer: Option C

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

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

enum color
{
red,
green,
blue
}
color c = color.red;
Type t;
t = c.GetType();
string[ ]str;
str = Enum.GetNames(t);
Console.WriteLine(str[ 0 ]);

A. red B. 0

C. 1 D. -1

E. color.red
View Answer Workspace Report Discuss in Forum

ANSWER : A

15. Which of the following statements are correct about the C#.NET code snippet given below?

namespace IndiabixConsoleApplication
(
class Sample
{
private enum color : int
{
red,
green,
blue
}
public void fun()
{
Console.WriteLine(color.red);
}
}
class Program
{
static void Main(string[ ] args)
{
// Use enum color here
}
}
}

1. To define a variable of type enum color in Main(), we should use the statement,color
c; .
2. enum color being private it cannot be used in Main().
3. We must declare enum color as public to be able to use it outside the class Sample.
4. To define a variable of type enum color in Main(), we should use the
statement,Sample.color c; .
5. We must declare private enum color outside the class to be able to use it inMain().

A. 1, 2, 3

B. 2, 3, 4

C. 3, 4

D. 4, 5
Answer & Explanation

Answer: Option B

16. Which of the following statements is correct about an enum used in C#.NET?

A. enum is a reference type.

B. enum is a value type.

C. Whether it a value type or a reference type depends upon size.

Whether it a value type or a reference type depends upon a Project Setting made in
D.
Visual Stiiclio.NET.

E. We can programmatically control whether it is a value type or a reference type.

Answer & Explanation

Answer: Option B

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

17. Which of the following statements are correct about an enum used in C#.NET?

1. An enum can be declared inside a class.


2. An enum can take Single, Double or Decimal values.
3. An enum can be declared outside a class.
4. An enum can be declared inside/outside a namespace.
5. An object can be assigned to an enum variable.

A. 1, 3, 4

B. 2, 5

C. 3, 4

D. 2, 4, 5

Answer & Explanation

Answer: Option A
EXCEPTION HANDLING

1. Which of the following is NOT a .NET Exception class?

A. Exception

B. StackMemoryException

C. DivideByZeroException

D. OutOfMemoryException

E. InvalidOperationException

Answer & Explanation

Answer: Option B

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

2. Which of the following statements is correct about an Exception?

A. It occurs during compilation.

B. It occurs during linking.

C. It occurs at run-time.

D. It occurs during Just-In-Time compilation.

E. It occurs during loading of the program.

Answer & Explanation

Answer: Option C
Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

3. In C#.NET if we do not catch the exception thrown at runtime then which of the following will
catch it?

A. Compiler

B. CLR

C. Linker

D. Loader

E. Operating system

Answer & Explanation

Answer: Option B

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

4. Which of the following statements is correct about the C#.NET program given below?

using System;
namespace IndiabixConsoleApplication
{
class MyProgram
{
static void Main(string[] args)
{
int index = 6;
int val = 44;
int[] a = new int[5];
try
{
a[index] = val ;
}
catch(IndexOutOfRangeException e)
{
Console.Write("Index out of bounds ");
}
Console.Write("Remaining program");
}
}
}

A. Value 44 will get assigned to a[6].

B. It will output: Index out of bounds

C. It will output: Remaining program

D. It will not produce any output.

E. It will output: Index out of bounds Remaining program

Answer & Explanation

Answer: Option E

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

5. Which of the following statements are correct about exception handling in C#.NET?

1. If an exception occurs then the program terminates abruptly without getting any chance
to recover from the exception.
2. No matter whether an exception occurs or not, the statements in the finallyclause (if
present) will get executed.
3. A program can contain multiple finally clauses.
4. A finally clause is written outside the try block.
5. finally clause is used to perform clean up operations like closing the network/database
connections.

A. 1 only

B. 2 only

C. 2 and 5 only

D. 3 and 4 only
E. None of the above

Answer & Explanation

Answer: Option C

6. Which of the following statements are correct about exception handling in C#.NET?

1. If our program does not catch an exception then the .NET CLR catches it.
2. It is possible to create user-defined exceptions.
3. All types of exceptions can be caught using the Exception class.
4. CLRExceptions is the base class for all exception classes.
5. For every try block there must be a corresponding finally block.

A. 1 and 2 only

B. 1, 2 and 3 only

C. 4 and 5 only

D. All of the above

E. None of the above

Answer & Explanation

Answer: Option B

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

7. Which of the following statements are correct about the exception reported below?
Unhandled Exception: System.lndexOutOfRangeException: Index was outside
the bounds of the array: at
IndiabixConsoleApplication.MyProgram.SetVal(Int32 index, Int32 val) in
D:\Sample\IndiabixConsoleApplication\MyProgram.cs:line 26 at
IndiabixConsoleApplication.MyProgram.Main(String[] args) in
D:\Sample\IndiabixConsoleApplication\MyProgram.cs:line 20

1. The CLR failed to handle the exception.


2. The class MyProgram belongs to the namespace MyProgram.
3. The function SetVal() was called from Main() in line number 20.
4. The exception occurred in line number 26 in the function SetVal()
5. The runtime exception occurred in the project IndiabixConsoleApplication.

A. 1 only

B. 1 and 2 only

C. 3, 4 and 5 only

D. All of the above

E. None of the above

Answer & Explanation

Answer: Option C

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

8. Which of the following is the Object Oriented way of handling run-time errors?

A. OnError

B. HERESULT

C. Exceptions

D. Error codes

E. Setjump and Longjump

Answer & Explanation

Answer: Option C

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

9. Which of the following statements is correct about the C#.NET program given below if a
value "6" is input to it?

using System;
namespace IndiabixConsoleApplication
{
class MyProgram
{
static void Main(string[] args)
{
int index;
int val = 44;
int[] a = new int[5];
try
{
Console.Write("Enter a number:");
index = Convert.Tolnt32(Console.ReadLine());
a[index] = val;
}
catch(FormatException e)
{
Console.Write("Bad Format");
}
catch(IndexOutOfRangeException e)
{
Console.Write("Index out of bounds");
}
Console.Write("Remaining program");
}
}
}

A. It will output: Index out of bounds Remaining program

B. It will output: Bad Format Remaining program

C. It will output: Bad Format

D. It will output: Remaining program

E. It will output: Index out of bounds

Answer & Explanation

Answer: Option A

Explanation:
No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

10. Which of the following statements are correct about the exception reported below?
Unhandled Exception: System.lndexOutOfRangeException:
Index was outside the bounds of the array.
at IndiabixConsoleApplication.Program.Main(String[] args) in
D:\ConsoleApplication\Program.cs:line 14

1. The program did not handle an exception called IndexOutOfRangeException.


2. The program execution continued after the exception occurred.
3. The exception occurred in line number 14.
4. In line number 14, the program attempted to access an array element which was
beyond the bounds of the array.
5. The CLR could not handle the exception.

A. 1 only

B. 1, 2 and 3 only

C. 2 and 5 only

D. 1, 3 and 4 only

E. None of the above

Answer & Explanation

Answer: Option D

Explanation:

No answer descrip
1. Which of the following statements are correct about exception handling in C#.NET?

1. try blocks cannot be nested.


2. In one function, there can be only one try block.
3. An exception must be caught in the same function in which it is thrown.
4. All values set up in the exception object are available in the catch block.
5. While throwing a user-defined exception multiple values can be set in the exception,
object.

A. 1 only
B. 1 and 2 only

C. 3 only

D. 4 and 5 only

E. All of the above

Answer & Explanation

Answer: Option D

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

12. Exceptions can be thrown even from a constructor, whereas error codes cannot be returned
from a constructor.

A. True B. False

Answer & Explanation

Answer: Option A

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

13. Which of the following statements is correct about the C#.NET program given below if a
value "6" is input to it?

using System;
namespace IndiabixConsoleApplication
{
class MyProgram
{
static void Main (string[] args)
{
int index;
int val = 66;
int[] a = new int[5];
try
{
Consote.Write("Enter a number: ");
index = Convert.ToInt32(Console.ReadLine());
a[index] = val;
}
catch(Exception e)
{
Console.Write("Exception occurred ");
}
Console.Write("Remaining program ");
}
}
}

A. It will output: Exception occurred

B. It will output: Remaining program

C. It will output: Exception occurred Remaining program

D. It will output: Remaining program Exception occurred

E. The value 66 will get assigned to a[6].

Answer & Explanation

Answer: Option C

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

14. Which of the following statements is correct about the C#.NET program given below if a
value "ABCD" is input to it?

using System;
namespace IndiabixConsoleApplication
{
class MyProgram
{
static void Main(string[] args)
{
int index;
int val = 55;
int[] a = new int[5];
try
{
Console.Write("Enter a number: ");
index = Convert.ToInt32(Console.ReadLine());
a[index] = val;
}
catch(FormatException e)
{
Console.Write("Bad Format ");
}
catch(IndexOutOfRangeException e)
{
Console.Write("Index out of bounds ");
}
Console.Write("Remaining program ");
}
}
}

A. It will output: Bad Format

B. It will output: Remaining program

C. It will output: Index out of bounds

D. It will output: Bad Format Remaining program

E. It will output: Index out of bounds Remaining program

Answer & Explanation

Answer: Option D

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

15. All code inside finally block is guaranteed to execute irrespective of whether an exception
occurs in the protected block or not.

A. True B. False

Answer & Explanation

Answer: Option A
Explanation:

No answer
6. Which of the following is NOT an Exception?

A. StackOverflow

B. Division By Zero

C. Insufficient Memory

D. Incorrect Arithmetic Expression

E. Arithmetic overflow or underflow

Answer & Explanation

Answer: Option D

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

17. Which of the following statements is correct about the C#.NET program given below if a
value "ABCD" is input to it?

using System;
namespace IndiabixConsoleApplication
{
class MyProgram
{
static void Main(string[] args)
{
int index;
int vat = 88;
int[] a = new int(5];
try
{
Console.Write("Enter a number: ");
index = Convert.Toint32(Console.ReadLine());
a[index] = val;
}
catch(Exception e)
{
Console.Write("Exception occurred");
}
Console.Write("Remaining program");
}
}
}

A. It will output: Exception occurred

B. It will output: Remaining program

C. It will output: Remaining program Exception occurred

D. It will output: Exception occurred Remaining program

E. The value 88 will get assigned to a[0].

Answer & Explanation

Answer: Option D

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

18. It is compulsory for all classes whose objects can be thrown with throw statement to be
derived from System.Exception class.

A. True B. False

Answer & Explanation

Answer: Option B

FUNCTIONS AND SUBROUTINES

1. Which of the following will be the correct output for the C#.NET program given below?

namespace IndiabixConsoleApplication
{
class SampleProgram
{
static void Main(string[] args)
{
int num = 1;
funcv(num);
Console.Write(num + ", ");
funcr(ref num);
Console.Write(num + ", ");
}
static void funcv(int num)
{
num = num + 10; Console.Write(num + ", ");
}
static void funcr (ref int num)
{
num = num + 10; Console.Write(num + ", ");
}
}
}

A. 1, 1, 1, 1,

B. 11, 1, 11, 11,

C. 11, 11, 11, 11,

D. 11, 11, 21, 11,

E. 11, 11, 21, 21,

Answer & Explanation

Answer: Option B

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

2. What will be the output of the C#.NET code snippet given below?

namespace IndiabixConsoleApplication
{
class SampleProgram
{
static void Main(string[] args)
{
int[]arr = newint[]{ 1, 2, 3, 4, 5 };
fun(ref arr);
}
static void fun(ref int[] a)
{
for (int i = 0; i < a.Length; i++)
{
a[i] = a[i] * 5;
Console.Write(a[ i ] + " ");
}
}
}
}

A. 12345

B. 6 7 8 9 10

C. 5 10 15 20 25

D. 5 25 125 625 3125

E. 6 12 18 24 30

Answer & Explanation

Answer: Option C

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

3. Which of the following statements are correct?

1. An argument passed to a ref parameter need not be initialized first.


2. Variables passed as out arguments need to be initialized prior to being passed.
3. Argument that uses params keyword must be the last argument of variable argument list
of a method.
4. Pass by reference eliminates the overhead of copying large data items.
5. To use a ref parameter only the calling method must explicitly use the refkeyword.

A. 1, 2

B. 2, 3
C. 3, 4

D. 4, 5

E. None of these

Answer & Explanation

Answer: Option C

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

4. A function returns a value, whereas a subroutine cannot return a value.

A. True B. False

Answer & Explanation

Answer: Option A

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

5. Which of the following statements are correct about functions and subroutines used in C#.NET?

1. A function cannot be called from a subroutine.


2. The ref keyword causes arguments to be passed by reference.
3. While using ref keyword any changes made to the parameter in the method will be
reflected in that variable when control passes back to the calling method.
4. A subroutine cannot be called from a function.
5. Functions and subroutines can be called recursively.

A. 1, 2, 4

B. 2, 3, 5

C. 3, 5
D. 4, 5

E. None of these

Answer & Explanation

Answer: Option B

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

12345 Next

6. Which of the following will be the correct output for the C#.NET program given below?

namespace IndiabixConsoleApplication
{
class SampleProgram
{
static void Main(string[] args)
{
int a = 5;
int s = 0, c = 0;
Proc(a, ref s, ref c);
Console.WriteLine(s + " " + c);
}
static void Proc(int x, ref int ss, ref int cc)
{
ss = x * x;
cc = x * x * x;
}
}
}

A. 00

B. 25 25

C. 125 125

D. 25 125
E. None of the above

Answer & Explanation

Answer: Option D

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

7. What will be the output of the C#.NET code snippet given below?

namespace IndiabixConsoleApplication
{
class SampleProgram
{
static void Main(string[ ] args)
{
int i = 10;
double d = 34.340;
fun(i);
fun(d);
}
static void fun(double d)
{
Console.WriteLine(d + " ");
}
}
}

A. 10.000000 34.340000

B. 10 34

C. 10 34.340

D. 10 34.34

Answer & Explanation

Answer: Option D

Explanation:
No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

8. Which of the following statements are correct?

1. C# allows a function to have arguments with default values.


2. C# allows a function to have variable number of arguments.
3. Omitting the return value type in method definition results into an exception.
4. Redefining a method parameter in the method's body causes an exception.
5. params is used to specify the syntax for a function with variable number of arguments.

A. 1, 3, 5

B. 3, 4, 5

C. 2, 5

D. 4, 5

E. None of these

Answer & Explanation

Answer: Option C

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

9. If a procedure fun() is to receive an int, a Single & a double and it is to return a decimal
then which of the following is the correct way of defining this procedure?

fun(int i, Single j, double k) decimal


A. { ... }

static decimal fun(int i, Single j, double k)


B. { ... }

fun(int i, Single j, double k)


C. {
...
return decimal;
}

static decimal fun(int i, Single j, double k) decimal


D. { ... }

E. A procedure can never return a value.

Answer & Explanation

Answer: Option E

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

10. If a function fun() is to receive an int, a Single & a double and it is to return a decimal
then which of the following is the correct way of defining this function?

decimal static fun(int i, Single j, double k)


A. { ... }

decimal fun(int i, Single j, double k)


B. { ... }

static decimal fun(int i, Single j, double k)


C. { ... }

static decimal fun(int i, Single j, double k) decimal


D. { ... }

static fun(int i, Single j, double k)


{
E. ...
return decimal;
}

Answer & Explanation

Answer: Option C
Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

Prev 12345 Next

11. Which of the following statements are correct about functions used in C#.NET?

1. Function definitions cannot be nested.


2. Functions can be called recursively.
3. If we do not return a value from a function then a value -1 gets returned.
4. To return the control from middle of a function exit function should be used.
5. Function calls can be nested.

A. 1, 2, 5

B. 2, 3, 5

C. 2, 3

D. 4, 5

E. None of these

Answer & Explanation

Answer: Option A

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

12. How many values is a function capable of returning?

A. 1

B. 0

C. Depends upon how many params arguments does it use.


D. Any number of values.

E. Depends upon how many ref arguments does it use.

Answer & Explanation

Answer: Option A

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

13. What will be the output of the C#.NET code snippet given below?

namespace IndiabixConsoleApplication
{
class SampleProgram
{
static void Main(string[ ] args)
{
object[] o = new object[] {"1", 4.0, "India", 'B'};
fun (o);
}
static void fun (params object[] obj)
{
for (int i = 0; i < obj.Length-1; i++)
Console.Write(obj[i] + " ");
}
}
}

A. 1 4.0 India B

B. 1 4.0 India

C. 1 4 India

D. 1 India B

Answer & Explanation

Answer: Option C

Explanation:
No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

14. How many values is a subroutine capable of returning?

A. Depends upon how many params arguments does it use.

B. Any number of values.

C. Depends upon how many ref arguments does it use.

D. 0

E. 1

Answer & Explanation

Answer: Option D

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

15. Which of the following CANNOT occur multiple number of times in a program?

A. namespace B. Entrypoint

C. Class D. Function

E. Subroutine

Answer & Explanation

Answer: Option B

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

Prev 12345 Next


16. What will be the output of the C#.NET code snippet given below?

namespace IndiabixConsoleApplication
{
class SampleProgram
{
static void Main(string[ ] args)
{
int i;
int res = fun(out i);
Console.WriteLine(res);
}
static int fun (out int i)
{
int s = 1;
i = 7;
for(int j = 1; j <= i; j++)
{
s = s * j;
}
return s;
}
}
}

A. 1 B. 7

C. 8 D. 720

E. 5040

Answer & Explanation

Answer: Option E

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

17. If a function fun() is to sometimes receive an int and sometimes a double then which of the
following is the correct way of defining this function?

static void fun(object i)


A. { ... }
static void fun(int i)
B. { ... }

static void fun(double i, int j)


C. { ... }

static void fun(int i, double j)


D. { ... }

static void fun(int i, double j, )


E. { ... }

Answer & Explanation

Answer: Option A

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

18. Which of the following statements are correct about subroutines used in C#.NET?

1. If we do not return a value from a subroutine then a value -1 gets returned.


2. Subroutine definitions cannot be nested.
3. Subroutine can be called recursively.
4. To return the control from middle of a subroutine exit subroutine should be used.
5. Subroutine calls can be nested.

A. 1, 2, 3

B. 2, 3, 5

C. 3, 5

D. 3, 4

E. None of these

Answer & Explanation


Answer: Option B

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

19. A function can be used in an expression, whereas a subroutine cannot be.

A. True B. False

Answer & Explanation

Answer: Option A

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

20. Which of the following statements are correct about the C#.NET program given below?

namespace IndiabixConsoleApplication
{
class SampleProgram
{
static void Main(string[ ] args)
{
int a = 5;
int s = 0, c = 0;
s, c = fun(a);
Console.WriteLine(s +" " + c) ;
}
static int fun(int x)
{
int ss, cc;
ss = x * x; cc = x * x * x;
return ss, cc;
}
}
}

1. An error will be reported in the statement s, c = fun(a); since multiple values


returned from a function cannot be collected in this manner.
2. It will output 25 125.
3. It will output 25 0.
4. It will output 0 125.
5. An error will be reported in the statement return ss, cc; since a function cannot
return multiple values.

A. 1, 3

B. 2, 4

C. 4, 5

D. 1, 5

E. None of these

Answer & Explanation

Answer: Option D

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

Prev 12345 Next

21. What will be the output of the C#.NET code snippet given below?

namespace IndiabixConsoleApplication
{
class SampleProgram
{
static void Main(string[ ] args)
{
int i = 5;
int j;
fun1(ref i);
fun2(out j);
Console.WriteLine(i + ", " + j);
}
static void funl(ref int x)
{
x = x * x;
}
static void fun2(out int x)
{
x = 6;
x = x * x;
}
}
}

A. 5, 6

B. 5, 36

C. 25, 36

D. 25, 0

E. 5, 0

Answer & Explanation

Answer: Option C

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

Prev 12345

GENERICS

1. Which one of the following classes are present System.Collections.Genericnamespace?

1. Stack
2. Tree
3. SortedDictionary
4. SortedArray

A. 1 and 2 only
B. 2 and 4 only

C. 1 and 3 only

D. All of the above

E. None of the above

Answer & Explanation

Answer: Option C

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

2. For the code snippet shown below, which of the following statements are valid?

public class Generic<T>


{
public T Field;
public void TestSub()
{
T i = Field + 1;
}
}
class MyProgram
{
static void Main(string[] args)
{
Generic<int> gen = new Generic<int>();
gen.TestSub();
}
}

A. Addition will produce result 1.

B. Result of addition is system-dependent.

C. Program will generate run-time exception.

D. Compiler will report an error: Operator '+' is not defined for types T and int.
E. None of the above.

Answer & Explanation

Answer: Option D

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

3. Which of the following statements are valid about generics in .NET Framework?

1. Generics is a language feature.


2. We can create a generic class, however, we cannot create a generic interface in C#.NET.
3. Generics delegates are not allowed in C#.NET.
4. Generics are useful in collection classes in .NET framework.
5. None of the above

A. 1 and 2 Only

B. 1, 2 and 3 Only

C. 1 and 4 Only

D. All of the above

E. None of the above

Answer & Explanation

Answer: Option C

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

4. Which of the following statements is valid about generic procedures in C#.NET?

A. All procedures in a Generic class are generic.

B. Only those procedures labeled as Generic are generic.


C. Generic procedures can take at the most one generic parameter.

D. Generic procedures must take at least one type parameter.

E. None of the above.

Answer & Explanation

Answer: Option D

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

5. For the code snippet shown below, which of the following statements are valid?

public class TestIndiaBix


{
public void TestSub<M> (M arg)
{
Console.Write(arg);
}
}
class MyProgram
{
static void Main(string[] args)
{
TestIndiaBix bix = new TestIndiaBix();
bix.TestSub("IndiaBIX ");
bix.TestSub(4.2f);
}
}

A. Program will compile and on execution will print: IndiaBIX 4.2

B. A non generic class Hello cannot have generic subroutine.

C. Compiler will generate an error.

D. Program will generate a run-time exception.

E. None of the above.

Answer & Explanation


Answer: Option A

6. For the code snippet given below, which of the following statements is valid?

public class Generic<T>


{
public T Field;
}
class Program
{
static void Main(string[ ] args)
{
Generic<String> g = new Generic<String>();
g.Field = "Hello";
Console.WriteLine(g.Field);
}
}

A. It will print string "Hello" on the console.

B. Name Generic cannot be used as a class name because it's a keyword.

C. Compiler will give an error.

D. Member Field of class Generic is not accessible directly.

E. None of the above.

Answer & Explanation

Answer: Option A

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

7. For the code snippet given below, which of the following statements are valid?

public class MyContainer<T> where T: IComparabte


{
// Insert code here
}

1. Class MyContainer requires that it's type argument must


implementIComparabte interface.
2. Type argument of class MyContainer must be IComparabte.
3. Compiler will report an error for this block of code.
4. This requirement on type argument is called as constraint.

A. 1 and 2 Only

B. 1, 2 and 3 Only

C. 1 and 4 Only

D. All of the above

E. None of the above

Answer & Explanation

Answer: Option C

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

8. For the code snippet given below, which of the following statements are valid?

public class MyContainer<T> where T: class, IComparable


{
//Insert code here
}

1. Class MyContainer requires that it's type argument must


implementIComparable interface.
2. Compiler will report an error for this block of code.
3. There are multiple constraints on type argument to MyContainer class.
4. Class MyContainer requires that its type argument must be a reference type and it must
implement IComparable interface.
A. 1 and 2 Only

B. 3 and 4 Only

C. 2 and 3 Only

D. All of the above

E. None of the above

Answer & Explanation

Answer: Option B

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

9. Which of the following statements is valid about advantages of generics?

A. Generics shift the burden of type safety to the programmer rather than compiler.

B. Generics require use of explicit type casting.

C. Generics provide type safety without the overhead of multiple implementations.

D. Generics eliminate the possibility of run-time errors.

E. None of the above.

Answer & Explanation

Answer: Option C

INHERITNCE

1. Which of the following can be facilitated by the Inheritance mechanism?

1. Use the existing functionality of base class.


2. Overrride the existing functionality of base class.
3. Implement new functionality in the derived class.
4. Implement polymorphic behaviour.
5. Implement containership.

A. 1, 2, 3

B. 3, 4

C. 2, 4, 5

D. 3, 5

Answer & Explanation

Answer: Option A

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

2. Which of the following statements should be added to the subroutine fun( ) if the C#.NET code
snippet given below is to output 9 13?

class BaseClass
{
protected int i = 13;
}
class Derived: BaseClass
{
int i = 9;
public void fun()
{
// [*** Add statement here ***]
}
}

A. Console.WriteLine(base.i + " " + i);

B. Console.WriteLine(i + " " + base.i);

C. Console.WriteLine(mybase.i + " " + i);


D. Console.WriteLine(i + " " + mybase.i);

E. Console.WriteLine(i + " " + this.i);

Answer & Explanation

Answer: Option B

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

3. Which of the following statements are correct about the C#.NET code snippet given below?

namespace IndiabixConsoleApplication
{
class index
{
protected int count;
public index()
{
count = 0;
}
}
class index1: index
{
public void increment()
{
count = count +1;
}
}
class MyProgram
{
static void Main(string[] args)
{
index1 i = new index1();
i.increment();
}
}
}

1. count should be declared as public if it is to become available in the inheritance chain.


2. count should be declared as protected if it is to become available in the inheritance
chain.
3. While constructing an object referred to by i firstly constructor of index class will be called
followed by constructor of index1 class.
4. Constructor of index class does not get inherited in index1 class.
5. count should be declared as Friend if it is to become available in the inheritance chain.

A. 1, 2, 5

B. 2, 3, 4

C. 3, 5

D. 4, 5

E. None of these

Answer & Explanation

Answer: Option B

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

4. What will be the size of the object created by the following C#.NET code snippet?

namespace IndiabixConsoleApplication
{
class Baseclass
{
private int i;
protected int j;
public int k;
}
class Derived: Baseclass
{
private int x;
protected int y;
public int z;
}
class MyProgram
{
static void Main (string[ ] args)
{
Derived d = new Derived();
}
}
}

A. 24 bytes

B. 12 bytes

C. 20 bytes

D. 10 bytes

E. 16 bytes

Answer & Explanation

Answer: Option A

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

5. Which statement will you add in the function fun() of class B, if it is to produce the
output "Welcome to IndiaBIX.com!"?

namespace IndiabixConsoleApplication
{
class A
{
public void fun()
{
Console.Write("Welcome");
}
}
class B: A
{
public void fun()
{
// [*** Add statement here ***]
Console.WriteLine(" to IndiaBIX.com!");
}
}
class MyProgram
{
static void Main (string[ ] args)
{
B b = new B();
b.fun();
}
}
}

A. base.fun();

B. A::fun();

C. fun();

D. mybase.fun();

E. A.fun();

Answer & Explanation

Answer: Option A

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

6. What will be the output of the C#.NET code snippet given below?

namespace IndiabixConsoleApplication
{
class Baseclass
{
public void fun()
{
Console.Write("Base class" + " ");
}
}
class Derived1: Baseclass
{
new void fun()
{
Console.Write("Derived1 class" + " ");
}
}
class Derived2: Derived1
{
new void fun()
{
Console.Write("Derived2 class" + " ");
}
}
class Program
{
public static void Main(string[ ] args)
{
Derived2 d = new Derived2();
d.fun();
}
}
}

A. Base class

B. Derived1 class

C. Derived2 class

D. Base class Derived1 class

E. Base class Derived1 class Derived2 class

Answer & Explanation

Answer: Option A

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

7. Which of the following should be used to implement a 'Has a' relationship between two entities?

A. Polymorphism B. Templates

C. Containership D. Encapsulation

E. Inheritance

Answer & Explanation

Answer: Option C

Explanation:

No answer description available for this question. Let us discuss.


View Answer Workspace Report Discuss in Forum

8. Which of the following is correct about the C#.NET snippet given below?

namespace IndiabixConsoleApplication
{
class Baseclass
{
public void fun()
{
Console.WriteLine("Hi" + " ");
}
public void fun(int i)
{
Console.Write("Hello" + " ");
}
}
class Derived: Baseclass
{
public void fun()
{
Console.Write("Bye" + " ");
}
}
class MyProgram
{
static void Main(string[ ] args)
{
Derived d;
d = new Derived();
d.fun();
d.fun(77);
}
}
}

A. The program gives the output as: Hi Hello Bye

B. The program gives the output as: Bye Hello

C. The program gives the output as: Hi Bye Hello

D. Error in the program

Answer & Explanation

Answer: Option B
Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

9. In an inheritance chain which of the following members of base class are accessible to the derived
class members?

1. static
2. protected
3. private
4. shared
5. public

A. 1, 3

B. 2, 5

C. 3, 4

D. 4, 5

Answer & Explanation

Answer: Option B

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

10. Which of the following are reuse mechanisms available in C#.NET?

1. Inheritance
2. Encapsulation
3. Templates
4. Containership
5. Polymorphism

A. 1, 4

B. 1, 3
C. 2, 4

D. 3, 5

Answer & Explanation

Answer: Option A

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

11. Which of the following should be used to implement a 'Like a' or a 'Kind of' relationship between
two entities?

A. Polymorphism B. Containership

C. Templates D. Encapsulation

E. Inheritance

Answer & Explanation

Answer: Option E

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

12. How can you prevent inheritance from a class in C#.NET ?

A. Declare the class as shadows.

B. Declare the class as overloads.

C. Declare the class as sealed.

D. Declare the class as suppress.

E. Declare the class as override.

Answer & Explanation


Answer: Option C

Explanation:

C#.NET allows sealed attribute to be used as a part of class statement. Classes declared
with sealed keyword cannot be used as based class for other classes. Most important reason to
do this world be to prevent behavior of a class to be changed in any way.

View Answer Workspace Report Discuss in Forum

13. Which of the following statements are correct about Inheritance in C#.NET?

1. A derived class object contains all the base class data.


2. Inheritance cannot suppress the base class functionality.
3. A derived class may not be able to access all the base class data.
4. Inheritance cannot extend the base class functionality.
5. In inheritance chain construction of object happens from base towards derived.

A. 1, 2, 4

B. 2, 4, 5

C. 1, 3, 5

D. 2, 4

Answer & Explanation

Answer: Option C

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

14. Assume class B is inherited from class A. Which of the following statements is correct about
construction of an object of class B?

While creating the object firstly the constructor of class B will be called followed by
A.
constructor of class A.

While creating the object firstly the constructor of class A will be called followed by
B.
constructor of class B.
C. The constructor of only class B will be called.

D. The constructor of only class A will be called.

The order of calling constructors depends upon whether constructors in class


E.
Aand class B are private or public.

Answer & Explanation

Answer: Option B

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

15. Which of the following statements is correct about the C#.NET program given below?

namespace IndiabixConsoleApplication
{
class Baseclass
{
int i;
public Baseclass(int ii)
{
i = ii;
Console.Write("Base ");
}
}
class Derived : Baseclass
{
public Derived(int ii) : base(ii)
{
Console.Write("Derived ");
}
}
class MyProgram
{
static void Main(string[ ] args)
{
Derived d = new Derived(10);
}
}
}

A. The program will work correctly only if we implement zero-argument constructors


in Baseclass as well as Derived class.

B. The program will output: Derived Base

C. The program will report an error in the statement base(ii).

D. The program will work correctly if we replace base(ii) withbase.Baseclass(ii).

E. The program will output: Base Derived

Answer & Explanation

Answer: Option E

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

Prev 123

INTERFACES

1. Which of the following statements is correct about the C#.NET code snippet given below?

interface IMyInterface
{
void fun1();
int fun2();
}
class MyClass: IMyInterface
{
void fun1()
{ }
int IMyInterface.fun2()
{ }
}

A. A function cannot be declared inside an interface.

B. A subroutine cannot be declared inside an interface.


C. A Method Table will not be created for class MyClass.

D. MyClass is an abstract class.

E. The definition of fun1() in class MyClass should be void IMyInterface.fun1().

Answer & Explanation

Answer: Option E

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

2. Which of the following can be declared in an interface?

1. Properties
2. Methods
3. Enumerations
4. Events
5. Structures

A. 1, 3

B. 1, 2, 4

C. 3, 5

D. 4, 5

Answer & Explanation

Answer: Option B

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

3. A class implements two interfaces each containing three methods. The class contains no instance
data. Which of the following correctly indicate the size of the object created from this class?
A. 12 bytes

B. 24 bytes

C. 0 byte

D. 8 bytes

E. 16 bytes

Answer & Explanation

Answer: Option B

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

4. Which of the following statements is correct about an interface used in C#.NET?

A. One class can implement only one interface.

In a program if one class implements an interface then no other class in the same
B.
program can implement this interface.

C. From two base interfaces a new interface cannot be inherited.

D. Properties can be declared inside an interface.

E. Interfaces cannot be inherited.

Answer & Explanation

Answer: Option D

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

5. Which of the following statements is correct about Interfaces used in C#.NET?


A. All interfaces are derived from an Object class.

B. Interfaces can be inherited.

C. All interfaces are derived from an Object interface.

D. Interfaces can contain only method declaration.

E. Interfaces can contain static data and methods.

Answer & Explanation

Answer: Option B

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

6. Which of the following statements is correct about an interface used in C#.NET?

A. If a class implements an interface partially, then it should be an abstract class.

B. A class cannot implement an interface partially.

C. An interface can contain static methods.

D. An interface can contain static data.

E. Multiple interface inheritance is not allowed.

Answer & Explanation

Answer: Option A

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

7. Which of the following statements is correct about an interface?

A. One interface can be implemented in another interface.


B. An interface can be implemented by multiple classes in the same program.

A class that implements an interface can explicitly implement members of that


C.
interface.

D. The functions declared in an interface have a body.

Answer & Explanation

Answer: Option C

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

8. Which of the following statements are correct about an interface in C#.NET?

1. A class can implement multiple interfaces.


2. Structures cannot inherit a class but can implement an interface.
3. In C#.NET, : is used to signify that a class member implements a specific interface.
4. An interface can implement multiple classes.
5. The static attribute can be used with a method that implements an interface declaration.

A. 1, 2, 3

B. 2, 4

C. 3, 5

D. None of the above.

Answer & Explanation

Answer: Option A

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

9. Which of the following is the correct implementation of the interface given below?
interface IMyInterface
{
double MyFun(Single i);
}

class MyClass
{
double MyFun(Single i) as IMyInterface.MyFun
A. {
// Some code
}
}

class MyClass
{
MyFun (Single i) As Double
B. {
// Some code
}
}

class MyClass: implements IMyInterface


{
double fun(Single si) implements IMyInterface.MyFun()
C. {
//Some code
}
}

class MyClass: IMyInterface


{
double IMyInterface.MyFun(Single i)
D. {
// Some code
}
}

Answer & Explanation

Answer: Option D

Explanation:

No answer description available for this question. Let us discuss.


View Answer Workspace Report Discuss in Forum

10. Which of the following statements is correct?

When a class inherits an interface it inherits member definitions as well as its


A.
implementations.

B. An interface cannot contain the signature of an indexer.

C. Interfaces members are automatically public.

To implement an interface member, the corresponding member in the class must be


D.
public as well as static.

Answer & Explanation

Answer: Option C

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

Prev 123 Next

11. Which of the following statements are correct about an interface used in C#.NET?

1. An interface can contain properties, methods and events.


2. The keyword must implement forces implementation of an interface.
3. Interfaces can be overloaded.
4. Interfaces can be implemented by a class or a struct.
5. Enhanced implementations of an interface can be developed without breaking existing
code.

A. 1, 2

B. 1, 4, 5

C. 3, 4

D. 3 only

Answer & Explanation


Answer: Option B

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

12. Which of the following can implement an interface?

1. Data
2. Class
3. Enum
4. Structure
5. Namespace

A. 1, 3

B. 2, 4

C. 3, 5

D. 4 only

Answer & Explanation

Answer: Option B

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

13. Which of the following statements is correct about the C#.NET code snippet given below?

interface IMyInterface
{
void fun1();
void fun2();
}
class MyClass: IMyInterface
{
private int i;
void IMyInterface.fun1()
{
// Some code
}
}

A. Class MyClass is an abstract class.

B. Class MyClass cannot contain instance data.

C. Class MyClass fully implements the interface IMyInterface.

D. Interface IMyInterface should be inherited from the Object class.

The compiler will report an error since the interface IMyInterface is only partially
E.
implemented.

Answer & Explanation

Answer: Option D

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

14. Which of the following statements is correct about the C#.NET code snippet given below?

interface IPerson
{
String FirstName
{
get;
set;
}
String LastName
{
get;
set;
}
void Print();
void Stock();
int Fun();
}

A. Properties cannot be declared inside an interface.


B. This is a perfectly workable interface.

C. The properties in the interface must have a body.

D. Subroutine in the interface must have a body.

E. Functions cannot be declared inside an interface.

Answer & Explanation

Answer: Option B

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

15. Which of the following is the correct way to implement the interface given below?

interface IPerson
{
String FirstName
{
get;
set;
}
}

class Employee : IPerson


{
private String str;
public String FirstName
{
get
{
A. return str;
}
set
{
str = value;
}
}
}
class Employee
{
private String str;
public String IPerson.FirstName
{
get
{
B. return str;
}
set
{
str = value;
}
}
}

class Employee : implements IPerson


{
private String str;
public String FirstName
{
get
{
C. return str;
}
set
{
str = value;
}
}
}

D. None of the above

Answer & Explanation

Answer: Option A

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

Prev 123
POLYMORPHISM

1. Which of the following unary operators can be overloaded?

1. true
2. false
3. +
4. new
5. is

A. 1, 2, 3

B. 3, 4, 5

C. 3 only

D. 5 only

Answer & Explanation

Answer: Option A

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

2. A derived class can stop virtual inheritance by declaring an override as

A. inherits

B. extends

C. inheritable

D. not inheritable

E. sealed

Answer & Explanation


Answer: Option E

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

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

A. new

B. base

C. overloads

D. override

E. overridable

Answer & Explanation

Answer: Option A

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

4. Which of the following statements is correct?

When used as a modifier, the new keyword explicitly hides a member inherited from a
A.
base class.

B. Operator overloading works in different ways for structures and classes.

C. It is not necessary that all operator overloads are static methods of the class.

D. The cast operator can be overloaded.

Answer & Explanation

Answer: Option A
Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

5. 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

E. udoperator

Answer & Explanation

Answer: Option C

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

1234 Next

6. Which of the followings is the correct way to overload + operator?

A. public sample operator + ( sample a, sample b )

B. public abstract operator + ( sample a, sample b)

C. public abstract sample operator + (sample a, sample b )

D. public static sample operator + ( sample a, sample b )


E. All of the above

Answer & Explanation

Answer: Option D

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

7. Which of the following statements is correct?

A. Static methods can be a virtual method.

B. Abstract methods can be a virtual method.

C. It is necessary to override a virtual method.

When overriding a method, the names and type signatures of the override method
D.
must be the same as the virtual method that is being overriden.

E. We can override virtual as well as non-virtual methods.

Answer & Explanation

Answer: Option D

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

8. Which of the following statements are correct?

1. All operators in C#.NET can be overloaded.


2. We can use the new modifier to modify a nested type if the nested type is hiding another
type.
3. In case of operator overloading all parameters must be of the different type than the class
or struct that declares the operator.
4. Method overloading is used to create several methods with the same name that performs
similar tasks on similar data types.
5. Operator overloading permits the use of symbols to represent computations for a type.
A. 1, 3

B. 2, 4

C. 2, 5

D. 3, 4

Answer & Explanation

Answer: Option C

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

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

public class Sample


{
public int x;
public virtual void fun()
{ }
}
public class DerivedSample : Sample
{
new public void fun()
{ }
}

A. DerivedSample class hides the fun() method of base class.

The DerivedSample class version of fun() method gets called using Sampleclass
B.
reference which holds DerivedSample class object.

The code replaces the DerivedSample class version of fun() method with
C.
itsSample class version.

It is not possible to hide Sample class version of fun() method without use
D.
ofnew in DerivedSample class.

Answer & Explanation


Answer: Option A

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

10. Which of the following statements is correct?

A. The conditional logical operators cannot be overloaded.

When a binary operator is overloaded the corresponding assignment operator, if any,


B.
must be explicitly overloaded.

We can use the default equality operator in an overloaded implementation of the


C.
equality operator.

D. A public or nested public reference type does not overload the equality operator.

E. The array indexing operator can be overloaded.

Answer & Explanation

Answer: Option A

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

Prev 1234 Next

11. Which of the following operators cannot be overloaded?

1. true
2. false
3. new
4. ~
5. sizeof

A. 1, 3
B. 2, 4

C. 3, 5

D. All of the above

Answer & Explanation

Answer: Option C

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

12. Which of the following modifier is used when a virtual method is redefined by a derived class?

A. overloads

B. override

C. overridable

D. virtual

E. base

Answer & Explanation

Answer: Option B

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

13. In order for an instance of a derived class to completely take over a class member from a base
class, the base class has to declare that member as

A. new

B. base
C. virtual

D. overrides

E. overloads

Answer & Explanation

Answer: Option C

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

14. Which of the following can be declared as a virtual in a class?

1. Methods
2. Properties
3. Events
4. Fields
5. Static fields

A. 1, 2, 3

B. 3, 5

C. 2, 4

D. 2, 3, 5

Answer & Explanation

Answer: Option A

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

15. Which of the following statements is correct?

A. Only one object can be created from an abstract class.


B. By default methods are virtual.

If a derived class does not provide its own version of virtual method then the one in the
C.
base class is used.

If the method in the derived class is not preceded by override keywords, the compiler
D. will issue a warning and the method will behave as if the override keyword were
present.

E. Each derived class does not have its own version of a virtual method.

Answer & Explanation

Answer: Option C

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

Which of the following are necessary for Run-time Polymorphism?

1. The overridden base method must be virtual, abstract or override.


2. Both the override method and the virtual method must have the same access level
modifier.
3. An override declaration can change the accessibility of the virtual method.
4. An abstract inherited property cannot be overridden in a derived class.
5. An abstract method is implicitly a virtual method.

A. 1, 3

B. 1, 2, 5

C. 2, 3, 4

D. 4 only

Answer & Explanation


Answer: Option B

PROPERTIES

1. A property can be declared inside a class, struct, Interface.

A. True B. False
Answer & Explanation

Answer: Option A

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

2. Which of the following statements is correct about properties used in C#.NET?

A. A property can simultaneously be read only or write only.

B. A property can be either read only or write only.

C. A write only property will have only get accessor.

D. A write only property will always return a value.

Answer & Explanation

Answer: Option B

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

3. A Student class has a property called rollNo and stu is a reference to a Studentobject and
we want the statement stu.RollNo = 28 to fail. Which of the following options will ensure this
functionality?

A. Declare rollNo property with both get and set accessors.

B. Declare rollNo property with only set accessor.

C. Declare rollNo property with get, set and normal accessors.

D. Declare rollNo property with only get accessor.

E. None of the above

Answer & Explanation


Answer: Option D

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

4. If a class Student has an indexer, then which of the following is the correct way to declare this
indexer to make the C#.NET code snippet given below work successfully?

Student s = new Student();


s[1, 2] = 35;

class Student
{
int[ ] a = new int[5, 5];
public property WriteOnly int this[int i, int j]
{
A. set
{
a[i, j] = value;
}
}
}

class Student
{
int[ , ] a = new int[5, 5];
public int property WriteOnly
{
B. set
{
a[i, j] = value;
}
}
}

class Student
{
C. int[ , ] a = new int[5, 5];
public int this[int i, int j]
{
set
{
a[i, j] = value;
}
}
}

class Student
{
int[ , ] a = new int[5, 5];
int i, j;
public int this
{
D. set
{
a[i, j] = value;
}
}
}

Answer & Explanation

Answer: Option C

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

5. Which of the following statements are correct?

1. The signature of an indexer consists of the number and types of its formal parameters.
2. Indexers are similar to properties except that their accessors take parameters.
3. Accessors of interface indexers use modifiers.
4. The type of an indexer and the type of its parameters must be at least as accessible as
the indexer itself.
5. An interface accessor contains a body.

A. 1, 3, 5

B. 1, 2, 4

C. 3, 5

D. 2, 4
Answer & Explanation

Answer: Option B

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

1234 Next

6. If Sample class has a Length property with get and set accessors then which of the following
statements will work correctly?

1. Sample.Length = 20;

2. Sample m = new Sample();


3. m.Length = 10;

4. Console.WriteLine(Sample.Length);

5. Sample m = new Sample();


6. int len;
7. len = m.Length;
8. Sample m = new Sample();
9. m.Length = m.Length + 20;

A. 1, 3

B. 2, 4, 5

C. 4 only

D. 3, 5

Answer & Explanation

Answer: Option B

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

7. Which of the following is the correct way to implement a write only property Length in
aSample class?

class Sample
{
public int Length
{
set
A. {
Length = value;
}
}
}

class Sample
{
int len;
public int Length
{
get
{
B. return len;
}
set
{
len = value;
}
}
}

class Sample
{
int len;
public int Length
{
C. WriteOnly set
{
len = value;
}
}
}

class Sample
{
D. int len;
public int Length
{
set
{
len = value;
}
}
}

Answer & Explanation

Answer: Option D

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

8. A property can be declared inside a namespace or a procedure.

A. True B. False

Answer & Explanation

Answer: Option B

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

9. If a Student class has an indexed property which is used to store or retrieve values to/from an
array of 5 integers, then which of the following are the correct ways to use this indexed property?

1. Student[3] = 34;

2. Student s = new Student();


3. s[3] = 34;
4. Student s = new Student();
5. Console.WriteLine(s[3]);

6. Console.WriteLine(Student[3]);

7. Student.this s = new Student.this();


8. s[3] = 34;

A. 1, 2
B. 2, 3

C. 3, 4

D. 3, 5

Answer & Explanation

Answer: Option B

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

10. If Sample class has a Length property with set accessor then which of the following statements
will work correctly?

Sample m = new Sample();


A. int l;
l = m.Length;

Sample m = new Sample();


B. m.Length = m.Length + 20;

C. Sample.Length = 20;

D. Console.WriteLine (Sample.Length);

Sample m = new Sample();


E. m.Length = 10;

Answer & Explanation

Answer: Option E

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum


Prev 1234 Next

11. If Sample class has a Length property with get accessor then which of the following statements
will work correctly?

Sample m = new Sample();


A. m.Length = 10;

Sample m = new Sample();


B. m.Length = m.Length + 20;

Sample m = new Sample();


C. int l;
l = m.Length;

D. Sample.Length = 20;

E. Console.WriteLine(Sample.Length);

Answer & Explanation

Answer: Option C

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

12. An Account class has a property called accountNo and acc is a reference to a bank object and
we want the C#.NET code snippet given below to work. Which of the following options will ensure
this functionality?

acc.accountNo = 10;
Console.WriteLine(acc.accountNo);

A. Declare accountNo property with both get and set accessors.

B. Declare accountNo property with only get accessor.

C. Declare accountNo property with get, set and normal accessors.

D. Declare accountNo property with only set accessor.


E. None of the above

Answer & Explanation

Answer: Option A

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

13. Suppose a Student class has an indexed property. This property is used to set or retrieve values
to/from an array of 5 integers called scores[]. We want the property to report "Invalid Index"
message if the user attempts to exceed the bounds of the array. Which of the following is the
correct way to implement this property?

class Student
{
int[] scores = new int[5] {3, 2, 4,1, 5};
public int this[ int index ]
{
set
{
A. if (index < 5)
scores[index] = value;
else
Console.WriteLine("Invalid Index");
}
}
}

class Student
{
int[] scores = new int[5] {3, 2, 4, 1, 5};
public int this[ int index ]
{
get
{
B. if (index < 5)
return scores[ index ];
else
{
Console.WriteLine("Invalid Index"); return 0;
}
}
set
{
if (index < 5)
scores[ index ] = value;
else
Console.WriteLine("Invalid Index");
}
}
}

class Student
{
int[] scores = new int[5] {3, 2, 4, 1, 5};
public int this[ int index ]
{
get
{
if (index < 5)
C. return scores[ index ];
else
{
Console.WriteLine("Invalid Index");
return 0;
}
}
}
}

class Student
{
int[] scores = new int[5] {3, 2, 4, 1, 5};
public int this[ int index ]
{
get
{
if (index < 5)
scores[ index ] = value;
else
D. {
Console.WriteLine("Invalid Index");
}
}
set
{
if (index < 5)
return scores[ index ];
else
{
Console.WriteLine("Invalid Index");
return 0;
}
}
}
}

Answer & Explanation

Answer: Option B

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

14. Which of the following statements is correct about properties used in C#.NET?

A. Every property must have a set accessor and a get accessor.

B. Properties cannot be overloaded.

C. Properties of a class are actually methods that work like data members.

D. A property has to be either read only or a write only.

Answer & Explanation

Answer: Option C

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

15. Which of the following is the correct way to implement a read only property Length in
aSample class?

class Sample
{
int len;
A.
public int Length
{
get
{
return len;
}
}
}

class Sample
{
public int Length
{
get
B. {
return Length;
}
}
}

class Sample
{
int len;
public int Length
{
get
{
C. return len;
}
set
{
len = value;
}
}
}

class Sample
{
int len;
public int Length
{
D. Readonly get
{
return len;
}
}
}

Answer & Explanation

Answer: Option A
Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

Prev 1234 Next

16. Which of the folowing does an indexer allow to index in the same way as an array?

1. A class
2. A property
3. A struct
4. A function
5. An interface

A. 1, 3, 5

B. 2, 4

C. 3, 5

D. 3, 4, 5

Answer & Explanation

Answer: Option A

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

17. An Employee class has a property called age and emp is reference to a Employee object and we
want the statement Console.WriteLine(emp.age) to fail. Which of the following options will
ensure this functionality?

A. Declare age property with only get accessor.

B. Declare age property with only set accessor.

C. Declare age property with both get and set accessors.


D. Declare age property with get, set and normal accessors.

E. None of the above

Answer & Explanation

Answer: Option B

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

Prev 1234

STRINGS

1. Which of the following statements are true about the C#.NET code snippet given below?

String s1, s2;


s1 = "Hi";
s2 = "Hi";

1. String objects cannot be created without using new.


2. Only one object will get created.
3. s1 and s2 both will refer to the same object.
4. Two objects will get created, one pointed to by s1 and another pointed to by s2.
5. s1 and s2 are references to the same object.

A. 1, 2, 4

B. 2, 3, 5

C. 3, 4

D. 2, 5

Answer & Explanation


Answer: Option B

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

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

String s1 = "ALL MEN ARE CREATED EQUAL";


String s2;
s2 = s1.Substring(12, 3);
Console.WriteLine(s2);

A. ARE B. CRE

C. CR D. REA

E. CREATED

Answer & Explanation

Answer: Option B

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

3. Which of the following statements will correctly copy the contents of one string into another ?
String s1 = "String";
A. String s2;
s2 = s1;

String s1 = "String" ;
B. String s2;
s2 = String.Concat(s1, s2);

String s1 = "String";
C. String s2;
s2 = String.Copy(s1);

String s1 = "String";
D. String s2;
s2 = s1.Replace();
String s1 = "String";
E. String s2;
s2 = s2.StringCopy(s1);
Answer & Explanation

Answer: Option C

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

4. The string built using the String class are immutable (unchangeable), whereas, the ones built-
using the StringBuilder class are mutable.

A. True B. False

Answer & Explanation

Answer: Option A

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

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

String s1 = "Nagpur";
String s2;
s2 = s1.Insert(6, "Mumbai");
Console.WriteLine(s2);

A. NagpuMumbair

B. Nagpur Mumbai

C. Mumbai

D. Nagpur

E. NagpurMumbai

Answer & Explanation


Answer: Option E

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

1234 Next

6. If s1 and s2 are references to two strings, then which of the following is the correct way to
compare the two references?

A. s1 is s2

B. s1 = s2

C. s1 == s2

D. strcmp(s1, s2)

E. s1.Equals(s2)

Answer & Explanation

Answer: Option E

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

7. What will be the output of the C#.NET code snippet given below?

namespace IndiabixConsoleApplication
{
class SampleProgram
{
static void Main(string[ ] args)
{
string str= "Hello World!";
Console.WriteLine( String.Compare(str, "Hello World?" ).GetType() );
}
}
}

A. 0

B. 1

C. String

D. Hello World?

E. System.Int32

Answer & Explanation

Answer: Option E

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

8. Which of the following snippets are the correct way to convert a Single into a String?

1. Single f = 9.8f;
2. String s;
3. s = (String) (f);
4. Single f = 9.8f;
5. String s;
6. s = Convert.ToString(f);
7. Single f = 9.8f;
8. String s;
9. s = f.ToString();
10. Single f = 9.8f;
11. String s;
12. s = Clnt(f);
13. Single f = 9.8f;
14. String s;
15. s = CString(f);

A. 1, 2

B. 2, 3

C. 1, 3, 5
D. 2, 4

Answer & Explanation

Answer: Option B

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

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

String s1="Kicit";
Console.Write(s1.IndexOf('c') + " ");
Console.Write(s1.Length);

A. 36

B. 25

C. 35

D. 26

E. 37

Answer & Explanation

Answer: Option B

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

10. Which of the following is correct way to convert a String to an int?

1. String s = "123";
2. int i;
3. i = (int)s;
4. String s = "123";
5. int i;
6. i = int.Parse(s);
7. String s = "123";
8. int i;
9. i = Int32.Parse(s);
10. String s = "123";
11. int i;
12. i = Convert.ToInt32(s);
13. String s = "123";
14. int i;
15. i = CInt(s);

A. 1, 3, 5

B. 2, 4

C. 3, 5

D. 2, 3, 4

Answer & Explanation

Answer: Option D

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

Prev 1234 Next

11. Which of the following statements about a String is correct?

A. A String is created on the stack.

Whether a String is created on the stack or the heap depends on the length of the
B.
String.

C. A String is a primitive.

D. A String can be created by using the statement String s1 = new String;

E. A String is created on the heap.

Answer & Explanation


Answer: Option E

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

12. Which of the following statement is correct about a String in C#.NET?

A. A String is mutable because it can be modified once it has been created.

B. Methods of the String class can be used to modify the string.

C. A number CANNOT be represented in the form of a String.

D. A String has a zero-based index.

E. The System.Array class is used to represent a string.

Answer & Explanation

Answer: Option D

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

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

String s1 = "Five Star";


String s2 = "FIVE STAR";
int c;
c = s1.CompareTo(s2);
Console.WriteLine(c);

A. 0 B. 1

C. 2 D. -1

E. -2

Answer & Explanation


Answer: Option D

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

14. If s1 and s2 are references to two strings then which of the following are the correct ways to find
whether the contents of the two strings are equal?

1. if(s1 = s2)
2. if(s1 == s2)
3. int c;
4. c = s1.CompareTo(s2);
5. if( strcmp(s1, s2) )
6. if (s1 is s2)

A. 1, 2

B. 2, 3

C. 4, 5

D. 3, 5

Answer & Explanation

Answer: Option B

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

15. Which of the following statements are correct about the String Class in C#.NET?

1. Two strings can be concatenated by using an expression of the form s3 = s1 + s2;


2. String is a primitive in C#.NET.
3. A string built using StringBuilder Class is Mutable.
4. A string built using String Class is Immutable.
5. Two strings can be concatenated by using an expression of the form s3 = s1&s2;
A. 1, 2, 5

B. 2, 4

C. 1, 3, 4

D. 3, 5

Answer & Explanation

Answer: Option C

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

STRUCTURES

1. The space required for structure variables is allocated on stack.

A. True B. False

Answer & Explanation

Answer: Option A

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

2. Creating empty structures is allowed in C#.NET.

A. True B. False

Answer & Explanation

Answer: Option B

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum


3. Which of the following will be the correct output for the C#.NET program given below?

namespace IndiabixConsoleApplication
{
struct Sample
{
public int i;
}
class MyProgram
{
static void Main()
{
Sample x = new Sample();
x.i = 10;
fun(x);
Console.Write(x.i + " ");
}
static void fun(Sample y)
{
y.i = 20;
Console.Write(y.i + " ");
}
}
}

A. 10 20

B. 10 10

C. 20 10

D. 20 20

E. None of the above

Answer & Explanation

Answer: Option C

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

4. Which of the following is the correct way of setting values into the structure variable e defined
below?

struct Emp
{
public String name;
public int age;
public Single sal;
}
Emp e = new Emp();

e.name = "Amol";
A. e.age = 25;
e.sal = 5500;

With e
{
.name = "Amol";
B. .age = 25;
.sal = 5500;
}

With emp e
{
.name = "Amol";
C. .age = 25;
.sal = 5500;
}

e -> name = "Amol";


D. e -> age = 25;
e -> sal = 5500;

name = "Amol";
E. age = 25;
sal = 5500;
Answer & Explanation

Answer: Option A

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

5. Which of the following is the correct way to define a variable of the type struct Empdeclared
below?

struct Emp
{
private String name;
private int age;
private Single sal;
}

1. Emp e(); e = new Emp();


2. Emp e = new Emp;
3. Emp e; e = new Emp;
4. Emp e = new Emp();
5. Emp e;

A. 1, 3

B. 2, 5

C. 4, 5

D. 1, 2, 4

Answer & Explanation

Answer: Option C

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

1234 Next

6. Which of the following statements is correct about the C#.NET code snippet given
below?

class Trial
{
int i;
Decimal d;
}
struct Sample
{
private int x;
private Single y;
private Trial z;
}
Sample ss = new Sample();

A. ss will be created on the heap.

B. Trial object referred by z will be created on the stack.

C. z will be created on the heap.

D. Both ss and z will be created on the heap.

E. ss will be created on the stack.

Answer & Explanation

Answer: Option E

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

7. How many bytes will the structure variable samp occupy in memory if it is defined
as shown below?

class Trial
{
int i;
Decimal d;
}
struct Sample
{
private int x;
private Single y;
private Trial z;
}
Sample samp = new Sample();

A. 20 bytes

B. 12 bytes
C. 8 bytes

D. 16 bytes

E. 24 bytes

Answer & Explanation

Answer: Option B

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

8. Which of the following will be the correct result of the statement b = a in the
C#.NET code snippet given below?

struct Address
{
private int plotno;
private String city;
}
Address a = new Address();
Address b;
b = a;

A. All elements of a will get copied into corresponding elements of b.

B. Address stored in a will get copied into b.

C. Once assignment is over a will get garbage collected.

D. Once assignment is over a will go out of scope, hence will die.

E. Address of the first element of a will get copied into b.

Answer & Explanation

Answer: Option A

Explanation:

No answer description available for this question. Let us discuss.


View Answer Workspace Report Discuss in Forum

9. Which of the following statements are correct?

1. A struct can contain properties.


2. A struct can contain constructors.
3. A struct can contain protected data members.
4. A struct cannot contain methods.
5. A struct cannot contain constants.

A. 1, 2

B. 3, 4

C. 1, 2, 4

D. 3, 5

Answer & Explanation

Answer: Option A

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

10. C#.NET structures are always value types.

A. True B. False

Answer & Explanation

Answer: Option A

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

Prev 1234 Next


11. When would a structure variable get
destroyed?
When no reference refers to
A. it, it will get garbage
collected.

Depends upon whether it is


B. created using new or
without using new.

C. When it goes out of scope.

Depends upon the Project


D. Settings made in Visual
Studio.NET.

Depends upon whether we


E. free it's memory
using free() or delete().

Answer & Explanation

Answer: Option C

Explanation:

No answer description available for


this question. Let us discuss.

View Answer Workspace Report Discuss in


Forum

12. Which of the following statements is correct about the C#.NET code snippet given below?

struct Book
{
private String name;
private int noofpages;
private Single price;
}
Book b = new Book();

A. The structure variable b will be created on the heap.

B. We can add a zero-argument constructor to the above structure.

C. When the program terminates, variable b will get garbage collected.


D. The structure variable b will be created on the stack.

E. We can inherit a new structure from struct Book.

Answer & Explanation

Answer: Option D

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

13. Which of the following will be the correct output for the C#.NET program given below?

namespace IndiabixConsoleApplication
{
struct Sample
{
public int i;
}
class MyProgram
{
static void Main(string[] args)
{
Sample x = new Sample();
x.i = 10;
fun(ref x);
Console.Write(x.i + " ");
}
public static void fun(ref Sample y)
{
y.i = 20;
Console.Write(y.i + " ");
}
}
}

A. 20 10

B. 10 20

C. 10 10

D. 20 20
E. None of the above

Answer & Explanation

Answer: Option D

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

14. Which of the following statements is correct?

A. A struct never declares a default constructor.

B. All value types in C# inherently derive from ValueType, which inherits fromObject.

C. A struct never declares a default destructor.

D. In C#, classes and structs are semantically same.

Answer & Explanation

Answer: Option B

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

15. Which of the following statements are correct about the structure declaration given below?

struct Book
{
private String name;
protected int totalpages;
public Single price;
public void Showdata()
{
Console.WriteLine(name + " " + totalpages + " " + price);
}
Book()
{
name = " ";
totalpages = 0;
price = 0.0f;
}
}
Book b = new Book();

1. We cannot declare the access modifier of totalpages as protected.


2. We cannot declare the access modifier of name as private.
3. We cannot define a zero-argument constructor inside a structure.
4. We cannot declare the access modifier of price as public.
5. We can define a Showdata() method inside a structure.

A. 1, 2

B. 1, 3, 5

C. 2, 4

D. 3, 4, 5

Answer & Explanation

Answer: Option B

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

Prev 1234 Next

16. Which of the following are true about classes and struct?

1. A class is a reference type, whereas a struct is a value type.


2. Objects are created using new, whereas structure variables can be created either
using new or without using new.
3. A structure variable will always be created slower than an object.
4. A structure variable will die when it goes out of scope.
5. An object will die when it goes out of scope.

A. 1, 2, 4

B. 3, 5
C. 2, 4

D. 3, 4, 5

Answer & Explanation

Answer: Option A

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

17. Which of the following will be the correct output for the program given below?

namespace IndiabixConsoleApplication
{
struct Sample
{
public int i;
}
class MyProgram
{
static void Main(string[] args)
{
Sample x = new Sample();
Sample y;
x.i = 9;
y = x;
y.i = 5;
Console.WriteLine(x.i + " " + y.i);
}
}
}

A. 99

B. 95

C. 55

D. 59

E. None of the above

Answer & Explanation


Answer: Option B

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

18. Which of the following statements are correct about Structures used in C#.NET?

1. A Structure can be declared within a procedure.


2. Structs can implement an interface but they cannot inherit from anotherstruct.
3. struct members cannot be declared as protected.
4. A Structure can be empty.
5. It is an error to initialize an instance field in a struct.

A. 1, 2, 4

B. 2, 3, 5

C. 2, 4

D. 1, 3

Answer & Explanation

Answer: Option B

Explanation:

No answer description available for this question. Let us discuss.

View Answer Workspace Report Discuss in Forum

Prev 1234

1. If a class is using an interface, it must


inherit the properties of the interface

contain the same methods as the interface

create an interface object

all of the above

View Answer / Hide Answer

ANSWER: all of the above

2. What is the output of the code public class B : A { }

Errors

It defines a class that inherits the public methods of A only.

It defines a class that inherits all the methods of A but the private members cannot be accessed.

b and c

View Answer / Hide Answer

ANSWER: It defines a class that inherits all the methods of A but the private members cannot be
accessed.

3. Sealed Classes cannot be a base class.


True

False

View Answer / Hide Answer

ANSWER: True

4. ___________________ allow to encapsulate discrete units of functionality and provide a graphical


representation of that functionality to the user

controls

object

class

graphics

View Answer / Hide Answer

ANSWER: controls

5. Features of Read only variables


It is allocated at compile time

Declaration and initialization is separated

It is allocated at runtime

all of these

View Answer / Hide Answer

ANSWER: all of these

6. How to kill a user session explicitly?

Session.Close()

Session.Discard()

Session.kill()

Session.Abandon()

View Answer / Hide Answer

ANSWER: Session.Abandon()

7. Convert vs. Parse methods


Convert allows null values, Parse cannot

Convert converts the value, Parse is for parsing

Both are same

None of these

View Answer / Hide Answer

ANSWER: Convert allows null values, Parse cannot

8. Different ways a method can be overloaded in C#.NET

Different parameter data types

Different number of parameters

Different order of parameters

All of above

View Answer / Hide Answer

ANSWER: All of above

1. Can you store multiple data types in System.Array?

No
Yes

View Answer / Hide Answer

ANSWER: Yes

2. Which of the following is incorrect about System.Text.StringBuilder and System.String?

StringBuilder is more efficient when there is a large amount of string manipulation

Strings are immutable, so each time a string is changed, a new instance in memory is created.

StringBuilder is mutable; when you modify an instance of the StringBuilder class, you modify the actual
string, not a copy

Strings are mutable in .Net

View Answer / Hide Answer

ANSWER: Strings are mutable in .Net

3. What is MSIL?

Multi Socket Interface Library

Microsoft Intermediate Language


Microsoft Interface Language

Microsoft Integer Long

View Answer / Hide Answer

ANSWER: Microsoft Intermediate Language

4. An assembly is

A collection of files that appear to the programmer to be a single DLL or EXE.

properties of c#

events Of c#

declarative syntax of Java

View Answer / Hide Answer

ANSWER: A collection of files that appear to the programmer to be a single DLL or EXE.

5. Which of following is correct:

enum Day{Sunday= 01,Monday= 02,Tuesday= 03,Wednesday=04,Thursday= 05,Friday= 06,Saturday=07}


Day enum{Sunday= 01,Monday= 02,Tuesday= 03,Wednesday=04,Thursday= 05,Friday= 06,Saturday=07}

Day{Sunday= 01,Monday= 02,Tuesday= 03,Wednesday=04,Thursday= 05,Friday= 06,Saturday=07}

enumeration Day{Sunday= 01,Monday= 02,Tuesday= 03,Wednesday=04,Thursday= 05,Friday=


06,Saturday=07}

View Answer / Hide Answer

ANSWER: enum Day{Sunday= 01,Monday= 02,Tuesday= 03,Wednesday=04,Thursday= 05,Friday=


06,Saturday=07}

6. In C#, by default structs are passed how?

By memory.

By value.

By reference.

By address.

View Answer / Hide Answer

ANSWER: By value.

7. What is boxing?
Encapsulating an object in a value type.

Encapsulating a copy of an object in a value type.

Encapsulating a value type in an object.

Encapsulating a copy of a value type in an object.

View Answer / Hide Answer

ANSWER: Encapsulating a copy of a value type in an object.

8. Which property will you use to process different server paths in a page?

Request

Response

Server

Application

View Answer / Hide Answer

ANSWER: Server

1. Which file contains configuration data for each unique URl resource used in project?

global.asax
assemblyinfo.cs

web.config

webapplication.vsdisco

View Answer / Hide Answer

ANSWER: web.config

2. Automatic paging is possible in

datareader

dataset

datatabel

all

View Answer / Hide Answer

ANSWER: datatabel

3. In data reader, what can be used before read method?


Getstring

Getvalue

GetNumber

None

View Answer / Hide Answer

ANSWER: None

4. What object can help you maintain data across users?

Session object

Application Object

Server Object

Response Object

View Answer / Hide Answer

ANSWER: Application Object

5. From a dataview dv who has a column EmpNo from employee table, how will u bind a textbox
Textbox.databinding.add(Text,dv,EmpNo);

Textbox.databinding.adddv,EmpNo);

Textbox.databinding.add(EmpNo);

None of the above

View Answer / Hide Answer

ANSWER: Textbox.databinding.add(Text,dv,EmpNo);

6. The uniqueId that gets generated at the start of the Session is stored in

Client computer as a cookie

Server machine

Passed to and fro on each and every request and response

Both a and b are correct

View Answer / Hide Answer

ANSWER: Server machine


7. What property is used on the datatable to indicate conflicts after update method is called?

HasErrorConflict

HasError

HasCollision

HasDataError

View Answer / Hide Answer

ANSWER: HasErrorConflict

8. The page class file is generated when:

Every time a page is accessed

Whenever the assembly is recompiled and deployed

Whenever the configuration settings are changed

None of the above

View Answer / Hide Answer

ANSWER: Whenever the assembly is recompiled and deployed

1. You need to encrypt the SOAP header. What is the correct method to use?
Inherit the web service class from the SoapHeaderEncrypt class

Custom SOAP headers

SOAP header extensions

Enable SSL for the XML web service and configure it to encrypt the headers

View Answer / Hide Answer

ANSWER: SOAP header extensions

2. Which of the following is not true for abstract class?

It cannot be instantiated

It can contain both implemented methods and abstract methods

It can be instantiated.

It can not be instantiated on its own, they must be inherited.

View Answer / Hide Answer

ANSWER: It can be instantiated.


3. What component of a Data Provider provides connected, forward-only, read-only access to a
database?

DataAdapter

Command object

Connection object

DataReader object

View Answer / Hide Answer

ANSWER: DataReader object

4. A DataAdapter facilitates disconnected data access.

True

False

View Answer / Hide Answer

ANSWER: True
5. Which of the following refers to providing new culture-specific resources and retrieving the
appropriate resource based on the culture setting?

Localization

Globalization

Overloading

Encapsulation

View Answer / Hide Answer

ANSWER: Localization

6. Which of the following automatically detects if windows installer is installed on the target machine?

Assembly

Native image

Bootstrapper application

Globalization

View Answer / Hide Answer

ANSWER: Bootstrapper application


7. Which of the following is not true for shared assembly?

It can be accessed by multiple programs at once.

It must be installed to the GAC.

It can be accessed only by one application.

View Answer / Hide Answer

ANSWER: It can be accessed only by one application.

8. Which type of assembly should be created when you want to provide different sets of resources for
different culture?

Private assembly

Satellite assembly

Shared assembly

View Answer / Hide Answer

ANSWER: Satellite assembly

1. Inheriting from a base class and providing a new method for one of the base class methods

Overriding
Overloading

Shadowing

Abstracting

View Answer / Hide Answer

ANSWER: Overriding

2. It contains all the information needed to describe the assembly to the common language runtime.

Bootstrapper

Assembly manifest

GAC

Strong Name

View Answer / Hide Answer

ANSWER: Assembly manifest

3. Convert.ToInt32 and Int.Parse?


Both are Same

Int.Parse can't handle Null values , It will throw ArgumentNullException Error

Convert.ToInt32 can't handle Null Values ,it will throws ArgumentNullException error

Both can handle Null values

View Answer / Hide Answer

ANSWER: Int.Parse can't handle Null values , It will throw ArgumentNullException Error

4. Which of the following class cannot be inherited?

Sealed

Abstract

Both

None

View Answer / Hide Answer

ANSWER: Sealed

5. Does C# support multiple-inheritance?


No. But you can use Interfaces

Yes

View Answer / Hide Answer

ANSWER: No. But you can use Interfaces

6. What is the advantage of using System.Text.StringBuilder over System.String?

StringBuilder is more efficient in cases where there is a large amount of string manipulation

StringBuilder creates a new instance in memory, each time a string is changed

Both a and b are correct

View Answer / Hide Answer

ANSWER: StringBuilder is more efficient in cases where there is a large amount of string manipulation

7. When do you absolutely have to declare a class as abstract?

When the class itself is inherited from an abstract class, but not all base abstract methods have been
overridden.
When at least one of the methods in the class is abstract.

Both a and b are correct

View Answer / Hide Answer

ANSWER: Both a and b are correct

8. What are the different ways a method can be overloaded?

Different parameter data types

Different number of parameters

Different order of parameters

All of the above

View Answer / Hide Answer

ANSWER: All of the above

9. Which of the following can't be used in our .NET application?

.Net assemblies
ActiveX control

COM type libraries

All of the above can be used

View Answer / Hide Answer

ANSWER: All of the above can be used

10. Type of code security that protects system resources from unauthorized calls

Role-based security

Code-based security

View Answer / Hide Answer

ANSWER: Code-based security

Q.1 Choose the correct option according to the given statements.

Statement 1: A delegate is an object that can refer to a method.

Statement 2: A delegate in C# is similar to a function pointer in C/C++.

Statement 3: The method that will be invoked by a delegate is determined at compile time.

A) Only statement 1 is correct.


B) Only statement 2 is correct.

C) Statement 1 and 2 are correct.

D) Only statement 3 is correct.

View Answer / Hide Answer

ANSWER: C

Q.2 What is general form of a delegate declaration?

A) delegate return-type name_of_delegate(parameter-list);

B) name_of_delegate(parameter-list);

C) delegate name_of_delegate;

D) None of the above.

View Answer / Hide Answer

ANSWER: A

Explanation:

A delegate type is declared using the keyword delegate. The general form of a delegate declaration is
shown here:
delegate return-type name_of_delegate(parameter-list);

Here, return-type is the type of value returned by the methods that the delegate will be calling.

The name of the delegate is specified by name_of_delegate. The parameters required by the methods
are specified by the parameter-list.

Q.3 Choose the correct option according to the given statements.

Statement 1: delegate can be used to call only those methods that signature and return type are same
as delegate.

Statement 2: A delegate cannot refer to a static method.

Statement 3: A delegate can refer to a static method.

A) Statement 1 and 2 are correct.

B) Only statement 2 is correct.

C) Statement 1 and 3 are correct.

D) Only statement 3 is correct.

View Answer / Hide Answer


ANSWER: C

Q.4 A method is written as follows

string DemoFunction(string s)

-------

-------

Choose the correct code for delegate declaration to call above function.

A) delegate string name_of_delegate (string str);

B) string name_of_delegate (string str);

C) delegate string name_of_delegate (string s, string str);

D) None of the above.

Ans. A

View Answer / Hide Answer

ANSWER: A
Explanation:

delegate can call only those methods whose signature and return type are same as delegate.

Q.5 Choose the correct option regarding the multicast delegate.

Statement 1: multicasting is the ability to create an invocation list, or chain, of methods that will be
automatically called when a delegate is invoked.

Statement 2: + or += operator is used to add methods to the chain for multicasting.

Statement 3: - or - = operator is used to remove methods from the chain.

A) Only statement 1 and 2 are correct.

B) Only statement 2 is correct.

C) Only statement 1 and 3 are correct.

D) All statements are correct.

View Answer / Hide Answer

ANSWER: D

Explanation: The given below example shows how multicast delegate can be used.
using System;

// Declare a delegate type.

delegate void Test();

class DelegateTest

public void function1()

Console.WriteLine("Function 1 is called");

public void function2()

Console.WriteLine("Function 2 is called");

class Program

static void Main(string[] args)

DelegateTest obj = new DelegateTest();

Test delObj = new Test(obj.function1);

// Set up multicast.
delObj += obj.function2;

delObj();

Console.WriteLine("Function 2 removed from the list");

delObj -= obj.function2;

delObj();

Output:

Function 1 is called

Function 2 is called

Function 2 removed from the list

Function 1 is called

Q.6 Choose the correct option about the Anonymous method.

A) Anonymous method cannot use Ref and Out parameter from outside of anonymous method.

B) Anonymous methods allow us to define a code block where a delegate object is acceptable.
C) Anonymous method can use Ref and Out parameter from outside of anonymous method.

D) Option A and B are correct.

View Answer / Hide Answer

ANSWER: D

Q.7 What is general form of an event declaration?

A) event event-name;

B) event delegateName event-name;

C) event ret-type event-name(parameter-list);

D) None of the above

View Answer / Hide Answer

ANSWER: B

Q.8 Choose the correct option according to the given statements about events and delegates.
A) events can be multicast.

B) delegate can be multicast.

C) events cannot be multicast.

D) Option A and B are correct

View Answer / Hide Answer

ANSWER: D

Q.9 According to above given code, how will you call function1 by using delegate?

delegate void Test();

class DelegateTest

public void function1()

Console.WriteLine("Function 1 called");

}
A) DelegateTest obj = new DelegateTest();

Test delObj =obj.function1;

delObj();

B) DelegateTest obj = new DelegateTest();

Test delObj = new Test (obj.function1);

delObj();

C) Option A and B both are correct.

D) None of the above.

View Answer / Hide Answer

ANSWER: C

Q. 10 Choose the correct option according to the given statements about lambda expression.

A) If the lambda body consists of a single expression, then an expression lambda is being created.

B) If the lambda body consists of a block of statements enclosed by braces, then a statement lambda is
being created.

C) If the lambda body consists of a single expression, then an statement lambda is being created.

D) Option A and B are correct.

View Answer / Hide Answer


ANSWER: D

C# supports two types of lambda expression. It is the lambda body that determines what type is being
created.

Expression Lambdas

The expression on the right side of the => acts on the parameter specified by the left side.

The general form of an expression lambda that takes only one parameter will be as follows:

param => expr

Here is a simple expression lambda:

count => count + 5

Here count is the parameter that is acted on by the expression count + 5. So the value of count
increased by five.

Statement Lambdas

A statement lambda allows the body of lambda to contain multiple statements. In statement lambda
you can use loops, if statements, declare variables, and so on.

Example:
// Declare a delegate type.

delegate int FactDemo(int f);

class Program

static void Main(string[] args)

FactDemo factorial = n =>

int num = 1;

for (int i = 1; i <= n; i++)

num = num * i;

return num;

};

Console.WriteLine("Factorial is =" +factorial(6));

}
Q.1 Trace the output of given below code.

ArrayList obj = new ArrayList();

obj.Add("A");

Console.WriteLine("Capacity = "+obj.Capacity);

A) Capacity=1

B) Capacity=2

C) Capacity=3

D) Capacity=4

View Answer / Hide Answer

ANSWER: D

Explanation:

ArrayList expands at run time. When you add first item in the ArrayList its capacity automatically
increased to 4. When you add fifth element in the ArrayList its capacity will be 8 and so on.

Q.2 Choose the correct option about ArrayList.


Statement 1: In ArrayList you can add any type of object.

Statement 2: In ArrayList you can add only string type of object.

A) Only statement 1 is correct.

B) Only statement 2 is correct.

C) Both statements 1 are correct.

D) None of the above.

View Answer / Hide Answer

ANSWER: A

Explanation:

In ArrayList you can add any type of object by using its Add method. This method has one input
parameter and its type is Object. All input types are converted into Object in ArrayList.

Example:

ArrayList obj = new ArrayList();

obj.Add("A");

obj.Add(1);

obj.Add(DateTime.Today.Date);

foreach (object list in obj)

Console.WriteLine(list);
}

Q.3 If you want to add an array in ArrayList then which method of ArrayList will be used?

A) Add

B) AddRange

C) AddArray

D) None of the above.

View Answer / Hide Answer

ANSWER: B

Example:

ArrayList list = new ArrayList();

string[] days ={ "Sun", "Mon", "Tue", "Wed", "Thru", "Fri", "Sat" };

list.AddRange(days);

foreach (object ob in list)

Console.Write(ob + " ");

}
Q.4 Trace the output of given below code.

int[] arr = {1,2,3,4,5 };

ArrayList obj = new ArrayList();

obj.Add("A");

obj.Add("B");

obj.AddRange(arr);

foreach (object list in obj)

Console.Write(list+" ");

A) A B 1 2 3 4 5

B) Compile time error

C) Run time error

D) None of the above

View Answer / Hide Answer

ANSWER: A
Q.5 Which of the following ArrayList methods can be used to determine whether an item exists in the
collection?

A) Count

B) Contains

C) Remove

D) None of the above.

View Answer / Hide Answer

ANSWER: B

Q.6 Trace the output of given below code.

Hashtable ht = new Hashtable();

ht["EmpId"] = "1";

ht["EmpName"] = "XYZ";

foreach (object ob in ht)

Console.WriteLine(ob);
}

A) EmpId=1

EmpName=XYZ

B) Compile Time Error

C) 1, XYZ

D) None of the above.

View Answer / Hide Answer

ANSWER: D

Explanation:

When you run the above code you will see the output on console like this:

System.Collections.DictionaryEntry

The result is not like what you expected because HashTable stores the data in key value pair. It is a
dictionary object. If you want the output as key and value separately then use

DictionaryEntry.

foreach (DictionaryEntry ob in ht)

Console.WriteLine(ob.Key+" : "+ob.Value);

}
Q.7 What does the Dequeue method of the Queue class do?

A) Retrieves an item from the front of the collection

B) Removes the first item from the collection

C) Option A and B are correct.

D) None of the above.

View Answer / Hide Answer

ANSWER: C

Explanation:

Retrieves an item from the front of the queue and it also removing it at the same time

Q.8 In what order does a Stack retrieve items as you use its Pop method?

A) Random order
B) First-in, first-out

C) Last-in, first-out

D) Last-in, last-out

View Answer / Hide Answer

ANSWER: C

Q.9 Trace the output of the following code

Hashtable ht = new Hashtable();

ht["EmpId"] = "1";

ht["EmpId"] = "Pune";

foreach (DictionaryEntry ob in ht)

Console.WriteLine(ob.Key+" = "+ob.Value);

Console.WriteLine("Count ="+ht.Count);

A) EmpId = Pune

Count =1

B) EmpId = Pune
EmpId = Pune

Count =2

C) EmpId = Pune

Count =2

D) None of the above.

View Answer / Hide Answer

ANSWER: A

Explanation:

If you try to store the same key twice, the second call replaces the first call. If you want different values
then keys must be unique, it should not duplicate.

Q.10 ListDictionary, HybridDictionary, and OrderedDictionary class is available in which Namespace?

A) System.Collections

B) System.Collections.Specialized

C) System

D) All of the above.

View Answer / Hide Answer


ANSWER: B

Q.11 Which class is efficient for small collections of items(Less than 10 items)?

A) SmallList

B) HashTable

C) ListDictionary

D) None of the above.

View Answer / Hide Answer

ANSWER: C

Explanation:

The Hashtable class is a very efficient collection but if the number of items is less then HashTable gives
performance issue. HashTable is very efficient for large collection. ListDictionary is very efficient for
small collections of items.
Q.12 if you do not know how large your collection is, then which class you will use to store the data?

A) ListDictionary

B) HybridDictionary

C) HashTable

D) None of the above.

Ans. B

View Answer / Hide Answer

Q.13 you want the functionality of the Hashtable but you need to control the order of the elements in
the collection. In this situation which collection class you will use?

A) HybridDictionary

B) ArrayList

C) OrderedDictionary

D) HashTable

View Answer / Hide Answer

ANSWER: C
Q.14 When adding a key to a Hashtable, what methods can be called on the key to determine whether
the key is unique?

A) GetType

B) GetHashCode

C) Equals

D) Option B and C are correct.

View Answer / Hide Answer

ANSWER: D

Q.15 Which collection is same as ArryList but can store only string type value?

A) StringDictionary.

B) StringCollection

C) StringArray.

D) None of the above.

View Answer / Hide Answer


ANSWER: B

Q.16 What types of objects can stored as a Value in StringDictionary?

A) Strings

B) Objects

C) Arrays of strings

D) All of the above.

View Answer / Hide Answer

ANSWER: A

Q.17 Where can you add items to a LinkedList?

A) At the beginning of the LinkedList

B) Before any specific node

C) After any specific node

D) At the end of the LinkedList


E) All of the above.

View Answer / Hide Answer

ANSWER: E

Q.18 Read the given below code. What you will write at the place of question marks in line

foreach (??????<int, String> item in obj) ?

Dictionary<int, String> obj = new Dictionary<int, String>();

obj[1] = "CareerRide.com";

obj[2] = "XYZ.com";

obj[3] = "PQR.com";

foreach (??????<int, String> item in obj)

int id = item.Key;

string website = item.Value;

Console.WriteLine(" {0} = {1}", id, website);

A. Value
B. KeyValuePair

C. Key

D. None of the above

View Answer / Hide Answer

ANSWER: B

Q.1 According to given below statements, choose the correct option regarding serialization.

Statement 1: Serialization is the process of converting information into a byte stream that can be stored
or transferred.

Statement 2: Deserialization is the process of converting a serialized sequence of bytes into an object.

Statement 3: Serialization is the process of converting a serialized sequence of bytes into an object.

Statement 4: DeSerialization is the process of converting information into a byte stream that can be
stored or transferred.

A) Statement 1 and 2 are correct.

B) Statement 3 and 4 are correct.

C) Statement 1 and 4 are correct.

D) Statement 2 and 3 are correct.


View Answer / Hide Answer

ANSWER: A

Q.2 What are the steps to serialize an object?

A)

- Create a stream object.

- Create a BinaryFormatter Object.

- Call the BinaryFormatter.Serialize method.

B)

- Create a BinaryFormatter Object.

- Call the BinaryFormatter.Serialize method.

C)

- Create a stream object.

- Create a BinaryFormatter Object.

- Call the BinaryFormatter.Deserialize method.


D) None of the above.

View Answer / Hide Answer

ANSWER: A

Example:

using System.IO;

using System.Runtime.Serialization.Formatters.Binary;

class Program

static void Main(string[] args)

string data = "Welcome to the CareerRide.com .";

// Create file to save the data

FileStream fs = new FileStream("c:\\data.txt", FileMode.Create);

// Create a BinaryFormatter object to perform the serialization process

BinaryFormatter obj = new BinaryFormatter();

// Use the BinaryFormatter object to serialize the data to the file

obj.Serialize(fs, data);

// Close the file

fs.Close();

}
}

If you run the above code and open the Data.txt file, you will see the contents of the string you stored
surrounded with binary information to describe the data for the deserialization.

Q.3 Which of the following attributes should you add to a class to enable it to be serialized?

A) ISerializable

B) Serializable

C) SoapInclude

D) OnDeserialization

View Answer / Hide Answer

ANSWER: B

Explanation:

If you apply Serializable attribute to a type, it indicate that instances of this type can be serialized. If you
do not want a field within your class to be serializable, apply the NonSerializedAttribute attribute.
Q.4 Which of the following interfaces should you implement to enable you to run a method after an
instance of your class is serialized?

A) IFormatter

B) ISerializable

C) IDeserializationCallback

D) IObjectReference

View Answer / Hide Answer

ANSWER: C

Q.5 How many types of Serialization .NET supports?

A) Binary Serialization

B) SOAP Serialization

C) XML Serialization

D) All of the above.

View Answer / Hide Answer


ANSWER: D

Q.6 According to given below statements, choose the correct option regarding XML serialization.

Statement 1: XML serialization provides the interoperability to communicate with different platforms.

Statement 2: XML serialization cannot be used to serialize private data.

Statement 3: XML serialization can be used to serialize private data.

Statement 4: XML serialization does not provides the interoperability to communicate with different
platforms.

A) Only statement 1 is correct.

B) Statement 1 and 2 are correct.

C) Statement 3 and 4 are correct.

D) Only statement 4 is correct.

View Answer / Hide Answer

ANSWER: B
Q.7 Which of the following attributes would you use to cause a member to be serialized as an attribute,
rather than an element?

A) XmlAnyAttribute

B) XMLType

C) XMLElement

D) XMLAttribute

View Answer / Hide Answer

ANSWER: D

Q.8 Which of the following attributes should you add to a member to prevent it from being serialized by
BinaryFormatter?

A) NonSerialized

B) Serializable

C) SerializationException

D) SoapIgnore

Ans. A

View Answer / Hide Answer


ANSWER: A

Explanation:

If you want that particular field should not be serialized then use NonSerialized attribute.

[Serializable]

public class Employee

public int EmpID;

[NonSerialized] public int TotalSalary;

public String EmpName;

Q.9 Which of the following attributes should you add to a member to prevent it from being serialized by
XML serialization?

A) XMLType

B) XMLIgnore

C) XMLElement

D) XMLAttribute

View Answer / Hide Answer


ANSWER: B

Explanation:

Use the XMLIgnore attribute to prevent a member from being serialized during XML serialization.

Q.10 Which of the following are requirements for a class to be serialized with XML serialization?

A) The class must be public.

B) The class must be private.

C) The class must have a parameterless constructor.

D) Option A and C are correct.

View Answer / Hide Answer

ANSWER: D

Q.11 What is/are the advantages of XML serialization? Choose the correct option.
A) Objects serialized by using XML are self-describing and easily processed.

B) An object that is serialized by using XML can be easily processed by an application written for a
different operating system in a different technology.

C) Option A and B both are correct.

D) None of the above.

View Answer / Hide Answer

ANSWER: C

Q.12 What are the steps to serialize an object by using XML Serialization?

A)

- Create an XmlSerializer object by passing it the type of object you plan to serialize.

- Call the XmlSerializer.Serialize method to serialize the object.

B)

- Create a stream (TextWriter, or XmlWriter) object to hold the serialized output.

- Create an XmlSerializer object by passing it the type of object you plan to serialize.

- Call the XmlSerializer.Serialize method to serialize the object.


C)

- Create a stream (TextWriter, or XmlWriter) object to hold the serialized output.

- Call the XmlSerializer.Serialize method to serialize the object.

D) None of the above.

View Answer / Hide Answer

ANSWER: B

Explanation:

using System;

using System.IO;

using System.Xml.Serialization;

class Program

static void Main(string[] args)

FileStream fs = new FileStream("C:\\Date.XML", FileMode.Create);

// Create an XmlSerializer object to perform the serialization

XmlSerializer XMLObj = new XmlSerializer(typeof(DateTime));

// Use the XmlSerializer object to serialize the data.


XMLObj.Serialize(fs, System.DateTime.Now);

// Close the file

fs.Close();

Q.13 Trace the output of given below code.

[XmlRoot ("CartItem")]

public class ShoppingCart

[XmlAttribute] public Int32 productId;

public decimal price;

public Int32 quantity;

[XmlIgnore] public decimal total;

public ShoppingCart()

{
}

Assume that productID=100, price=100.25 quantity=20.

A)

<?xml version="1.0" ?>

<CartItem productId="100">

<price>100.25</price>

<quantity>20</quantity>

</CartItem>

B)

<?xml version="1.0" ?>

< ShoppingCart productId="100">

<price>100.25</price>

<quantity>20</quantity>

</ ShoppingCart >

C)

<?xml version="1.0" ?>


<CartItem>

< productId="100">

<price>100.25</price>

<quantity>20</quantity>

</CartItem>

D) None of the above.

View Answer / Hide Answer

ANSWER: A

Q.1 Structure/struct comes under which type?

A) Value type

B) Reference type

C) Derived type

D) None of the above.

View Answer / Hide Answer

ANSWER: A
Q.2 Which of the following are value types?

A. Decimal

B. Integer

C. System.Drawing.Point

D. All of the above.

View Answer / Hide Answer

ANSWER: D

Q.3 Which is the correct declaration for a nullable integer?

A) int i = null;

B) Nullable(int) i = null;

C) Nullable<int> i = null;

D) None of the above.

View Answer / Hide Answer

ANSWER: C
Explanation:

You can declare the variable as nullable if you want to determine whether a value has not been
assigned. You could also use the following syntax to declare integer nullable type: int? i = null; A
Nullable<bool> can be assigned the values true false, or null.

Q.4 The default type of enumeration elements is int. Choose the correct given below code to declare an
enum as byte .

A) Days : byte {Sat=1, Sun, Mon, Tue, Wed, Thu, Fri};

B) enum Days : byte {Sat=1, Sun, Mon, Tue, Wed, Thu, Fri};

C) Days : byte enum{Sat=1, Sun, Mon, Tue, Wed, Thu, Fri};

D) None of the above.

View Answer / Hide Answer

ANSWER: B

Q.5 Reference types stores actual data in which memory location?

A) Heap
B) Stack

C) Secondry Storage

D) None of the above.

View Answer / Hide Answer

ANSWER: A

Explanation:

Reference types store the address of their data on the stack and the actual data is stored in an area of
memory called the heap.

class RefDemo

public int x;

class MyProgram

static void Main(string[] args)

RefDemo obj1 = new RefDemo();

RefDemo obj2 = obj1;

obj1.x = 10;

obj2.x = 20;

Console.WriteLine("obj1.x = {0} , obj2.x = {1}", obj1.x, obj2.x);

}
Q.6 Trace the output of given below code.

using System;

struct Numbers

public int val;

public Numbers(int n)

val = n;

class MyProgram

static void Main(string[] args)

Numbers n1 = new Numbers(0);

Numbers n2 = n1;

n1.val += 1;

n2.val += 2;
Console.WriteLine("n1 = {0}, n2 = {1}", n1.val, n2.val);

A) n1=1 , n2=2

B) n1=1 , n2=3

C) n1=2 , n2=2

D) None of the above.

View Answer / Hide Answer

ANSWER: A

Q.7 Trace the output of given below code.

using System;

class Numbers

public int val;

public Numbers(int n)

val = n;
}

class MyProgram

static void Main(string[] args)

Numbers n1 = new Numbers (0);

Numbers n2 = n1;

n1.val += 1;

n2.val += 2;

Console.WriteLine("n1 = {0}, n2 = {1}", n1.val, n2.val);

A) n1 = 3, n2 = 3

B) n1 = 3, n2 = 3

C) n1 = 3, n2 = 3

D) n1 = 3, n2 = 3

View Answer / Hide Answer

ANSWER: B
Q.8 With strict conversions enabled, which of the following would allow an implicit conversion?

A. Int16 to Int32

B. Int32 to Int16

C. Int16 to Double

D. Option A and C are correct.

View Answer / Hide Answer

ANSWER: D

Q.9 According to given below statements, choose the correct option regarding boxing and unboxing.

Statement 1: Boxing converts a value type to a reference type.

Statement 2: Unboxing converts a reference type to a value type.

Statement 3: Unboxing converts a value type to a reference type.

Statement 4: Boxing converts a reference type to a value type.

A) Statement 1 and 2 are correct.

B) Statement 3 and 4 are correct.

C) Statement 1 and 3 are correct.


D) Statement 2 and 4 are correct.

View Answer / Hide Answer

ANSWER: A

Explanation:

Converting a value type to reference type is called Boxing.

int i = 12;

object o = (object) i;

Converting a reference type to value type is called Boxing.

object o = 12;

int i = (int) o;

Q.10 According to given below statements, choose the correct option regarding boxing and unboxing.

Statement 1: Strings of type System.String is immutable in .NET

Statement 2: Strings of type System.String is mutable in .NET

Statement 3: StringBuilder class is used to create mutable strings.

Statement 4: StringBuilder class is used to create immutable strings.


A) Statement 1 and 2 are correct.

B) Statement 3 and 4 are correct.

C) Statement 1 and 3 are correct.

D) Statement 2 and 4 are correct.

View Answer / Hide Answer

ANSWER: C

Explanation:

Strings of type System.String are immutable in .NET. That means, if you have done any change to a
string, new string will be created and abandon the old one.

string s;

s = "Hello"; // Hello"

s += " how"; // "Hello how "

s += " are"; // "Hello how are "

s += "you"; // "Hello how are you"

Console.WriteLine(s);

Only the last string has a reference; the remaining will be disposed of during garbage collection. If you
want to avoid these types of temporary strings use StringBuilder class. This class is available in
System.Text namespace.

System.Text.StringBuilder sb = new System.Text.StringBuilder(30);

sb.Append("Hello");

sb.Append(" how");
sb.Append(" are");

sb.Append(" you");

string s = sb.ToString(); // Copy result to string.

Console.WriteLine(s);

Q.11 Which of the following statements are correct about an enum used in C#.NET?

A) An enumerator contains white space in its name.

B) An enumerator cannot contain white space in its name.

C) The value of each successive enumerator is decreased by 1.

D) None of the above.

View Answer / Hide Answer

ANSWER: B

Q.12 Trace the correct output for the following given below C#.NET code snippet
using System;

enum Days : int

sun = -5,

mon,

tue

class MyProgram

static void Main(string[] args)

Console.Write( (int) Days.sun + ", ");

Console.Write( (int) Days.mon + ", ");

Console.Write( (int) Days.tue );

Console.WriteLine();

A) You cannot assign negative value to the enum variable.

B) -5, -4, -3

C) Compile time error

D) -5, -6, -7

View Answer / Hide Answer


ANSWER: B

Q.13 C#.Net Primitive Type float mapped with which FCL type?

A) System.Triple

B) System.Double

C) System.Single

D) None of the above.

View Answer / Hide Answer

ANSWER: C

Q.14 What is the default access modifier for a class in c#.Net?

A) internal

B) private

C) public

D) protected
View Answer / Hide Answer

ANSWER: A

Explanation:

By default the access modifier for a class in c#.Net is internal in a namespace. You can also declare the
class as public. You cannot explicitly declare a class in a namespace as private, protected, or protected
internal.

If the class is nested within another class default access specifier is private.

Q.15 Within a namespace, what type you can declare?

A) Another namespace, class, interface, struct, enum, delegate

B) Only class and interface.

C) only class

D) None of the above.

View Answer / Hide Answer

ANSWER: A
Explnation:

Within a namespace, you can declare one or more of the following types:

Another namespace, class, interface, struct, enum, delegate.

using System;

namespace DemoNamespace

class DemoClass { }

interface DemoInterface { }

struct DemoStruct { }

enum DemoeEnum { a, b }

delegate void SampleDelegateDemo(int i);

namespace SampleNamespace.Nested

class SampleClass

static void Main()

Console.WriteLine("Welcome at careerRide.com");

}
Q.1 Trace the output of given below code.

using System;

interface IDemo

int x = 10;

class Program

static void Main(string[] args)

Console.WriteLine("Welcome at careerRide");

A) Welcome at careerRide

B) Compile time error.

C) Run time error

D) None of the above.

View Answer / Hide Answer

ANSWER: B
Explanation:

If you run the above code you will get the compile time error as follows.

Interfaces cannot contain fields. So you cannot declare variable in interface.

Q. 2

using System;

interface IDemo

void myFunction();

class Program:IDemo

static void Main(string[] args)

myFunction();

void myFunction()

{
Console.WriteLine("Welcome at careerRide.com");

A) Compile time error.

B) Welcome at careerRide.com.

C) Run time error

D) None of the above.

View Answer / Hide Answer

ANSWER: A

Explanation:

In the above code Main is static function and static function can call only static function. But still if you
want to call myFunction() then you have to create the object of the class.

using System;

interface IDemo

void myFunction();

class Program:IDemo

static Program p = new Program();


static void Main(string[] args)

p.myFunction();

public void myFunction()

Console.WriteLine("Welcome at careerRide.com");

Q.3 Which of the following can be declared (without implementation) in an interface?

A) events, indexers, methods, and properties.

B) Only methods

C) Only methods, and properties.

D) None of the above.

View Answer / Hide Answer

ANSWER: A
Q.4 Which of the following statements is correct about an interface used in C#.NET?

A) Interfaces contain no implementation of methods.

B) An interface cannot be instantiated directly.

C) Both A and B option are correct.

D) None of the above.

View Answer / Hide Answer

ANSWER: C

Q.5 According to the given statement, choose the correct option about an interface used in C#.NET.

Statement 1: A class can implement multiple interfaces.

Statement 2: Structures cannot inherit a class but can implement an interface.

Statement 3: An interface can implement multiple classes.

Statement 4: A class can implement only one interface.


A) Only statement 1 is correct.

B) Statement 1 and statement 2 are correct.

C) Statement 3 and statement 4 are correct.

D) Only statement 4 is correct.

View Answer / Hide Answer

ANSWER: B

Q.6 Which of the following is the correct implementation of the interface given below used in C#.NET?

interface IDemo

void myFunction(int x);

A) class SampleClass : IDemo

public void myFunction()

// some code

}
}

B) class SampleClass implements IDemo

public int myFunction(int x)

// some code

C) class SampleClass : IDemo

public void myFunction(int x)

// some code

D) None of the above.

View Answer / Hide Answer

ANSWER: C
Q.7 Which of the following statements is correct?

A) The methods declared in interface are by default sealed.

B) The methods declared in interface are by default public and abstract.

C) The methods declared in interface are by default private.

D) None of the above.

View Answer / Hide Answer

ANSWER: B

Q.8 Choose the correct option about the C#.NET code snippet given below?

interface IMyInterface

void function1();

void function2();

class MyClass : IMyInterface

{
void function1()

// Some code

A) Run time exception

B) Console.WriteLine("Welcome at CareerRide.com");

C) It will give compile tile error as: 'MyClass' does not implement interface member
IMyInterface.function2().

D) None of the above.

View Answer / Hide Answer

ANSWER: C

Q.9 Which of the following is the correct way to implement the interface given below in C#.Net?

interface IEmployee

String FirstName

get;
set;

A) class Emp : IEmployee

String str;

public string FirstName

get{ return str; }

set{ str = value;}

B) class Emp : implements IEmployee

String str;

public string FirstName()

get{ return str; }

set{ str = value;}

C) class Emp : IEmployee

String str;

public int FirstName


{

get{ return str; }

set{ str = value;}

D) None of the above.

View Answer / Hide Answer

ANSWER: A

Q.10 Which of the following statements is correct about the C#.NET code snippet given below?

interface IMYInterface

//---------

//---------

class BaseClass

//---------
//---------

class DerivedClass :IMYInterface , BaseClass

A) No problem in the code

B) It gives the compile time error as: Base class 'MyClass' must come before any interfaces.

C) A class cannot implement an interface and another class simultaneously.

D) None of the above

View Answer / Hide Answer

ANSWER: B

Q.11 In the given below code run method is declared in both the interfaces, which is the correct code to
call the both run method separately in C#.Net?

interface IBike

void run();

}
interface ICar

void run();

A) class MyClass :IBike,ICar

void IBike . run()

Console.WriteLine("My bike is running");

void ICar . run()

Console.WriteLine("My car is running");

B) class MyClass :IBike,ICar

void run()

Console.WriteLine("My bike is running");

void run()

{
Console.WriteLine("My car is running");

C) ) class MyClass :IBike

void run()

Console.WriteLine("My bike is running");

Console.WriteLine("My car is running");

D) None of the above.

View Answer / Hide Answer

ANSWER: A

Q.12 Refer question 11, choose the correct code to call both run method separately.
A) MyClass obj = new MyClass();

obj.run();

obj.run();

B) MyClass obj = new MyClass();

IBike bike = (IBike)obj;

ICar car = (ICar)obj;

bike.run();

car.run();

C) MyClass obj = new MyClass();

IBike bike = (IBike)obj;

ICar car = (ICar)obj;

IBike.run();

ICar.run();

D) None of the above.

View Answer / Hide Answer

ANSWER: B
Threading in .NET - placement questions

Raj Singh 10-6-2014 07:37 AM

Threading in .NET - placement questions

Q.1 Which are the two important predefined delegate in Threading?

A DelegateThreadStart and Thread.

B) ThreadStart and ParameterizedThreadStart.

C) Thread and ThreadStart.

D) None of the above.

View Answer / Hide Answer

ANSWER: B

Q.2 The types of multitasking are

A) Thread-based and process-based

B) Process-based and program-based .


C) Hardware based.

D) None of the above.

View Answer / Hide Answer

ANSWER: A

Q.3 Choose the correct option according to given below statement.

Statement 1: A program in execution is called Thread.

Statement 2: A program in execution is called Process.

Statement 3: The main purpose of threading is to perform multiple operations concurrently.

Statement 4: Thread is a light weight process.

A) Statement 1 is correct.

B) Only statement 2, and 3 are correct.

C) Statement 2, 3, and 4 are correct.

D) Only Statement 4 is correct.

View Answer / Hide Answer

ANSWER: C
Q.4 What are the two types of thread that .NET Framework supports?

A) Foreground and background.

B) Running and waiting thread.

C) Running and suspended thread.

D) None of the above.

View Answer / Hide Answer

ANSWER: A

Q.5 What method stops a running thread?

A) Thread.Suspend

B) Thread.Resume

C) Thread.Abort

D) Thread.Join
View Answer / Hide Answer

ANSWER: C

Q.6 By default, when you create a thread, What is its type?

A) Normal.

B) Background.

C) Foreground.

D) None of the above.

View Answer / Hide Answer

ANSWER: C

Q.7 Choose the correct option according to given below statement.

Statement 1: Processes does not have any thread.

Statement 2: All processes have at least two thread of execution.

Statement 3: All processes have at most one thread of execution.


Statement 4: All processes have at least one thread of execution.

A) Statement 1 is correct.

B) Only statement 2, and 3 are correct.

C) Statement 2, 3, and 4 are correct.

D) Only Statement 4 is correct.

View Answer / Hide Answer

ANSWER: D

Q.8 What type of object is required when starting a thread that requires a single parameter?

A) ThreadStart delegate

B) ParameterizedThreadStart delegate

C) ExecutionContext class

D) None of the above.

View Answer / Hide Answer

ANSWER: B
Q.9 Thread class is available in which namespace?

A) System.Thread

B) System.Threading

C) System.ThreadStart

D) None of the above.

View Answer / Hide Answer

ANSWER: B

Q.10 The default priority for a thread is.

A) Normal

B) AboveNormal

C) Highest

D) Lowest

View Answer / Hide Answer


ANSWER: A

Q.11 Suppose that there is no writer lock in place, how many readers can simultaneously read data with
a ReaderWriterLock?

A) 0

B) 1

C) 2

D) Unlimited

View Answer / Hide Answer

ANSWER: D

Q.12 When two or more threads need access to a shared resource that can be used by only one thread
at a time, is called

A) Sharing

B) Asynchronization.
C) Synchronization.

D) None of the above.

View Answer / Hide Answer

ANSWER: C

Q.13 Which condition occurs when two (or more) threads attempt to access a shared resource at the
same time, without proper synchronization?

A) Race Condition.

B) Run Condition.

C) Wait Condition.

D) None of the above.

View Answer / Hide Answer

ANSWER: A
Q.14 Which of the following can be used to synchronize threads across AppDomain and process
boundaries?

A. Monitor class

B. Mutex class

C. SyncLock

D. None of the above.

View Answer / Hide Answer

ANSWER: D

Q.15 To lock data where multiple readers can access data at once but one writer at a time can change
data, then which class will you use?

A) Mutex.

B) Monitor.

C) ReaderWriterLock

D) None of the above.

View Answer / Hide Answer

ANSWER: C
Exception handling in .NET - placement questions

Raj Singh 10-11-2014 04:52 AM

Exception handling in .NET - placement questions

Q.1 Why should you close and dispose of resources in a Finally block instead of a Catch block?

A) You cannot dispose of resources in a Catch block.

B) Finally blocks run whether or not an exception occurs.

C) The compiler throws an error if resources are not disposed in the Finally block.

D) None of the above.

View Answer / Hide Answer

ANSWER: B

Q.2 All exception classes are derived from which built-in class?
A) Exception

B) Finally

C) SystemException.

D) None of the above.

View Answer / Hide Answer

ANSWER: A

Q.3 Which of the following statements is correct about an Exception?

A) It occurs at compile time.

B) It occurs at run-time.

C) It occurs at load time.

D) None of the above.

View Answer / Hide Answer

ANSWER: B
Q.4 Trace the output of given below code.

using System;

class MyProgram

static void Main(string[] args)

int val = 100;

int[] a = new int[5];

try

a[6] = val;

catch (IndexOutOfRangeException e)

Console.WriteLine (Index out of bounds);

Console.WriteLine("Welcome at careerRide.");

}
A) Index out of bounds.

B) Welcome at careerRide.

C) Index out of bounds

Welcome at careerRide.

D) None of the above.

View Answer / Hide Answer

ANSWER: C

Q.5 Choose the correct option according to given below statement.

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

Statement 2: Try block can be nested.

Statement 3: Try block cannot be nested.

Statement 4: A try block must be associated with finally block.

A) Statement 1 and 2 are correct.

B) Only statement 3 is correct.

C) Statement 3, and 4 are correct.

D) Only Statement 4 is correct.


View Answer / Hide Answer

ANSWER: A

Q.6 Which of the following statements are correct about exception handling in C#.NET?

A) A program can contain multiple finally clauses.

B) finally clause will always executed, No matter whether an exception occurs or not.

C) A program cannot contain multiple finally clauses.

D) Option B and C are correct.

View Answer / Hide Answer

ANSWER: D

Q.7 Choose the correct option according to given below statement.

Statement 1: User-defined exceptions can be created.

Statement 2: All types of exceptions can be caught using the Exception class.
Statement 3: User-defined exceptions cannot be created.

A) Statement 1 and 2 are correct.

B) Only statement 3 is correct.

C) Statement 2, and 3 are correct.

D) Only Statement 1 is correct.

View Answer / Hide Answer

ANSWER: A

Q.8 if your program does not catch an exception, then exception is catches by

A) CTS

B) CLR

C) CLS

D) None of the above.

View Answer / Hide Answer

ANSWER: B
Q.9 Trace the output of given below code.

using System;

class Program

static void Main(string[] args)

try

Console.WriteLine("Welcome at careerRide");

catch (Exception e)

Console.WriteLine("Exception catched");

catch (DivideByZeroException e)

Console.WriteLine(" Divide by zero exception");

finally

{
Console.WriteLine("finally block executed");

A) Compile time error

B) Welcome at careerRide

C) Exception catched

D) finally block executed

View Answer / Hide Answer

ANSWER: A

Q. 10 Trace the output of given below code.

using System;

class MyProgram

static void Main(string[] args)

{
try

Console.WriteLine("Welcome to careerRide");

A) Welcome to careerRide

B) Compile time error

C) Run time error.

D) None of the above.

View Answer / Hide Answer

ANSWER: B

LINQ in .NET - placement questions

Raj Singh 10-24-2014 01:04 AM


LINQ in .NET - placement questions

Q.1 Select the correct query that will give only positive numbers. You can refer the given below array.

int[] nums = { 1, -2, 3, 0, -4, 5 ,10,20,-3,100,30};

A) var posNumber = from n in nums

where n > 0

select n;

B) var posNumber = from n in nums

where n is positive

select n;

C) var posNumber = from n in nums

where n is positive Int

select n;

D) None of the above.

View Answer / Hide Answer

ANSWER: A
Q.2 Select the correct query that will give only positive numbers less than 10.

A) var posNumber = from n in nums

where n is positive Int and less than 10

select n;

B) var posNums = from n in nums

where n > 0

where n < 10

select n;

C) var posNumber = from n in nums

where n is positive Int and < 10

select n;

D) None of the above.

View Answer / Hide Answer

ANSWER: B
Q.3 An integer array is given as follows

int[] nums = { 10, -19, 4, 7, 2, -5, 0,100,50 };

Select the correct query to find out the sorted number.

A) var sortNums = from n in nums

orderby n

B) var sortNums = from n in nums

sortedby n

select n;

C) var sortNums = from n in nums

orderby n

select n;

D) None of the above.

View Answer / Hide Answer

ANSWER: C
Q.4 Which namespace is necessary to use LINQ?

A) System.Data

B) System.Linq

C) System.Object

D) None of the above.

View Answer / Hide Answer

ANSWER: B

Q.5 What are different flavors of LINQ?

A) LINQ to Objects

B) LINQ to ADO.NET

C) LINQ to XML

D) All of the above.

View Answer / Hide Answer


ANSWER: D

Q.6 Trace the output of given below code.

List<int> numbers = new List<int>() { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };

IEnumerable<int> query = numbers.Where(num => num > 5 && num < 10);

foreach (var n in query)

Console.Write(n+" ");

A) 6 7 8 9

B) Compile Time Error

C) Run Time Error

D) None of the above.

View Answer / Hide Answer

ANSWER: A
Q.7 According to given below statements, choose the correct option.

Statement 1: A variable, declared outside the anonymous method can be accessed inside the
anonymous method.

Statement 2: A variable, declared inside the anonymous method cant be accessed outside the
anonymous method.

Statement 3: Unsafe code cant be accessed within an anonymous method.

Statement 4: Unsafe code can be accessed within an anonymous method.

A) Only statement 1 and 2 are correct.

B) Only statement 2 and 3 are correct.

C) Statement 1, 2 and 3 are correct.

D) Only statement 4 is correct.

View Answer / Hide Answer

ANSWER: C

Q.8 Trace the output of given below code.

using System;
class Program

delegate int delDemo(int x, int y);

static void Main(string[] args)

delDemo d1 = (x, y) => x * y;

delDemo d2 = (x, y) => { return x + y; };

delDemo d3 = delegate(int x, int y) { return x - y; };

int z1 = d1(10, 5);

int z2 = d2(10, 5);

int z3 = d3(10, 5);

Console.WriteLine(z1);

Console.WriteLine(z2);

Console.WriteLine(z3);

A) 50 15 5

B) 10 5

C) The above program will not compile.

D) None of the above.

View Answer / Hide Answer


ANSWER: A

Q.9 According to given below statements, choose the correct option.

Statement 1: An extension method is defined as static method but it is called like as an instance method.

Statement 2: An extension method first parameter is preceded by the "this" keyword.

Statement 3: An extension method is defined as static method and it is not called like as an instance
method.

Statement 4: An extension method first parameter does not preceded by the "this" keyword.

A) Only statement 1 and 2 are correct.

B) Only statement 2 and 3 are correct.

C) Statement 3 and 4 are correct.

D) Only statement 4 is correct.

View Answer / Hide Answer

ANSWER: A
Q.10 Trace the output of given below code.

List<int> data = new List<int> { 10, 20, 30, 40, 50 };

Console.WriteLine(data.Sum());

Console.WriteLine(data.Average());

Console.WriteLine(data.Max());

A) 50 30 150

B) 150 30 50

C) 150 50 30

D) None of the above

View Answer / Hide Answer

ANSWER: B

Q.11 Trace the output of given below code.

List<int> data = new List<int> { 10, 20, 30, 40, 50 };

Console.WriteLine(data.ElementAt(1));
A) 10

B) 20

C) 30

D) 40

View Answer / Hide Answer

ANSWER: B

Q.12 Trace the output of given below code.

List<int> data = new List<int> { 10, 20, 30, 40, 50, 60 };

Console.WriteLine(data.Single(d => d == 10));

Console.WriteLine(data.SingleOrDefault(d => d == 100));

A) 10 100

B) Single.

C) 10 0

D) None of the above.

View Answer / Hide Answer


ANSWER: C

Q.13 What is the extension of the file, when LINQ to SQL is used?

A) .dbml

B) msdb

C) accdb

D) None of the above.

View Answer / Hide Answer

ANSWER: A

Q.14 According to given below statements, choose the correct option.

Statement 1: LINQ query is compiled each and every time while stored procedures re-used the cached
execution plan to execute.

Statement 2: LINQ query does not compiled each and every time when program execute

A) Only statement 1 is correct.


B) Only statement 2 is correct.

C) Both statements are correct.

D) None of the statement is correct.

View Answer / Hide Answer

ANSWER: A

Q.15 Trace the output of given below code.

int[] num1 = { 1, 2, 3, 4, 5 };

int[] num2 = { 5, 6, 7, 8, 9, 10 };

IEnumerable<int> union = num1.Union(num2);

IEnumerable<int> intersection = num1.Intersect(num2);

IEnumerable<int> except = num1.Except(num2);

Console.Write("Union= ");

foreach(var U in union)

Console.Write("{0} ",U);

Console.Write("Intersection= ");

foreach (var I in intersection)


{

Console.Write("{0} ", I);

Console.Write("except= ");

foreach (var E in except)

Console.Write("{0} ", E);

A) Union= 1 2 3 4 5 6 7 8 9 10 Intersection=1 2 3 4 5 except= 1 2 3 4.

B) Union= 1 2 3 4 5 6 7 8 9 10 Intersection= 5 except= 1 2 3 4.

C) Union= 1 2 3 4 5 6 7 8 9 10 Intersection= 5 except= 6 7 8 9 10.

D) None of the above.

View Answer / Hide Answer

ANSWER: B

1. Which of the following can be declared in an interface?


1. Properties
2. Methods
3. Enumerations
4. Events
5. Structures
A.1, 3
B. 1, 2, 4
C. 3, 5
D.4, 5
Answer: Option B

2. A class implements two interfaces each containing three methods. The class contains no instance data. Which of
the following correctly indicate the size of the object created from this class?
A.12 bytes
B. 24 bytes
C. 0 byte
D.8 bytes
E. 16 bytes
Answer: Option B

3. Which of the following statements is correct about an interface used in C#.NET?


A.One class can implement only one interface.
In a program if one class implements an interface then no other class in the same program can implement this
B.
interface.
C. From two base interfaces a new interface cannot be inherited.
D.Properties can be declared inside an interface.
Interfaces cannot be inherited.
E.

Answer: Option D

4. Which of the following statements is correct about Interfaces used in C#.NET?


A.All interfaces are derived from an Object class.
B. Interfaces can be inherited.
C. All interfaces are derived from an Object interface.
D.Interfaces can contain only method declaration.
E. Interfaces can contain static data and methods.

Answer: Option B

5. Which of the following statements is correct about an interface used in C#.NET?


A.If a class implements an interface partially, then it becomes an abstract class.
B. A class cannot implement an interface partially.
C. An interface can contain static methods.
D.An interface can contain static data.
E. Multiple interface inheritance is not allowed.

Answer: Option A

6. Which of the following statements is correct about an interface?


A.One interface can be implemented in another interface.
B. An interface can be implemented by multiple classes in the same program.
C. A class that implements an interface can explicitly implement members of that interface.
D.The functions declared in an interface have a body.

Answer: Option C

7. Which of the following statements are correct about an interface in C#.NET?

1. A class can implement multiple interfaces.


2. Structures cannot inherit a class but can implement an interface.
3. In C#.NET, : is used to signify that a class member implements a specific interface.
4. An interface can implement multiple classes.
5. The static attribute can be used with a method that implements an interface declaration.
A.1, 2, 3
B. 2, 4
C. 3, 5
D.None of the above.

Answer: Option A

8. Which of the following statements is correct?


A.When a class inherits an interface it inherits member definitions as well as its implementations.
B. An interface cannot contain the signature of an indexer.
C. Interfaces members are automatically public.
D.To implement an interface member, the corresponding member in the class must be public as well as static.

Answer: Option C

9. Which of the following statements are correct about an interface used in C#.NET?

1. An interface can contain properties, methods and events.


2. The keyword must implement forces implementation of an interface.
3. Interfaces can be overloaded.
4. Interfaces can be implemented by a class or a struct.
5. Enhanced implementations of an interface can be developed without breaking existing code.

A.1, 2
B. 1, 4, 5
C. 3, 4
D.3 only

Answer: Option B

10. Which of the following can implement an interface?

1. Data
2. Class
3. Enum
4. Structure
5. Namespace

A.1, 3
B. 2, 4
C. 3, 5
D.4 only

Answer: Option B

11. Which of the following unary operators can be overloaded?

1. true
2. false
3. +
4. new
5. is
A.1, 2, 3
B. 3, 4, 5
C. 3 only
D.5 only

Answer: Option A

12. A derived class can stop virtual inheritance by declaring an override as


A.inherits
B. extends
C. inheritable
D.not inheritable
E. sealed

Answer: Option E

13. Which of the following keyword is used to change the data and behavior of a base class by replacing a member
of a base class with a new derived member?
A.new
B. base
C. overloads
D.override
E. overridable

Answer: Option A

14. Which of the following statements is correct?


A.When used as a modifier, the new keyword explicitly hides a member inherited from a base class.
B. Operator overloading works in different ways for structures and classes.
C. It is not necessary that all operator overloads are static methods of the class.
D.The cast operator can be overloaded.

Answer: Option A

15. 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
E. udoperator

Answer: Option C

16. Which of the following statements is correct?


A.Static methods can be a virtual method.
B. Abstract methods can be a virtual method.
C. It is necessary to override a virtual method.
When overriding a method, the names and type signatures of the override method must be the same as the
D.
virtual method that is being overriden.
E. We can override virtual as well as non-virtual methods.

Answer: Option D
17. Which of the following statements are correct about a delegate?

1. Inheritance is a prerequisite for using delegates.


2. Delegates are type-safe.
3. Delegates provide wrappers for function pointers.
4. The declaration of a delegate must match the signature of the method that we intend to call using it.
5. Functions called using delegates are always late-bound.

A. 1 and 2 only
B. 1, 2 and 3 only
C. 2, 3 and 4 only
D. All of the above
None of the above
E.

Answer: Option D

18. Which of the following statements are correct about delegates?

1. Delegates are not type-safe.


2. Delegate is a user-defined type.
3. Only one method can be bound with one delegate object.
4. Delegates can be used to implement callback notification.
5. Delegates permit execution of a method on a secondary thread in an asynchronous manner.

A. 1 and 2 only
B. 1, 2 and 3 only
C. 2, 4 and 5 only
D. 4 and 5 only
E. All of the above

Answer: Option C

19. Which of the following statements are correct about delegates?


A.Delegates cannot be used to call a static method of a class.
B. Delegates cannot be used to call procedures that receive variable number of arguments.
C. If signatures of two methods are same they can be called through the same delegate object.
D.Delegates cannot be used to call an instance function. Delegates cannot be used to call an instance subroutine.

Answer: Option B

20. Suppose on pushing a button an object is to be notified, but it is not known until runtime which object should be
notified. Which of the following programming constructs should be used to implement this idea?
A.Attribute B. Delegate
C. Namespace D.Interface
E. Encapsulation

Answer: Option B

21. Which of the following statements is incorrect about a delegate?


A.A single delegate can invoke more than one method.
B. Delegates can be shared.
C. Delegate is a value type.
D.Delegates are type-safe wrappers for function pointers.
E. The signature of a delegate must match the signature of the method that is to be called using it.

Answer: Option C

22. Suppose a Generic class called SortObjects is to be made capable of sorting objects of any type (Integer, Single,
Byte etc.). Which of the following programming constructs should be used to implement the comparision
function?
A.Namespace B. Interface
C. Encapsulation D.Delegate
E. Attribute

Answer: Option D

23. With which of the following can the ref keyword be used?

1. Static data
2. Instance data
3. Static function/subroutine
4. Instance function/subroutine

A.1, 2
B. 3, 4
C. 1, 3
D.2, 4
E. All of the above

Answer: Option B

24. Which of the following statements are correct about an ArrayList collection that implements the IEnumerable
interface?

1. The ArrayList class contains an inner class that implements the IEnumerator interface.
2. An ArrayList Collection cannot be accessed simultaneously by different threads.
3. The inner class of ArrayList can access ArrayList class's members.
4. To access members of ArrayList from the inner class, it is necessary to pass ArrayList class's reference
to it.
5. Enumerator's of ArrayList Collection can manipulate the array.

A.1 and 2 only


B. 1 and 3 and 4 only
C. 2 and 5 only
D.All of the above
E. None of the above

Answer: Option B

25. How many enumerators will exist if four threads are simultaneously working on an ArrayList object?
A.1
B. 3
C. 2
D.4
E. Depends upon the Project Setting made in Visual Studio.NET.

Answer: Option D

26. In which of the following collections is the Input/Output index-based?

1. Stack
2. Queue
3. BitArray
4. ArrayList
5. HashTable

A.1 and 2 only


B. 3 and 4 only
C. 5 only
D.1, 2 and 5 only
E. All of the above

Answer: Option B

27. Which of the following statements are correct about the Stack collection?

1. It can be used for evaluation of expressions.


2. All elements in the Stack collection can be accessed using an enumerator.
3. It is used to maintain a FIFO list.
4. All elements stored in a Stack collection must be of similar type.
5. Top-most element of the Stack collection can be accessed using the Peek() method.

A.1 and 2 only


B. 3 and 4 only
C. 1, 2 and 5 only
D.All of the above
E. None of the above

Answer: Option C

28. A HashTable t maintains a collection of names of states and capital city of each state. Which of the following is
the correct way to find out whether "Kerala" state is present in this collection or not?
A.t.ContainsKey("Kerala");
B. t.HasValue("Kerala");
C. t.HasKey("Kerala");
D.t.ContainsState("Kerala");
E. t.ContainsValue("Kerala");

Answer: Option A

29. Which of the following is NOT an interface declared in System.Collections namespace?


A.IComparer
B. Enumerable
C. Enumerator
D.IDictionaryComparer
E. IDictionaryEnumerator

Answer: Option D

30. Suppose value of the Capacity property of ArrayList Collection is set to 4. What will be the capacity of the
Collection on adding fifth element to it?
A.4 B. 8
C. 16 D.32
31. Which of the following is an ordered collection class?

1. Map
2. Stack
3. Queue
4. BitArray
5. HashTable

A.1 only
B. 2 and 3 only
C. 4 and 5 only
D.All of the above
E. None of the above

Answer: Option B

32. Which of the following is the correct way to find out the number of elements currently present in an ArrayList
Collection called arr?
A.arr.Count
B. arr.GrowSize
C. arr.MaxIndex
D.arr.Capacity
E. arr.UpperBound

Answer: Option A

33. Which of the following statements are correct about a HashTable collection?

1. It is a keyed collection.
2. It is a ordered collection.
3. It is an indexed collection.
4. It implements aIDictionaryEnumerator interface in its inner class.
5. The key - value pairs present in a HashTable can be accessed using the Keys and Values properties of
the inner class that implements the IDictionaryEnumerator interface.

A.1 and 2 only


B. 1, 2 and 3 only
C. 4 and 5 only
D.1, 4 and 5 only
E. All of the above

Answer: Option D

34. Which of the following statements are correct about the Collection Classes available in Framework Class
Library?
A.Elements of a collection cannot be transmitted over a network.
B. Elements stored in a collection can be retrieved but cannot be modified.
C. It is not easy to adopt the existing Collection classes for newtype of objects.
D.Elements stored in a collection can be modified only if allelements are of similar types.
E. They use efficient algorithms to manage the collection, thereby improving the performance of the program.

Answer: Option E

35. Which of the following statements are correct?

1. Instance members of a class can be accessed only through an object of that class.
2. A class can contain only instance data and instance member function.
3. All objects created from a class will occupy equal number of bytes in memory.
4. A class can contain Friend functions.
5. A class is a blueprint or a template according to which objects are created.

A.1, 3, 5
B. 2, 4
C. 3, 5
D.2, 4, 5
E. None of these

Answer: Option A

36. Which of the following statements is correct?


A.Procedural Programming paradigm is different than structured programming paradigm.
Object Oriented Programming paradigm stresses on dividing the logic into smaller parts and writing
B.
procedures for each part.
C. Classes and objects are corner stones of structured programming paradigm.
Object Oriented Programming paradigm gives equal importance to data and the procedures that work on the
D.
data.
E. C#.NET is a structured programming language.

Answer: Option D

37. The this reference gets created when a member function (non-shared) of a class is called.
A.True

Answer: Option A

38. Which of the following statements are correct?

1. Data membersofa class are by default public.


2. Data members of a class are by default private.
3. Member functions ofaclass are by default public.
4. A private function of a class can access a public function within the same class.
5. Member function of a class are by default private.

A.1, 3, 5
B. 1, 4
C. 2, 4, 5
D.1, 2, 3
E. None of these
Answer: Option C

39. Which of the following statements are correct about the this reference?

1. this reference can be modified in the instance member function of a class.


2. Static functions of a class never receive the this reference.
3. Instance member functions of a class always receive a this reference.
4. this reference continues to exist even after control returns from an instance member function.
5. While calling an instance member function we are not required to pass the this reference explicitly.

A.1, 4
B. 2, 3, 5
C. 3, 4
D.2, 5
E. None of these

Answer: Option B

40. Which of the following statements are correct about objects of a user-defined class called Sample?

1. All objects of Sample class will always have exactly same data.
2. Objects of Sample class may have same or different data.
3. Whether objects of Sample class will have same or different data depends upon a Project Setting made
in Visual Studio.NET.
4. Conceptually, each object of Sample class will have instance data and instance member functions of the
Sample class.
5. All objects of Sample class will share one copy of member functions.

A.1, 3
B. 2, 4
C. 4, 5
D.3, 5
E. None of these

Answer: Option C

41. Which of the following statements is correct about classes and objects in C#.NET?
A.Class is a value type.
B. Since objects are typically big in size, they are created on the stack.
C. Objects of smaller size are created on the heap.
D.Smaller objects that get created on the stack can be given names.
E. Objects are always nameless.

Answer: Option E

42. The [Serializable()] attribute gets inspected at


A.Compile-time
B. Run-time
C. Design-time
D.Linking-time
E. None of the above
Answer: Option B

43. Which of the following are correct ways to specify the targets for a custom attribute?
A.By applying AttributeUsage to the custom attribute's class definition.
B. By applying UsageAttribute to the custom attribute's class definition.
C. Once an attribute is declared it applies to all the targets.
D.By applying AttributeUsageAttribute to the custom attribute's class definition.
E. None of the above.

Answer: Option D

44. Which of the following are correct ways to pass a parameter to an attribute?

1. By value
2. By reference
3. By address
4. By position
5. By name

A.1, 2
B. 1, 2, 3
C. 4, 5
D.All of the above

Answer: Option C

45. Which of the following statements are correct about inspecting an attribute in C#.NET?

1. An attribute can be inspected at link-time.


2. An attribute can be inspected at compile-time.
3. An attribute can be inspected at run-time.
4. An attribute can be inspected at design-time.

A.1, 2
B. 3, 4
C. 1, 3, 4
D.All of the above
E. None of the above

Answer: Option A

46. Which of the following statements are correct about Attributes used in C#.NET?
If there is a custom attribute BugFixAttribute then the compiler will look ONLY for the BugFix attribute in the
A.
code that uses this attribute.
B. To create a custom attribute we need to create a custom attribute structure and derive it from System.Attribute.
C. To create a custom attribute we need to create a class and implement IAttribute interface in it.
If a BugFixAttribute is to receive three parameters then the BugFixAttribute class should implement a zero-
D.
argument constructor.
E. The CLR can change the behaviour of the code depending upon the attributes applied to it.

Answer: Option E
47. Which of the following statements are correct about Attributes in C#.NET?

1. On compiling a C#.NET program the attibutes applied are recorded in the metadata of the assembly.
2. On compilation all the attribute's tags are deleted from the program.
3. It is not possible to create custom attributes..
4. The attributes applied can be read from an assembly using Reflection class.
5. An attribute can have parameters.

A.1 and 2 only


B. 2 and 4 only
C. 1, 4 and 5 only
D.All of the above
E. None of the above

Answer: Option C

48. Which of the following correctly describes the contents of the filename AssemblyInfo.cs?
A.It contains method-level attributes.
B. It contains class-level attributes.
C. It contains assembly-level attributes.
D.It contains structure-level attributes.
E. It contains namespace-level attributes.

Answer: Option C

49. It possible to create a custom attribute that can be applied only to specific programming element(s) like ____ .
A.Classes
B. Methods
C. Classes and Methods
D.Classes, Methods and Member-Variables

Answer: Option C

50. Which of the following CANNOT be a target for a custom attribute?


A.Enum B. Event
C. Delegate D.Interface
E. Namespace

Answer: Option E

51. Once applied which of the following CANNOT inspect the applied attribute?
A.CLR
B. Linker
C. ASP.NET Runtime
D.Visual Studio.NET
E. Language compilers

Answer: Option B

52. Attributes can be applied to

1. Method
2. Class
3. Assembly
4. Namespace
5. Enum

A.1 and 2 only


B. 1, 2 and 3
C. 4 and 5 only
D.All of the above
E. None of the above

Answer: Option B.

53. If a namespace is present in a library then which of the following is the correct way to use the elements of the
namespace?

Add Reference of the namespace.


A.
Use the elements of the namespace.
Add Reference of the namespace.
B. Import the namespace.
Use the elements of the namespace.
Import the namespace.
C.
Use the elements of the namespace.
Copy the library in the same directory as the project that is trying to use it.
D.
Use the elements of the namespace.
Install the namespace in Global Assembly Cache.
E.
Use the elements of the namespace.

Answer: Option B

54. Which of the following is NOT a namespace in the .NET Framework Class Library?

A. System.Process
B. System.Security
C. System.Threading
D. System.Drawing
E. System.Xml

Answer: Option A

55. Which of the following statements is correct about a namespace in C#.NET?


A. Namespaces help us to control the visibility of the elements present in it.
B. A namespace can contain a class but not another namespace.
C. If not mentioned, then the name 'root' gets assigned to the namespace.
D. It is necessary to use the using statement to be able to use an element of a namespace.
E. We need to organise the classes declared in Framework Class Library into different namespaces.

Answer: Option A

56. Which of the following is absolutely neccessary to use a class Point present in namespace Graph stored in
library?
A. Use fully qualified name of the Point class.
B. Use using statement before using the Point class.
C. Add Reference of the library before using the Point class.
D. Use using statement before using the Point class.
E. Copy the library into the current project directory before using the Point class.

Answer: Option C

57. Which of the followings are NOT a .NET namespace?

1. System.Web
2. System.Process
3. System.Data
4. System.Drawing2D
5. System.Drawing3D

A. 1, 3
B. 2, 4, 5
C. 3, 5
D. 1, 2, 3

Answer: Option B

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


A. Namespaces can be nested only up to level 5.
B. A namespace cannot be nested.
C. There is no limit on the number of levels while nesting namespaces.
If namespaces are nested, then it is necessary to use using statement while using the elements of the inner
D.
namespace.
E. Nesting of namespaces is permitted, provided all the inner namespaces are declared in the same file.

Answer: Option C

59. Which of the following statements is correct about the using statement used in C#.NET?
A. using statement can be placed anywhere in the C#.NET source code file.
B. It is permitted to define a member at namespace level as a using alias.
C. A C#.NET source code file can contain any number of using statement.
D. By using using statement it is possible to create an alias for the namespace but not for the namespace element.
E. By using using statement it is possible to create an alias for the namespace element but not for the namespace.

Answer: Option C

60. Which of the following statements are correct about a namespace used in C#.NET?

1. Classes must belong to a namespace, whereas structures need not.


2. Every class, struct, enum, delegate and interlace has to belong to some or the other namespace.
3. All elements of the namespace have to belong to one file.
4. If not mentioned, a namespace takes the name of the current project.
5. The namespace should be imported to be able to use the elements in it.

A. 1, 3
B. 2, 4, 5
C. 3, 5
D. 4 only

Answer: Option B
61. Which of the following CANNOT belong to a C#.NET Namespace?
A. class B. struct
C. enum D. Data
E. interface

Answer: Option D

62. Which of the following statements is correct about a namespace used in C#.NET?
A. Nested namespaces are not allowed.
B. Importing outer namespace imports inner namespace.
C. Nested namespaces are allowed.
D. If nested, the namespaces cannot be split across files.

Answer: Option C

63. A property can be declared inside a class, struct, Interface.


A. True B. False

Answer: Option A

64. Which of the following statements is correct about properties used in C#.NET?
A. A property can simultaneously be read only or write only.
B. A property can be either read only or write only.
C. A write only property will have only get accessor.
D. A write only property will always return a value.

Answer: Option B

65. A Student class has a property called rollNo and stu is a reference to a Student object and we want the statement
stu.RollNo = 28 to fail. Which of the following options will ensure this functionality?
A. Declare rollNo property with both get and set accessors.
B. Declare rollNo property with only set accessor.
C. Declare rollNo property with get, set and normal accessors.
D. Declare rollNo property with only get accessor.
E. None of the above

Answer: Option D

66. Which of the following statements are correct?

1. The signature of an indexer consists of the number and types of its formal parameters.
2. Indexers are similar to properties except that their accessors take parameters.
3. Accessors of interface indexers use modifiers.
4. The type of an indexer and the type of its parameters must be at least as accessible as the indexer itself.
5. An interface accessor contains a body.

A. 1, 3, 5
B. 1, 2, 4
C. 3, 5
D. 2, 4

Answer: Option B
67. A property can be declared inside a namespace or a procedure.
A. True B. False

Answer: Option B

68.Which of the following statements is correct about properties used in C#.NET?

A. Every property must have a set accessor and a get accessor.


B. Properties cannot be overloaded.
C. Properties of a class are actually methods that work like data members.
D. A property has to be either read only or a write only.

Answer: Option C

69. Which of the folowing does an indexer allow to index in the same way as an array?

1. A class
2. A property
3. A struct
4. A function
5. An interface

A. 1, 3, 5
B. 2, 4
C. 3, 5
D. 3, 4, 5

Answer: Option A

70. An Employee class has a property called age and emp is reference to a Employee object and we want the
statement Console.WriteLine(emp.age) to fail. Which of the following options will ensure this functionality?
A. Declare age property with only get accessor.
B. Declare age property with only set accessor.
C. Declare age property with both get and set accessors.
D. Declare age property with get, set and normal accessors.
E. None of the above

Answer: Option B

71. Which of the following statements are correct about an enum used inC#.NET?

1. By default the first enumerator has the value equal to the number of elements present in the list.
2. The value of each successive enumerator is decreased by 1.
3. An enumerator contains white space in its name.
4. A variable cannot be assigned to an enum element.
5. Values of enum elements cannot be populated from a database.

A. 1, 2
B. 3, 4
C. 4, 5
D. 1, 4

Answer: Option C
72. Which of the following statements is true about an enum used in C#.NET?

A. An implicit cast is needed to convert from enum type to an integral type.


B. An enum variable cannot have a public access modifier.
C. An enum variable cannot have a private access modifier.
D. An enum variable can be defined inside a class or a namespace.
E. An enum variable cannot have a protected access modifier.

Answer: Option D

73. Which of the following statements are correct about an enum used inC#.NET?

1. To use the keyword enum, we should either use [enum] or System.Enum.


2. enum is a keyword.
3. Enum is class declared in System.Type namespace.
4. Enum is a class declared in the current project's root namespace.
5. Enum is a class declared in System namespace.

A. 1, 3
B. 2, 4
C. 2, 5
D. 3, 4

Answer: Option C

74. An enum that is declared inside a class, struct, namespace or interface is treated as public.
A. True B. False

Answer: Option A

75. An enum can be declared inside a class, struct, namespace or interface.


A. True B. False

Answer: Option A

76. Which of the following CANNOT be used as an underlying datatype for an enum in C#.NET?
A. byte
B. short
C. float
D. int

Answer: Option C

77.Which of the following statements are correct about enum used in C#.NET?

1. Every enum is derived from an Object class.


2. Every enum is a value type.
3. There does not exist a way to print an element of an enum as a string.
4. Every enum is a reference type.
5. The default underlying datatype of an enum is int.

A. 1, 2, 5
B. 1, 4
C. 3, 5
D. 2, 3, 4

Answer: Option A

78. Which of the following statements is correct about an enum used in C#.NET?
A. enum is a reference type.
B. enum is a value type.
C. Whether it a value type or a reference type depends upon size.
D. Whether it a value type or a reference type depends upon a Project Setting made in Visual Stiiclio.NET.
E. We can programmatically control whether it is a value type or a reference type.

Answer: Option B

79. Which of the following statements are correct about an enum used in C#.NET?

1. An enum can be declared inside a class.


2. An enum can take Single, Double or Decimal values.
3. An enum can be declared outside a class.
4. An enum can be declared inside/outside a namespace.
5. An object can be assigned to an enum variable.

A. 1, 3, 4
B. 2, 5
C. 3, 4
D. 2, 4, 5

Answer: Option A

80. The string built using the String class are immutable (unchangeable), whereas, the ones built- using the
StringBuilder class are mutable.
A. True B. False

Answer: Option A

11.

Which of the following statements about a String is correct?

A. A String is created on the stack.


B. Whether a String is created on the stack or the heap depends on the length of the String.
C. A String is a primitive.
D. A String can be created by using the statement String s1 = new String;
E. A String is created on the heap.

Answer: Option E

81. Which of the following statement is correct about a String in C#.NET?


A. A String is mutable because it can be modified once it has been created.
B. Methods of the String class can be used to modify the string.
C. A number CANNOT be represented in the form of a String.
D. A String has a zero-based index.
E. The System.Array class is used to represent a string.
Answer: Option D

82. Which of the following statements are correct about the String Class in C#.NET?

1. Two strings can be concatenated by using an expression of the form s3 = s1 + s2;


2. String is a primitive in C#.NET.
3. A string built using StringBuilder Class is Mutable.
4. A string built using String Class is Immutable.
5. Two strings can be concatenated by using an expression of the form s3 = s1&s2;

A. 1, 2, 5
B. 2, 4
C. 1, 3, 4
D. 3, 5

Answer: Option C

83. Which of the following statements are correct?

1. String is a value type.


2. String literals can contain any character literal including escape sequences.
3. The equality operators are defined to compare the values of string objects as well as references.
4. Attempting to access a character that is outside the bounds of the string results in an
IndexOutOfRangeException.
5. The contents of a string object can be changed after the object is created.

A. 1, 3
B. 3, 5
C. 2, 4
D. 1, 2, 4

Answer: Option C

84. Which one of the following statements is correct?


A. Array elements can be of integer type only.
B. The rank of an Array is the total number of elements it can contain.
C. The length of an Array is the number of dimensions in the Array.
D. The default value of numeric array elements is zero.
E. The Array elements are guaranteed to be sorted.

Answer: Option D

85. Which of the following statements are correct about arrays used in C#.NET?

1. Arrays can be rectangular or jagged.


2. Rectangular arrays have similar rows stored in adjacent memory locations.
3. Jagged arrays do not have an access to the methods of System.Array Class.
4. Rectangular arrays do not have an access to the methods of System.Array Class.
5. Jagged arrays have dissimilar rows stored in non-adjacent memory locations.

A. 1, 2
B. 1, 3, 5
C. 3, 4
D. 1, 2, 5
E. 4, 5

Answer: Option D

86. The space required for structure variables is allocated on stack.


A. True B. False

Answer: Option A

87. Creating empty structures is allowed in C#.NET.


A. True B. False

Answer: Option B

88. Which of the following statements are correct?

1. A struct can contain properties.


2. A struct can contain constructors.
3. A struct can contain protected data members.
4. A struct cannot contain methods.
5. A struct cannot contain constants.

A. 1, 2
B. 3, 4
C. 1, 2, 4
D. 3, 5

Answer: Option A

89. C#.NET structures are always value types.


A. True B. False

Answer: Option A

90. When would a structure variable get destroyed?


A. When no reference refers to it, it will get garbage collected.
B. Depends upon whether it is created using new or without using new.
C. When it goes out of scope.
D. Depends upon the Project Settings made in Visual Studio.NET.
E. Depends upon whether we free it's memory using free() or delete().

Answer: Option C

91. Which of the following statements is correct?


A. A struct never declares a default constructor.
B. All value types in C# inherently derive from ValueType, which inherits from Object.
C. A struct never declares a default destructor.
D. In C#, classes and structs are semantically same.

Answer: Option B
92. Which of the following are true about classes and struct?

1. A class is a reference type, whereas a struct is a value type.


2. Objects are created using new, whereas structure variables can be created either using new or without using
new.
3. A structure variable will always be created slower than an object.
4. A structure variable will die when it goes out of scope.
5. An object will die when it goes out of scope.

A. 1, 2, 4
B. 3, 5
C. 2, 4
D. 3, 4, 5

Answer: Option A

93. Which of the following statements are correct about Structures used in C#.NET?

1. A Structure can be declared within a procedure.


2. Structs can implement an interface but they cannot inherit from another struct.
3. struct members cannot be declared as protected.
4. A Structure can be empty.
5. It is an error to initialize an instance field in a struct.

A. 1, 2, 4
B. 2, 3, 5
C. 2, 4
D. 1, 3

Answer: Option B

94. Which of the following statements are TRUE about the .NET CLR?

1. It provides a language-neutral development & execution environment.


2. It ensures that an application would not be able to access memory that it is not authorized to access.
3. It provides services to run "managed" applications.
4. The resources are garbage collected.
5. It provides services to run "unmanaged" applications.

A.Only 1 and 2
B. Only 1, 2 and 4
C. 1, 2, 3, 4
D.Only 4 and 5
E. Only 3 and 4

Answer: Option C

95. Which of the following are valid .NET CLR JIT performance counters?

1. Total memory used for JIT compilation


2. Average memory used for JIT compilation
3. Number of methods that failed to compile with the standard JIT
4. Percentage of processor time spent performing JIT compilation
5. Percentage of memory currently dedicated for JIT compilation

A. 1, 5
B. 3, 4
C. 1, 2
D. 4, 5

Answer: Option B

96. Which of the following statements is correct about Managed Code?


A.Managed code is the code that is compiled by the JIT compilers.
B. Managed code is the code where resources are Garbage Collected.
C. Managed code is the code that runs on top of Windows.
D.Managed code is the code that is written to target the services of the CLR.
E. Managed code is the code that can run on top of Linux.

Answer: Option D

97. Which of the following utilities can be used to compile managed assemblies into processor-specific native code?
A.gacutil B. ngen
C. sn D.dumpbin
E. ildasm

Answer: Option B

98. Which of the following are NOT true about .NET Framework?

1. It provides a consistent object-oriented programming environment whether object code is stored and
executed locally, executed locally but Internet-distributed, or executed remotely.
2. It provides a code-execution environment that minimizes software deployment and versioning conflicts.
3. It provides a code-execution environment that promotes safe execution of code, including code created
by an unknown or semi-trusted third party.
4. It provides different programming models for Windows-based applications and Web-based
applications.
5. It provides an event driven programming model for building Windows Device Drivers.

A.1, 2
B. 2, 4
C. 4, 5
D.1, 2, 4

Answer: Option C

99. Which of the following components of the .NET framework provide an extensible set of classes that can be used
by any .NET compliant programming language?
A..NET class libraries
B. Common Language Runtime
C. Common Language Infrastructure
D.Component Object Model
E. Common Type System

Answer: Option A
100. Which of the following jobs are NOT performed by Garbage Collector?

1. Freeing memory on the stack.


2. Avoiding memory leaks.
3. Freeing memory occupied by unreferenced objects.
4. Closing unclosed database collections.
5. Closing unclosed files.

A.1, 2, 3
B. 3, 5
C. 1, 4, 5
D.3, 4

Answer: Option C

101. Which of the following .NET components can be used to remove unused references from the managed heap?
A.Common Language Infrastructure
B. CLR
C. Garbage Collector
D.Class Loader
E. CTS

Answer: Option C

102. Which of the following statements correctly define .NET Framework?


It is an environment for developing, building, deploying and executing Desktop Applications, Web
A.
Applications and Web Services.
B. It is an environment for developing, building, deploying and executing only Web Applications.
C. It is an environment for developing, building, deploying and executing Distributed Applications.
D.It is an environment for developing, building, deploying and executing Web Services.
E. It is an environment for development and execution of Windows applications.

Answer: Option A

103. Which of the following constitutes the .NET Framework?

1. ASP.NET Applications
2. CLR
3. Framework Class Library
4. WinForm Applications
5. Windows Services

A.1, 2
B. 2, 3
C. 3, 4
D.2, 5

Answer: Option B

104. Which of the following assemblies can be stored in Global Assembly Cache?
A.Private Assemblies
B. Friend Assemblies
C. Shared Assemblies
D.Public Assemblies
E. Protected Assemblies

Answer: Option C

105. Code that targets the Common Language Runtime is known as


A.Unmanaged
B. Distributed
C. Legacy
D.Managed Code
E. Native Code

Answer: Option D

106. Which of the following statements is correct about the .NET Framework?
A..NET Framework uses DCOM for achieving language interoperability.
B. .NET Framework is built on the DCOM technology.
C. .NET Framework uses DCOM for making transition between managed and unmanaged code.
D..NET Framework uses DCOM for creating unmanaged applications.
E. .NET Framework uses COM+ services while creating Distributed Applications.

Answer: Option C

107. Which of the following is the root of the .NET type hierarchy?
A.System.Object
B. System.Type
C. System.Base
D.System.Parent
E. System.Root

Answer: Option A

108. Which of the following benefits do we get on running managed code under CLR?

1. Type safety of the code running under CLR is assured.


2. It is ensured that an application would not access the memory that it is not authorized to access.
3. It launches separate process for every application running under it.
4. The resources are Garbage collected.

A.Only 1 and 2
B. Only 2, 3 and 4
C. Only 1, 2 and 4
D.Only 4
E. All of the above

Answer: Option E

109. Which of the following security features can .NET applications avail?

1. PIN Security
2. Code Access Security
3. Role Based Security
4. Authentication Security
5. Biorhythm Security

A.1, 4, 5
B. 2, 5
C. 2, 3
D.3, 4

Answer: Option C

110. Which of the following jobs are done by Common Language Runtime?

1. It provides core services such as memory management, thread management, and remoting.
2. It enforces strict type safety.
3. It provides Code Access Security.
4. It provides Garbage Collection Services.

A.Only 1 and 2
B. Only 3, 4
C. Only 1, 3 and 4
D.Only 2, 3 and 4
E. All of the above

Answer: Option E

111. Which of the following statements are correct about a .NET Assembly?

1. It is the smallest deployable unit.


2. Each assembly has only one entry point - Main(), WinMain() or DLLMain().
3. An assembly can be a Shared assembly or a Private assembly.
4. An assembly can contain only code and data.
5. An assembly is always in the form of an EXE file.

A.1, 2, 3
B. 2, 4, 5
C. 1, 3, 5
D.1, 2

Answer: Option A

112. Which of the following statements are correct about JIT?

1. JIT compiler compiles instructions into machine code at run time.


2. The code compiler by the JIT compiler runs under CLR.
3. The instructions compiled by JIT compilers are written in native code.
4. The instructions compiled by JIT compilers are written in Intermediate Language (IL) code.
5. The method is JIT compiled even if it is not called

A.1, 2, 3
B. 2, 4
C. 3, 4, 5
D.1, 2
Which of the following are parts of the .NET Framework?
1. The Common Language Runtime (CLR)
2. The Framework Class Libraries (FCL)
3. Microsoft Published Web Services
4. Applications deployed on IIS
5. Mobile Applications

A.Only 1, 2, 3
B. Only 1, 2
C. Only 1, 2, 4
D.Only 4, 5
E. All of the above

Answer: Option B

113. Which of the following statements are correct about data types?

1. If the integer literal exceeds the range of byte, a compilation error will occur.
2. We cannot implicitly convert non-literal numeric types of larger storage size to byte.
3. Byte cannot be implicitly converted to float.
4. A char can be implicitly converted to only int data type.
5. We can cast the integral character codes.

A.1, 3, 5
B. 2, 4
C. 3, 5
D.1, 2, 5

Answer: Option D

114. Which of the following is an 8-byte Integer?


A.Char
B. Long
C. Short
D.Byte
E. Integer

Answer: Option B

115. Which of the following is NOT an Integer?


A.Char
B. Byte
C. Integer
D.Short
E. Long

Answer: Option A

116. Which of the following statements is correct?


A.Information is never lost during narrowing conversions.
B. The CInteger() function can be used to convert a Single to an Integer.
C. Widening conversions take place automatically.
D.Assigning an Integer to an Object type is known as Unboxing.
E. 3.14 can be treated as Decimal by using it in the form 3.14F.

Answer: Option C

117. Which of the following are value types?

1. Integer
2. Array
3. Single
4. String
5. Long

A.1, 2, 5
B. 1, 3, 5
C. 2, 4
D.3, 5

Answer: Option B

118. Which of the following does not store a sign?


A.Short
B. Integer
C. Long
D.Byte
E. Single

Answer: Option D

119. What is the size of a Decimal?


A.4 byte
B. 8 byte
C. 16 byte
D.32 byte

Answer: Option C

120. Which of the following is the correct size of a Decimaldatatype?


A.8 Bytes
B. 4 Bytes
C. 10 Bytes
D.16 Bytes
E. None of the above.

Answer: Option D

121. Which of the following statements are correct?

1. We can assign values of any type to variables of type object.


2. When a variable of a value type is converted to object, it is said to be unboxed.
3. When a variable of type object is converted to a value type, it is said to be boxed.
4. Boolean variable cannot have a value of null.
5. When a value type is boxed, an entirely new object must be allocated and constructed.

A.2, 5
B. 1, 5
C. 3, 4
D.2, 3

Answer: Option B

122. Which of the following statements are correct about data types?

1. Each value type has an implicit default constructor that initializes the default value of that type.
2. It is possible for a value type to contain the null value.
3. All value types are derived implicitly from System.ValueType class.
4. It is not essential that local variables in C# must be initialized before being used.
5. Variables of reference types referred to as objects and store references to the actual data.

A.1, 3, 5
B. 2, 4
C. 3, 5
D.2, 3, 4

Answer: Option A

123. Which of the following statements are correct about datatypes in C#.NET?

1. Every datatype is either a value type or a reference type.


2. Value types are always created on the heap.
3. Reference types are always created on the stack.
4. Mapping of every value type to a type in Common Type System facilitates Interoperability in
C#.NET.
5. Every reference type gets mapped to a type in Common Type System.

A.1, 3
B. 2, 5
C. 1, 4
D.3, 4

Answer: Option C

124. Which of the following is the correct default value of a Boolean type?
A.0 B. 1
C. True D.False
E. -1

Answer: Option D

125. Which of the following statements is correct?


A.It is not possible to extend the if statement to handle multiple conditions using the else-if arrangement.
The switch statement can include any number of case instances with two case statements having the same
B.
value.
A jump statement such as a break is required after each case block excluding the last block if it is a default
C.
statement.
D.The if statement selects a statement for execution based on the value of a Boolean expression.
E. C# always supports an implicit fall through from one case label to another.

Answer: Option D

126. Which of the following can be used to terminate a while loop and transfer control outside the loop?

1. exit while
2. continue
3. exit statement
4. break
5. goto

A.1, 3
B. 2, 4
C. 3, 5
D.4, 5
E. None of these

Answer: Option D

127. Which of the following statements are correct?

1. A switch statement can act on numerical as well as Boolean types.


2. A switch statement can act on characters, strings and enumerations types.
3. We cannot declare variables within a case statement if it is not enclosed by { }.
4. The foreach statement is used to iterate through the collection to get the desired information and
should be used to change the contents of the collection to avoid unpredictable side effects.
5. All of the expressions of the for statement are not optional.

A.1, 2
B. 2, 3
C. 3, 5
D.4, 5
E. None of these

Answer: Option A

128. Which of the following statements are correct?

1. The switch statement is a control statement that handles multiple selections and enumerations by
passing control to one of the case statements within its body.
2. The goto statement passes control to the next iteration of the enclosing iteration statement in which it
appears.
3. Branching is performed using jump statements which cause an immediate transfer of the program
control.
4. A common use of continue is to transfer control to a specific switch-case label or the default label in a
switch statement.
5. The do statement executes a statement or a block of statements enclosed in {}repeatedly until a
specified expression evaluates to false.

A.1, 2, 4
B. 1, 3, 5
C. 2, 3, 4
D.3, 4, 5
E. None of these

Answer: Option B

129. Which of the following statements is correct?


A.It is not possible to extend the if statement to handle multiple conditions using the else-if arrangement.
The switch statement can include any number of case instances with two case statements having the same
B.
value.
A jump statement such as a break is required after each case block excluding the last block if it is a default
C.
statement.
D.The if statement selects a statement for execution based on the value of a Boolean expression.
E. C# always supports an implicit fall through from one case label to another.

Answer: Option D

130. Which of the following can be used to terminate a while loop and transfer control outside the loop?

1. exit while
2. continue
3. exit statement
4. break
5. goto

A.1, 3
B. 2, 4
C. 3, 5
D.4, 5
E. None of these

Answer: Option D

131. Which of the following statements are correct?

1. A switch statement can act on numerical as well as Boolean types.


2. A switch statement can act on characters, strings and enumerations types.
3. We cannot declare variables within a case statement if it is not enclosed by { }.
4. The foreach statement is used to iterate through the collection to get the desired information and
should be used to change the contents of the collection to avoid unpredictable side effects.
5. All of the expressions of the for statement are not optional.

A.1, 2
B. 2, 3
C. 3, 5
D.4, 5
E. None of these

Answer: Option A

132. Which of the following statements are correct?

1. The switch statement is a control statement that handles multiple selections and enumerations by
passing control to one of the case statements within its body.
2. The goto statement passes control to the next iteration of the enclosing iteration statement in which it
appears.
3. Branching is performed using jump statements which cause an immediate transfer of the program
control.
4. A common use of continue is to transfer control to a specific switch-case label or the default label in a
switch statement.
5. The do statement executes a statement or a block of statements enclosed in {} repeatedly until a
specified expression evaluates to false.

A.1, 2, 4
B. 1, 3, 5
C. 2, 3, 4
D.3, 4, 5
E. None of these

Answer: Option B

133. Which of the following is NOT an Arithmetic operator in C#.NET?


A.** B. +
C. / D.%
E. *

Answer: Option A

134. Which of the following are NOT Relational operators in C#.NET?

1. >=
2. !=
3. Not
4. <=
5. <>=

A.1, 3
B. 2, 4
C. 3, 5
D.4, 5
E. None of these

Answer: Option C

135. Which of the following is NOT a Bitwise operator in C#.NET?


A.& B. |
C. << D.^
E. ~

Answer: Option C

136. Which of the following statements are correct about the Bitwise & operator used in C#.NET?

1. The & operator can be used to Invert a bit.


2. The & operator can be used to put ON a bit.
3. The & operator can be used to put OFF a bit.
4. The & operator can be used to check whether a bit is ON.
5. The & operator can be used to check whether a bit is OFF.

A.1, 2, 4
B. 2, 3, 5
C. 3, 4
D.3, 4, 5
E. None of these

Answer: Option D

137. Which of the following are Logical operators in C#.NET?

1. &&
2. ||
3. !
4. Xor
5. %

A.1, 2, 3
B. 1, 3, 4
C. 2, 4, 5
D.3, 4, 5
E. None of these

Answer: Option A

138. Which of the following statements is correct about Bitwise | operator used in C#.NET?
A.The | operator can be used to put OFF a bit.
B. The | operator can be used to Invert a bit.
C. The | operator can be used to check whether a bit is ON.
D.The | operator can be used to check whether a bit is OFF.
E. The | operator can be used to put ON a bit.

Answer: Option E

139. Which of the following is NOT an Assignment operator in C#.NET?


A.\= B. /=
C. *= D.+=
E. %=

Answer: Option A

140. Which of the following statements is correct about Bitwise ^ operator used in C#.NET?
A.The ^ operator can be used to put ON a bit.
B. The ^ operator can be used to put OFF a bit.
C. The ^ operator can be used to Invert a bit.
D.The ^ operator can be used to check whether a bit is ON.
E. The ^ operator can be used to check whether a bit is OFF.

Answer: Option C
141.Which of the following statements are correct?

1. The conditional operator (?:) returns one of two values depending on the value of a Boolean
expression.
2. The as operator in C#.NET is used to perform conversions between compatible reference types.
3. The &* operator is also used to declare pointer types and to dereference pointers.
4. The -> operator combines pointer dereferencing and member access.
5. In addition to being used to specify the order of operations in an expression, brackets [ ] are used to
specify casts or type conversions.

A.1, 2, 4
B. 2, 3, 5
C. 3, 4, 5
D.1, 3, 5
E. None of these

Answer: Option A

142. Which of the following statements are correct?

1. An argument passed to a ref parameter need not be initialized first.


2. Variables passed as out arguments need to be initialized prior to being passed.
3. Argument that uses params keyword must be the last argument of variable argument list of a method.
4. Pass by reference eliminates the overhead of copying large data items.
5. To use a ref parameter only the calling method must explicitly use the ref keyword.

A.1, 2
B. 2, 3
C. 3, 4
D.4, 5
E. None of these
143. A function returns a value, whereas a subroutine cannot return a value.
A.True B.False

Answer: Option A

144. Which of the following statements are correct about functions and subroutines used in C#.NET?

1. A function cannot be called from a subroutine.


2. The ref keyword causes arguments to be passed by reference.
3. While using ref keyword any changes made to the parameter in the method will be reflected in that
variable when control passes back to the calling method.
4. A subroutine cannot be called from a function.
5. Functions and subroutines can be called recursively.

A.1, 2, 4
B. 2, 3, 5
C. 3, 5
D.4, 5
E. None of these

Answer: Option B
145. Which of the following statements are correct?

1. C# allows a function to have arguments with default values.


2. C# allows a function to have variable number of arguments.
3. Omitting the return value type in method definition results into an exception.
4. Redefining a method parameter in the method's body causes an exception.
5. params is used to specify the syntax for a function with variable number of arguments.

A.1, 3, 5
B. 3, 4, 5
C. 2, 5
D.4, 5
E. None of these

Answer: Option C

146. Which of the following statements are correct about functions used in C#.NET?

1. Function definitions cannot be nested.


2. Functions can be called recursively.
3. If we do not return a value from a function then a value -1 gets returned.
4. To return the control from middle of a function exit function should be used.
5. Function calls can be nested.

A.1, 2, 5
B. 2, 3, 5
C. 2, 3
D.4, 5
E. None of these

Answer: Option A

147. How many values is a function capable of returning?


A.1
B. 0
C. Depends upon how many params arguments does it use.
D.Any number of values.
E. Depends upon how many ref arguments does it use.

Answer: Option A

148. How many values is a subroutine capable of returning?


A.Depends upon how many params arguments does it use.
B. Any number of values.
C. Depends upon how many ref arguments does it use.
D.0
E. 1

Answer: Option D

149. Which of the following CANNOT occur multiple number of times in a program?
A.namespace B. Entrypoint
C. Class D.Function
E. Subroutine

Answer: Option B

150. Which of the following statements are correct about subroutines used in C#.NET?

1. If we do not return a value from a subroutine then a value -1 gets returned.


2. Subroutine definitions cannot be nested.
3. Subroutine can be called recursively.
4. To return the control from middle of a subroutine exit subroutine should be used.
5. Subroutine calls can be nested.

A.1, 2, 3
B. 2, 3, 5
C. 3, 5
D.3, 4
E. None of these

Answer: Option B

151. A function can be used in an expression, whereas a subroutine cannot be.


A.True B.False

Answer: Option A

152.Which one of the following classes are present System.Collections.Generic namespace?

1. Stack
2. Tree
3. SortedDictionary
4. SortedArray

A.1 and 2 only


B. 2 and 4 only
C. 1 and 3 only
D.All of the above
E. None of the above

Answer: Option C

153. Which of the following statements are valid about generics in .NET Framework?

1. Generics is a language feature.


2. We can create a generic class, however, we cannot create a generic interface in C#.NET.
3. Generics delegates are not allowed in C#.NET.
4. Generics are useful in collection classes in .NET framework.
5. None of the above

A.1 and 2 Only


B. 1, 2 and 3 Only
C. 1 and 4 Only
D.All of the above
E. None of the above

Answer: Option C

154. Which of the following statements is valid about generic procedures in C#.NET?
A.All procedures in a Generic class are generic.
B. Only those procedures labeled as Generic are generic.
C. Generic procedures can take at the most one generic parameter.
D.Generic procedures must take at least one type parameter.
E. None of the above.

Answer: Option D

155. Which of the following statements is valid about advantages of generics?


A.Generics shift the burden of type safety to the programmer rather than compiler.
B. Generics require use of explicit type casting.
C. Generics provide type safety without the overhead of multiple implementations.
D.Generics eliminate the possibility of run-time errors.
E. None of the above.

Answer: Option C

Which of the following is not a .NET


compatible language?
A. C#, J#
B. VB.NET
C. Managed C++
D. Java
E. COBOL.NET, Perl.NET

See Answer & Explanation Lets Discuss


Correct answer is : D
Explanation
Java is not compliant with CLS defined in .NET.
Common language
specification (CLS)
A. is an execution engine for all .NET applications.
B. is similar to JVM as in Java.
C. defines standard rules for defining .NET compliant languages.
D. is a compiler.

See Answer & Explanation Lets Discuss


Correct answer is : C
Explanation
The CLS is a group of rules that describes a complete set of features any .NET-aware
compiler must support in order to produce instructions(code) that can be run on CLR.

Common Type Structure


(CTS)
A. defines data types in order to be run by CLR.
B. defines a set of rules for all compilers to generate managed code
for .NET.
C. describes a set of features that different languages have in
common.
D. All of the above.
E. None of the above.

See Answer & Explanation Lets Discuss


Correct answer is : A
Explanation
Data types is chosen from the set (class, structure, interface, enumeration, delegate).

Which of the following statement


is not correct?
A. CLR is an execution engine of .NET.
B. Assembly is a logical unit of deployment.
C. CLR executes managed code.
D. .NET provides cross language interoperability using code
access security.
See Answer & Explanation Lets Discuss
Correct answer is : D
Contents of assembly file can be
investigated using
A. ILDASM.exe
B. ILDASM.dll
C. ILDASM.inc
D. ILDASM.aspx

See Answer & Explanation Lets Discuss


Correct answer is : A
Explanation
ildasm.exe enables us to load any .NET assembly and investigate its contents, including
related manifest, CIL instructions and type metadata.

Which of the following statements is


correct about Managed Code?
A. Managed code is the code that is compiled by the
JIT compilers.
B. Managed code is the code where resources are
Garbage Collected.
C. Managed code is the code that is written to target
the services of the CLR.
D. Managed code is the code that runs on top of
Windows.
E. Managed code is the code that can run on top of
Linux.
See Answer & Explanation Lets Discuss
Correct answer is : C
Explanation
Applications that run on top of CLR are known as managed code and all others are known as
unmanaged code.
Which of the following utilities can be used to
compile managed assemblies into processor-specific
native code?
A. gacutil
B. ngen
C. sn
D. ildasm
E. dumpbin

See Answer & Explanation Lets Discuss


Correct answer is : B

Which of the followig statement is true


regarding classes and objects? (Choose all that
apply)
A. Class is a blue print that describes how an
instance of this class will look in the
memory.
B. Whenever an object of a class is created, it
will have instance data and instance
member functions of that class.
C. Garbage collector destroyes the object
when it is no longer needed.
D. Objects are created on managed-heap of
memory.
See Answer & Explanation Lets Discuss
Correct answer is : A,B,C,D
How many constructors a C# class
can define?
A. Only one
B. Only two
C. Any number
D. None

See Answer & Explanation Lets Discuss


Correct answer is : C

Can the method DrawCircle() be overloaded in the following ways in C#?


public int DrawCircle(){.....}
public float DrawCircle(){.....}
A. Yes

B. No

See Answer & Explanation Lets Discuss


Correct answer is : B

The correct way of creating objects of a


class Hello is: (Choose all that apply)
A. Hello obj1 = new Hello();
B. Hello obj2; obj = new Hello();
C. Hello obj3;
D. Hello obj4 = Hello();
E. obj5 = new Hello();

See Answer & Explanation Lets Discuss


Correct answer is : A,B

What will be the output of following program?


using System;
namespace PlacementYogiConsoleApplication
{
class Hello
{
int a, b;
public void SetValue(int a, int b)
{
a = a;
b = b;
}
public void DisplayValue()
{
Console.WriteLine(a + " " + b);
}
}
class MyGreeting
{
static void Main(string[] args)
{
Hello obj = new Hello();
obj.SetValue(1, 2);
obj.DisplayValue();
}
}
}
A. 12
B. 12
C. 00
D. None
of the
abov
e
See Answer & Explanation Lets Discuss
Correct answer is : C

In C# "this" keyword is used to


resolve name-clash.
A. True
B. False

See Answer & Explanation Lets Discuss


Correct answer is : A
Consider a user-defined class "Hello". Select
the correct statement. (Choose all that apply)
A. All objects created on class Hello will always
have exactly same data.
B. Objects of Hello class may have same or
different data depending upon special
settings in Visual Studio.
C. Every object of class Hello will have instance
data and instance member functions of class
Hello.
D. All objects of class Hello will share one copy
of member functions.
See Answer & Explanation Lets Discuss
Correct answer is : C,D

Which of the following


statement is correct?
A. Object Oriented Programming paradigm stresses on
dividing the logic into smaller parts and writing procedures
for each part.
B. Classes and objects are building blocks of structured
programming paradigm.
C. Object Oriented Programming paradigm gives equal
importance to data and procedures that work on the data.
D. Procedural Programming paradigm is different than
structured programming paradigm.
E. C#.NET is a procedural programming language.

See Answer & Explanation Lets Discuss


Correct answer is : C

What are the pillars of


OOPS concept?
A. Abstraction,Inheritance, Encapsulation, Polymorphism
B. Atomicity, Inheritance, Encapsulation, Polymorphism
C. Abstraction, Inheritance, Polymorphism
D. None of the Above

See Answer & Explanation Lets Discuss


Correct answer is : A

Which of the following statement is correct


regarding access specifier? (Choose all that
apply)
A. Data members of a class are by default
private.
B. Data members of a class are by default
public.
C. Member functions of a class are by default
private.
D. Member function of a class are by default
public.
E. A private function of a class can access a
public function within the same class.
See Answer & Explanation Lets Discuss
Correct answer is : A,C,E

Which of the following statement is true


regarding "this" keyword (Choose all that
apply)
A. Static functions of a class never receive
"this" reference.
B. Instance member functions of a class always
receive "this" reference.
C. While calling an instance member function it
is not required to pass "this" reference
explicitly.
D. "this" reference continues to exist even after
control returns from an instance member
function.
See Answer & Explanation Lets Discuss
Correct answer is : A,B,C

Which of the following data types are


value types?
1. int, uint, float, doubl
2. short, ushort
3. string
4. long, ulong
5. byte, sbyte
6. object

A. 1, 2, 3, 4
B. 1, 2
C. 1, 2, 4, 5
D. 3, 6
E. 1, 2, 3

See Answer & Explanation Lets Discuss


Correct answer is : C

Which of the following data type does


not store a sign value?
A. int
B. float
C. single
D. long
E. byte

See Answer & Explanation Lets Discuss


Correct answer is : E

Which of the following statement is true


about data types in C#?
1. Size of byte and sbyte is same.
2. Size of short and ushort is same.
3. Size of int and uint is same.
4. Size of long and ulong is same.
5. Size of double and Decimal is same.

A. 1, 5
B. 2, 5
C. 3, 4, 5
D. 1, 2, 3, 4
E. 5

See Answer & Explanation Lets Discuss


Correct answer is : D
Explanation
Size of byte and sbyte: 1 byte
Size of short and ushort: 2 bytes
Size of int and uint: 4 bytes
Size of long and long: 8 bytes
Size of double: 8 bytes
Size of Decimal: 16 bytes

Which of the following statement is


correct? (Choose all that apply)
A. We can assign values of any type to variables of
type object.
B. When a value type is boxed, an entirely new object
must be allocated and constructed.
C. When a variable of a value type is converted to
object, it is said to be unboxed.
D. When a variable of type object is converted to a
value type, it is said to be boxed.
E. Boolean variable cannot be assigned a value
of null.
See Answer & Explanation Lets Discuss
Correct answer is : A,B
Which of the following statement is correct
about datatypes in C#? (Choose all that
apply)
A. Value types are always created on the heap.
B. Reference types are always created on the
stack.
C. Every reference type gets mapped to a type
in CTS (Common Type System ).
D. Mapping of every value type to a type in
Common Type System facilitates
Interoperability in C#.NET.
E. Every datatype is either a value type or a
reference type.
See Answer & Explanation Lets Discuss
Correct answer is : D,E

Which is the default value of


Boolean type in C#?
X A. True
B. 1

C. False
D. 0

See Answer & Explanation Lets Discuss


Correct answer is : C

Which one of the following options is not


Arithmetic Operators in C#?
A. +, -
B. *, /
C. ++, --, %
D. >=, <=

See Answer & Explanation Lets Discuss


Correct answer is : D
Which one of the following options is not
Relational Operators in C#?
A. &&, ||
B. ==, !=
C. <, >
D. <=, >=

See Answer & Explanation Lets Discuss


Correct answer is : A

Which one of the following is not a


Logical Operator in C#?
A. &&
B. ||
C. &
D. !

See Answer & Explanation Lets Discuss


Correct answer is : C

Which one of the following options is not


Bitwise Operators in C#?
A. &, |
B. ^, ~
C. <<, >>
D. +=, -=

See Answer & Explanation Lets Discuss


Correct answer is : D

Which one of the following options is not


Assignment Operators in C#?
A. =, +=, -=, *=, /=
B. ?:, is, as
C. %=, <<=, >>=
D. &=, ^=, |=

See Answer & Explanation Lets Discuss


Correct answer is : B

Which one of the following statements is


correct about arrays in C#?
A. Array elements can be declared as integer type
only.
B. The rank of an Array is the total number of
elements it can contain.
C. The length of an Array is the number of
dimensions in the Array.
D. The Array elements are always stored in
ascending or descending order.
E. The default value of numeric type array elements
is zero.
See Answer & Explanation Lets Discuss
Correct answer is : E

What would be the signature of a


method myfunc() that :-

1. has a double array as a formal


parameter.
2. returns an array of integers.

A. public void myfunc(double[] a)


B. public [] myfunc(double a)
C. public int myfunc(double a)
D. public int[] myfunc()
E. public int[] myfunc(double[] a)

See Answer & Explanation Lets Discuss


Correct answer is : E
Which of the following statements is correct about the array declaration given
below?
int[][][] myArray = new int[2][][];
A. myArray
refers to a
3-D
jagged
array
containing
2 2-D
jagged
arrays.
B. myArray
refers to a
3-D
jagged
array
containing
three 2-D
jagged
arrays.
C. myArray
refers to a
3-D
jagged
array
containing
2 2-D
rectangula
r arrays.
D. myArray
refers to a
2-D
jagged
array
containing
2 rows.
E. myArray
refers to a
2-D
jagged
array
containing
3 rows.

See Answer & Explanation Lets Discuss


Correct answer is : A

Which of the following statements is


correct about String in C#?
A. A String is created on the stack.
B. A String is created on the heap.
C. A String is a primitive type.
D. Keyword new is used to create a String.

See Answer & Explanation Lets Discuss


Correct answer is : B

Which of the following statement is


correct about String in C#?
A. Methods of the String class cannot be used to
operate the string.
B. A String is mutable because it can be modified once
it has been created.
C. A String has a zero-based index.
D. A numeric value cannot be represented in the form
of a String.
See Answer & Explanation Lets Discuss
Correct answer is : C

string in C# is a Reference
Type.
A. True
B. False

See Answer & Explanation Lets Discuss


Correct answer is : A
If s1 and s2 contain references to two different
strings then which of the following can be used to
compare values of s1 and s2? (Multiple Choice)
A. s1 == s2
B. s1.Equals(s2)
C. s1.CompareTo(s2)
D. strcmp(s1,s2)
E. All of the above

See Answer & Explanation Lets Discuss


Correct answer is : A,B,C

Inheritance is one of the pillar of Object-


Oriented-Programming (OOP).
A. True
B. False

See Answer & Explanation Lets Discuss


Correct answer is : A

Which of the following statements are true


regarding Inheritance? (Multiple Choice)
A. Derived class can access protected and public
members of base class.
B. Derived class can use the functionality of base
class.
C. Derived class can implement new functionality
other than base class.
D. Derived class functions can override functions
of base class.
See Answer & Explanation Lets Discuss
Correct answer is : A,B,C,D
Explanation

Which of the following statements are true


regarding inheritance in C#? (Multiple Choice)
A. Multiple level inheritance is allowed in C#.
B. Base class can access the members of its
derived class.
C. Multiple inheritance is allowed in C#.
D. A class can be derived from a base class
which is present in an assembly file.
See Answer & Explanation Lets Discuss
Correct answer is : A,D

Can infinite loop be achieved


using While loop?
A. True
B. False

See Answer & Explanation Lets Discuss


Correct answer is : A

Which of the following keyword can be used to


terminate the While loop in C#? (Multiple
Choice)
A. return
B. continue
C. break
D. goto

See Answer & Explanation Lets Discuss


Correct answer is : A,C,D

A structure variable declared in a C# program is


garbage collected when it is no longer in use.
A. True
B. False

See Answer & Explanation Lets Discuss


Correct answer is : B

Enumeration (enum) in c# is a
reference type.
A. True
B. False

See Answer & Explanation Lets Discuss


Correct answer is : B

Which of the following statements is correct


about enum in C#? (Multiple Choice)
A. The default value of first element of an enum
is 0.
B. If there is no access specifier, enum is treated
as public.
C. An enum can be declared inside a class, struct,
interface or namespace.
D. Values assigned to enum elements must
always begin with 0.
E. All of the above

See Answer & Explanation Lets Discuss


Correct answer is : A,B,C

enum in C#.NET does not allow float or double


values to be assigned to its elements.
A. True
B. False

See Answer & Explanation Lets Discuss


Correct answer is : A

Exceptions in C#.NET occurs


during
A. compilation
B. run-time
C. just-in-time compilation
D. linking

See Answer & Explanation Lets Discuss


Correct answer is : B

Which of the following options is a


C#.NET exception class? (Multiple
Choice)
A. ArithmeticException & ArrayTypeMismatchException
B. DivideByZeroException & IndexOutOfRangeException
C. InvalidCastException & NullReferenceException
D. OutOfMemoryException & OverflowException
E. All of the above

See Answer & Explanation Lets Discuss


Correct answer is : E

If we don't use a try/catch block to handle the


exception in C# program then which of the following
component is responsible to catch it?
A. Common Language Runtime (CLR)
B. Compiler
C. Linker
D. Loader

See Answer & Explanation Lets Discuss


Correct answer is : A

Which of the following statements is true about


exception handling in C#.NET? (Multiple Choice)
A. User-defined exceptions can be created in
C#.
B. Exception class can catch all types of
exceptions.
C. It is must to have a finally block for every
try block.
D. Multiple catch block cannot be used for a
single try block.
See Answer & Explanation Lets Discuss
Correct answer is : A,B

Exceptions is the Object-Oriented style of


handling run-time errors.
A. True
B. False

See Answer & Explanation Lets Discuss


Correct answer is : A

Which of the following statements is


correct about Interfaces in C#.NET?
A. Interfaces can be inherited by other classes.
B. Interfaces can contain static data and methods.
C. All interfaces are derived from Object class.
D. Interfaces can contain only method declarations.

See Answer & Explanation Lets Discuss


Correct answer is : A

Which of the following statements is correct


about an interface used in C#.NET?
A. A class cannot implement an interface
partially.
B. An interfaces can contain static data and
methods.
C. If a class implements an interface partially,
then it becomes an abstract class.
D. Multiple interface inheritance is not allowed.

See Answer & Explanation Lets Discuss


Correct answer is : C

1. What is "AutoPostBack"?
A: If any control needs automatic post back in case of any events then attribute
"AutoPostBack" of that control must be set to true. For example on a button click if
you want the event to go serer side immediately then set "AutoPostBack" attribute
of this button to true.
Lets Discuss
2. How can we ensure that the page is Post Back?
A: By using the property "IsPostBack" of page event, it can be ensured that a page is
post back or not.
Lets Discuss
3. What is the role of @Resister directives in ASP.NET?
A: @Resister directive informs the compiler about the custom server control added to
the page.
Lets Discuss
4. How can page specific attributes be set in ASP.NET?
A: Page specific attributes are set using @Page directive.
Lets Discuss
5. What is connectionStrings section in Web.config file in ASP.NET?
A: Web.config file is the most important file of any web project where project
configuration can be defined. The connectionStrings section is used to configure the
database connection for this project.
<configuration>
<connectionStrings>
<add name="ConnectionStringName"
connectionString="Server=server_name;
Port=xxxx; Database=database_name; Uid=user_id; Pwd=password" />
</connectionStrings>
</configuration>

//ConnectionStringName : Any name for this connection


//server_name : Name of the host server or IP address
//xxxx : Port number for the used database
//database_name : Name of the database created for this project
//user_id : user id to connect to this database
//password : Password to connect to this database
Lets Discuss
6. What is the order of events execution in APS.NET?
A: ASP.NET events occur in the following order:

1. Page_Init
2. Page_Load
3. Control Events
4. Page Unload Events

Page_Init event occurs only once when the page is loaded for the first time.
Lets Discuss
7. What is the significance of Global.asax file in ASP.NET project?
A: The Global.asax file also known as ASP.NET application file is used to respond
application level events such as application starting and ending events, session
starting and ending events, application error etc.It is not compulsory to define this
file in your project as it is optional.
Lets Discuss
8. Can a DropDownList be validated using RequiredFieldValidator?
A: Yes, this can be done by setting the IntialProperty of RequiredFieldValidator control.

1. How much Bytes are stored by Long Datatype in C# .net?

a) 8

b) 4

c) 2

d) 1

View Answer

Answer: a

Explanation : Long is the datatype keyword used for storing data of unlimited length so by definition
its size is always maximum i.e 8.

2. Choose .NET class name from which datatype UInt is derived of?

a) System.Int16
b) System.UInt32

c) System.UInt64

d) System.UInt16

View Answer

Answer: b

Explanation : By Defination class assigned to

a) System.Int16 = short.

b) System.UInt32 = UInt.

c) System.UInt64 = ULong.

d) System.UInt16 = UShort.

3. Correct Declaration of Values to variables a and b?

a) int a = 32, b = 40.6;

b) int a = 42; b = 40;

c) int a = 32; int b = 40;

d) int a = b = 42;

View Answer

Answer: c

Explanation : a) Although,deceleration of b and a are correct but initialization of value to b should be


int datatype not float.

b) Missing deceleration type of b.

c) correctly declared datatypes a and b.

d) b cant be assigned values before declaration.

4. Select error in a given program :


Static Void Main(String[] args)

const int m = 100;

int n = 10;

const int k = n / 5 * 100 * n ;

Console.WriteLine(m * k);

Console.ReadLine();

a) k should not be declared constant

b) Expression assigned to k should be constant in nature

c) Expression (m * k) is invalid

d) m is declared in invalid format

View Answer

Answer : b

Explanation :k should be declared as const int k = 10/5 * 100*10 i.e only constant values should be
assigned to a constant.

Output :Error 1 The expression being assigned to k must be constant.

5. Arrange following datatype in order of increasing magnitude sbyte, short, long, int.

a) long < short < int < sbyte

b) sbyte < short < int < long

c) short < sbyte < int < long

d) short < int < sbyte < long

View Answer

Answer : b
Explanation : By definition.

6. Which datatype should be more preferred for storing a simple number like 35 to improve execution
speed of a program?

a) sbyte

b) short

c) int

d) long

View Answer

Answer: a

Explanation : Wider datatype like int,long takes more time for manipulation of a program.

7. Which Conversion function of Convert.TOInt32() and Int32.Parse() is efficient?

1) Int32.Parse() only used for strings and throws arguement exception for null string

2) Convert.Int32() used for datatypes and returns directly 0 for null string

a) 2

b) Both 1,2

c) 1

d) None of the mentioned

View Answer

Answer: a

Explanation: Convenient for every datatype so mostly preferred.

8. Correct way to assign values to variable c when int a=12, float b=3.5,int c;

a) c = a + b;

b) c = a + int(float(b));

c) c = a + convert.ToInt32(b);
d) c = int(a + b);

View Answer

Answer: c

Explanation:None.

9. Correct Set of Code for given data a and b to print output for c as 74 ?

a)

int a = 12;

float b = 6.2f;

int c;

c = a / b + a * b;

Console.WriteLine(c);

b)

int a = 12;

float b = 6.2f;

int c;

c = a / convert.ToInt32(b) + a * b;

Console.WriteLine(c);

c)

int a = 12;

float b = 6.2f;

int c;
c = a / convert.ToInt32(b) + a * convert.ToInt32(b);

Console.WriteLine(c);

d)

int a = 12;

float b = 6.2f;

int c;

c = convert.ToInt32(a / b + a * b);

Console.WriteLine(c);

View Answer

Answer: c

Explanation:Usage of typecasting operation.Seperately check each expression taking typecast


operations in concern.

Output : 74.

10) Is output remain same or different for both cases?

1)

char l ='k';

float b = 19.0f;

int c;

c = (l / convert.ToInt32(b));

Console.Writeline(c);

2)

char l ='k';

float b = 19.0f;
int c;

c = Convert.ToInt32(l / b);

console.writeline(c);

a) Yes

b) No

View Answer

Answer : No

Output 1) 5.

2) 6.

11. Default Type of number without decimal is ?

a) Long Int

b) Unsigned Long

c) Int

d) Unsigned Int

View Answer

Answer : c

Explanation:By definition.

12. Correct output for code is?

static void Main(string[] args)

float a = 10.553f;

long b = 12L;
int c;

c = Convert.ToInt32(a + b);

Console.WriteLine(c);

a) 23.453

b) 22

c) 23

d) 22.453

View Answer

Answer : c

Explanation:The two datatype float and long after arithmetic operation completely converted to
nearest whole number 23.

Output : 23.

1. Select a convenient deceleration and initializing of a floating point number:

a) float somevariable = 12.502D

b) float somevariable = (Double) 12.502D

c) float somevariable = (float) 12.502D

d) float somevariable = (Decimal)12.502D

View Answer

Answer: c

Explanation : We cannot implicitly convert a double number directly to any other datatype.Here, its
float we have to add the required

datatype to number as :
float somevariable = (float)12.502D;

or

Double somevariable = (Double)12.502D;

2. Number of digits upto which precision value of float datatype is valid ?

a) Upto 6 digit

b) Upto 8 digit

c) Upto 9 digit

d) Upto 7 digit

View Answer

Answer: d

Explanation : By definition.

3. Valid Size of float datatype is ?

a) 10 Bytes

b) 6 Bytes

c) 4 Bytes

d) 8 Bytes

View Answer

Answer: c

Explanation : By definition.

4. Correct way to define a value 6.28 in a variable a where value cannot be modified ?

a) #define a 6.28F

b) pi = 6.28F

c) const float pi = 6.28F


d) const float pi

pi = 6.28F

View Answer

Answer: c

Explanation : Const is a reserve keyword whenever they are declared with any variables.The value
stored in that variable always remain

fixed.Any modification done to change value of that variable results in error.Hence, options a, b and e
are rejected because value is not

declared fixed.Now, for value c and d only option c is correct because for value d while declaring a
constant variable we need to

provide a constant value too as provided in c. So, option c is correct way of deceleration of constant
variable.

5. Select correct set of code to display value of given variable c as 25.302.

a) float a = (double) 12.502f;

float b = 12.80f;

float c;

c = (float) a + b;

Console.Writeline(c);

Console.ReadLine();

b) float a = 12.502D;

float b = 12.80f;

float c;

c = a + b;
Console.WriteLine(c);

Console.ReadLine();

c) double a = 12.502;

float b = 12.802f;

float c;

c = (float)a + b;

Console.WriteLine(c);

Console.ReadLine();

d) double a = (float) 12.502f;

float b = 12.80f;

float c;

c = a + b;

Console.WriteLine(c);

Console.ReadLine();

View Answer

Answer: c

Explanation : Expression c = (float) a + b.

6. Minimum and Maximum range of values supported by float data type are ?

a) 1.5 * 10 ^-40 to 3.4 * 10 ^38

b) 1.5 * 10 ^-45 to 3.4 * 10 ^30

c) 1.5 * 10 ^-45 to 3.4 * 10 ^38

d) 1.5 * 10 ^-45 to 3.4 * 10 ^37

View Answer

Answer: c
Explanation : By Definition.

7. Select appropriate difference between decimal, float and double data type in C# ?

1) Float and Double are floating binary point types while decimal is a floating decimal point type.

2) Precision difference for float is 7 digit for double is 15 to 16 digit and for decimal is 28 to 29
digits.

3) Some values which cannot be exactly represented hence for those values float and double are more
appropriate.

a) 1

b) 1, 3

c) 1, 2, 3

d) 2, 3

View Answer

Answer: C

Explanation : By Definition.

8. Why does a float variable stop increments at number 16777216 in given code in C#?

float a = 0 ;

while (true)

a++;

if (a > 16777216)

break;

a) Sign and Exponent for 16777217 is same as for 16777216

b) Mantisaa is different for 16777216 and 16777217


c) Sign and Exponent for 16777217 is different as for 16777216

d) None of the mentioned

View Answer

Answer: b

Explanation : 16777216 is exactly 224, and would be represented as 32-bit float like so:

sign = 0 (positive number)

exponent = 24 (stored as 24 + 127 = 151 = 10010111)

mantissa = . 0

As 32 bits floating-point representation: 0 10010111 00000000000000000000000

Therefore: Value = (+ 1) * 2 ^ 24 * (1. 0 + . 0) = 2 ^ 24 = 16777216

Now lets look at the number 16777217, or exactly 224 + 1:

sign and exponent are the same.

Mantissa should have to be exactly 2-24 so that (+ 1) * 2 ^ 24 * (1. 0 + 2 ^-24) = 2 ^ 24 + 1 = 16777217


and here lies the actual problem .

The mantissa cannot have the value 2-24 because it only has 23 bits, so the number 16777217 just
cannot be represented with the accuracy of

32-bit floating points numbers.

9. Select output of following set of code ?

static void Main(string[] args)

int x = 1;

float y = 2. 4f;

short z = 1;
Console. WriteLine((float) x + y * z - (x + = (short) y) );

Console. ReadLine();

a) 0.4000004

b) 0.4000023

c) 0.0400021

d) 0.4000001

View Answer

Answer: d

Explanation : None.

Output : 0.4000001

10. A float occupies 4 bytes. If the hexadecimal equivalent of these 4 bytes are A, B, C and D, then when
this float is stored in memory in

which of the following order do these bytes gets stored ?

a) ABCD

b) DCBA

c) 0 * ABCD

d) Depends on big endian or little endian architecture

View Answer

Answer: d

Explanation : Little Endian means that the lower-order byte of the number is stored in memory at the
lowest address, and the high order

byte at the highest address. For example, a 4 byte Integer


ABCD will be arranged in memory as follows:

Base Address + 0 Byte 0 .

Base Address + 1 Byte 1 .

Base Address + 2 Byte 2 .

Base Address + 3 Byte 3 .

Intel processors (those used in PCs) use Little Endian byte order.

Big Endian means that the high-order byte of the number is stored in memory at the lowest address,
and the low-order byte at the highest

address. The same 4 byte integer would be stored as:

Base Address + 0 Byte 3 .

Base Address + 1 Byte 2 .

Base Address + 2 Byte 1 .

Base Address + 3 Byte 0 .

11. The Default value of Boolean DataType is ?

a) 0

b) True

c) False

d) 1

e) -1

View Answer

Answer: c

Explanation : By Definition.

12. Select the output choice for following set of code:


public static void Main(string[] args)

double ZERO = 0;

Console.WriteLine("RESULT OF DIVISION BY ZERO IS :{0}", (0 / ZERO));

Console.ReadLine();

a. None of the mentioned

b. exception arguement is thrown

c. NaN

d. 0.

View Answer

Answer: c

Explanation : None.

13. Which of the following format specifier used to print hexadecimal values and return value of output
as Octal equivalent in C# ?

a) %hx for small case letters and %HX for capital letters

b) %x for small case letters and %X for capital letters

c) No easy of doing it. C# dont provides specifier like %x or %O to be used with ReadLine() OR
WriteLine().We have to write our

own function

d) %Ox for smallcase letters and %OX for capital letters

View Answer

Answer: c

Explanation : Explained in answer itself.


1. What is Size of Char datatype?

a) 8 bit

b) 12 bit

c) 16 bit

d) 20 bit

View Answer

Answer: c

Explanation: None.

2. Choose an output for following set of code.

static void Main(string[] args)

char c = 'g';

string s = c.ToString();

string s1 = "I am a human bein" + c;

Console.WriteLine(s1);

Console.ReadLine();

a) I am a human bein c

b) I am a human being

c) I am a human being c

d) I am a human bein
View Answer

Answer: b

Explanation : gstored in character variable c which later on converted to string using method
Convert.Tostring() and hence appended at

last of the string in s1.

Output: I am a human being.

3. Given is code of days(example:MTWTFSS) which i need to split and hence create a list of days of
week in strings

(example:Monday,Tuesday,Wednesday,Thursday,Friday,Saturday,Sunday). A set of code


is given for this purpose but there is error

ocuring in that set of code related to conversion of char to strings.Hence,Select a code to solve the given
error.

static void Main(string[] args)

var days = "MTWTFSS";

var daysArray = days.ToCharArray().Cast<string>().ToArray();

for (var i = 0; i < daysArray.Length; i++)

switch (daysArray[i])

case "M":

daysArray[i] = "Monday";

break;
case "T":

daysArray[i] = "Tuesday";

break;

case "W":

daysArray[i] = "Wednesday";

break;

case "R":

daysArray[i] = "Thursday";

break;

case "F":

daysArray[i] = "Friday";

break;

case "S":

daysArray[i] = "Saturday";

break;

case "U":

daysArray[i] = "Sunday";

break;

daysArray[daysArray.Length - 1] = "and " + daysArray[daysArray.Length - 1];

Console.WriteLine(string.Join(", ", daysArray));

a) var daysArray = new List();

b) var daysArray = days.Select(c =>dayMapping[c]).ToArray();


c) var daysArray = days.ToCharArray().Select(c =>c.Tostring()).ToArray();

d) None of above mentioned.

View Answer

Answer: c.

Explanation : The problem arises due to cast conversion from char to string as one is not inherited
from other. So, quick way of

conversion is just using Char.ToString().

4. Output for following set of code ?

static void Main(string[] args)

var dayCode = "MTWFS";

var daysArray = new List<string>();

var list = new Dictionary<string, string>

{ {"M", "Monday"}, {"T", "Tuesday"}, {"W", "Wednesday"},

{"R", "Thursday"}, {"F", "Friday"}, {"S", "Saturday"},

{"U", "Sunday"}

};

for (int i = 0,max = dayCode.Length; i < max; i++)

var tmp = dayCode[i].ToString();

if (list.ContainsKey(tmp))

{
daysArray.Add(list[tmp]);

Console.WriteLine(string.Join("\n ", daysArray));

a) Monday ,Tuesday ,Wednesday ,Friday ,Saturday ,Sunday

b) Monday

Tuesday

Wednesday

Friday

Sunday

c) Monday

Tuesday

Wednesday

Friday

Saturday

d) Monday ,Tuesday ,Wednesday ,Friday ,Saturday

View Answer

Answer: c.

Explanation:None.

Output: Monday

Tuesday

Wednesday

Friday
Saturday

5. Select correct difference between char and var char datatypes?

1. varchar is non unicode and char is unicode character datatype

2. char is n bytes whereas varchar is actual length in bytes of data entered in terms of storage size

3. varchar is variable length and char is fixed length strings

4. For varchar use if a string is less than maximum length.So,its stored in verbatim without any extra
characters while for char if a

string is less than set length hence its padded with extra characters to equalize its length to given
length

a) 1, 3, 4

b) 2, 3, 4

c) 1, 2, 4

d) 3, 4

View Answer

Answer: d.

Explanation :By definition.

6. String method used to compare two strings with each other ?

a) Compare To()

b) Compare()

c) Copy()

d) ConCat()

View Answer

Answer: b

Explanation :Compare() used to compare two strings by taking length of strings in considerations.
7. Correct output for given C#.NET code is ?

static void Main(string[] args)

string s1 = "Delhi";

string s2;

s2 = s1.Insert (6, "Jaipur");

Console.WriteLine(s2);

a) DelhJaipuri

b) Delhi Jaipur

c) Delhi

d) DelhiJaipur

View Answer

Answer: d.

Explanation:Insert method() of string class used to join two strings s1 and s2.

Output : DelhiJaipur

8. For two strings s1 and s2 equal which is correct way to find contents of two string equal ?

a) if(s1 = s2)

b) int c;

c = s1.CompareTo(s2);

c) if (s1 is s2).

d) if(strcmp(s1, s2))

View Answer
Answer : b

9. Select output for given string ?

static void Main(string[] args)

string Str, Revstr = " ";

int Length;

Console.Write("Enter A String : ");

Str = Console.ReadLine();

Length = Str.Length - 1;

while (Length >= 0)

Revstr = Revstr + Str[Length];

Length --;

Console.WriteLine("Reverse String Is {0}", Revstr);

Console.ReadLine();

Enter a String:BOMBAY.

a) BOMBA

b) YABMOB

c) BOMAYB

d) YABMO

View Answer
Answer : b.

Explanation : Explain the concept of reveresal of string without using any string inbuilt method but using
while loop conditions.

Output:YABMOB

10. Select appropriate set of code for conversion of string to hexa form.

static void Main(string[] args)

string teststring = "MIKA@?&";

string hex = ConvertstringToHex(teststring, system.Text.Encoding.Unicode);

Console.WriteLine(hex);

a)

static string ConvertstringToHex(string input, system.Text.Encoding encoding)

string Bytes = encoding.GetBytes(input);

string Builder sbBytes = new Builder sbBytes();

for each (byte 'b' in StringBytes)

sBytes.AppendFormat("{0:x2}", b);

return sbBytes.Tostring();

b)
static string ConvertstringToHex(string input, system.Text.Encoding encoding)

char[]string Bytes = encoding.GetBytes(input);

string Builder sbBytes = new Builder sbBytes(StringBytes.Length*2);

for each (byte 'b' in StringBytes)

sBytes.AppendFormat("{0:X2}", b);

return sbBytes.Tostring();

c)

public static string ConvertStringToHex(String input, System.Text.Encoding encoding)

Byte[] stringBytes = encoding.GetBytes(input);

StringBuilder sbBytes = new StringBuilder(stringBytes.Length * 2);

foreach (byte b in stringBytes)

sbBytes.AppendFormat("{0:X2}", b);

Console.WriteLine(sbBytes.ToString());//sbBytes.ToString());

return sbBytes.ToString();

}
}

d) None of the mentioned.

View Answer

Answer : c.

Explanation: None.

Output:public static string ConvertStringToHex (String input, System.Text.Encoding encoding)

Byte[] stringBytes = encoding.GetBytes(input);

StringBuilder sbBytes = new StringBuilder(stringBytes.Length * 2);

foreach (byte b in stringBytes)

sbBytes.AppendFormat({0:X2}, b);

Console.WriteLine(sbBytes.ToString());//sbBytes.ToString());

return sbBytes.ToString();

11. Which of the following code is used for conversion of hex to string form ?

static void Main(string[] args)

string testString = "MIKA@?&^";

string normal = ConvertHexToString (hex, System.Text.Encoding.Unicode);

Console.WriteLine(normal);
Console.ReadLine();

a)

public static string ConvertHexToString(String hexInput, System.Text.Encoding encoding)

char[] numberChars = hexInput.Length;

byte[] bytes = new byte[numberChars / 2];

for (int i = 0; i < numberChars; i += 2)

bytes[i / 2] = Convert.ToByte(hexInput.Substring(i, 0), 16);

return encoding.GetString(bytes);

b)

public static string ConvertHexToString(String hexInput, System.Text.Encoding encoding)

int numberChars = hexInput.Length;

byte[] bytes = new byte[numberChars / 2];

for (int i = 0; i < numberChars; i += 2)

bytes[i / 2] = Convert.ToByte(hexInput.Substring(i, 2), 16);

return encoding.GetString(bytes);
}

c)

public static string ConvertHexToString(String hexInput, System.Text.Encoding encoding)

string numberChars = hexInput.Length;

byte[] bytes = new byte[numberChars];

for (int i = 0; i < numberChars; i += 2)

bytes[i / 2] = Convert.ToByte(hexInput.Substring(i, 2), 16);

return encoding.GetString(bytes);

d) None of the mentioned.

View Answer

Answer : b

Output:

public static string ConvertHexToString(String hexInput, System.Text.Encoding encoding)

int numberChars = hexInput.Length;

byte[] bytes = new byte[numberChars / 2];

for (int i = 0; i < numberChars; i += 2)

bytes[i / 2] = Convert.ToByte(hexInput.Substring(i, 2), 16);


}

return encoding.GetString(bytes);

12. Correct Output for C#.NET code given below is :

string s1 = " I AM BEST ";

string s2;

s2 = s1.substring (5, 4);

Console.WriteLine (s2);

a) AM BEST

b) I AM BES

c) BEST

d) I AM

View Answer

Answer : c

Explanation:Substring() of string class used to extract substrings from given string.In, given substring
condition, it extracts a substring

beginning at 5th position and ending at 4th position.

Output: BEST.

13. Correct statement about strings are ?

a) a string created on stack

b) a string is primitive in nature

c) string created on heap

d) Either string created on stack or on a heap depends on length of string


View Answer

Answer : c

Explanation: None.

14. Verbatim string literal is better used for ?

a) Convenience and better readability of strings when string text consist of backlash characters

b) Used to intialize multiline strings

c) To embedd a quotation mark by using double quotation marks inside a verbatim string

d) All of the mentioned

View Answer

Answer : d

Explanation : By definition.

15. Why string made reference type in C#.NET ?

a) To create string on stack

b) To reduce size of string

c) To overcome problem of stackoverflow

d) None of the mentioned

View Answer

Answer : b

Explanation :The problem of stack overflow very likely to occur since transport protocol used on web
these days are HTTP and data standard

as XML.Hence, both make use of strings extensively which will result in stack overflow problem.So, to
avoid this situation it is good idea
to make strings a reference type and hence create it on heap

1. Select output for following set of code.

static void Main(string[] args)

int a = 5;

int b = 10;

int c;

Console.WriteLine(c = ++ a + b ++);

Console.WriteLine(b);

Console.ReadLine();

a) 11, 10

b) 16, 10

c) 16, 11

d) 15, 11

View Answer

Answer: c

Explanation : c = 6 + 10 = 16 and b =11 as we know ++operator increments and then executes similarly
operator++ executes and then

increments.

Output:16,11

2. Storage location used by computer memory to store data for usage by an application is ?
a) Pointers

b) Constants

c) Variable

d) None of the mentioned

View Answer

Answer: c

Explanation : Variables are essential locations in memory of computer that are reserved for storing
data used by an application. Each

variable is given a name by programmer and hence assigned a value .The name assigned to variable then
used in C# code to access value

assigned to variable.

3. DIFFERENCE BETWEEN KEYWORDS VAR AND DYNAMIC ?

a) Var introduced in C# (3.0) and Dynamic introduced in C# (4.0)

b) Var is a type of variables where deceleration done at compile time by compiler while Dynamic
deceleration is achieved at runtime by

compiler

c) For Var Error caught at compile time and for Dynamic Error caught at runtime

d) For Var datatype the code as : var obj1 = 1; and var obj1=I am a string will also compile safely.For
Dynamic datatype the code as:

dynamic obj1 =1; and dynamic obj1 = I am a string will create an error

View Answer

Answer: a, b, c

4) Are the given codes :


1. Myclass class;

Myclass class2 = null;

2. int i;

int j = 0;

a) True for (1);False for (2)

b) True for (2);False for (1)

c) Both (1) and (2) are equivalents

d) Both (1) and (2) are not equivalents

View Answer

Answer: c.

Explanation : When we create a type in C#, It automatically get filled with padded zeroes. For the case
of class (reference types) this

equates to a null pointer. Hence, for code 1) Both variable values are equivalent to each other.Similarly,
for code 2) i.e for value type

(including int/float/double etc.), the type is passed with zeroes.Hence, they are equivalent.

5. What is the output to following set of code ?

int a,b;

a = (b = 10) + 5;

a) b = 10, a = 5

b) b = 15, a = 5

c) a = 15, b = 15

d) a = 10, b = 10
View Answer

Answer: c

Explanation: a = b = 15.

6. What will be output for following conversion ?

static void Main(string[] args)

char a = 'A';

string b = "a";

Console.WriteLine(Convert.ToInt32(a));

Console.WriteLine(Convert.ToInt32(Convert.Tochar(b)));

Console.ReadLine();

a) 1, 97

b) 65, 97

c) 65, 97

d) 97, 1

View Answer

Answer: c

Explanation : ASCII value of character a is 65 and ASCII value of string a is 97.

Output: 65,97

7. Select output of given set of Code :


static void Main(string[] args)

String name = "Dr.Gupta";

Console.WriteLine("Good Morning" + name);

a) Dr.Gupta

b) Good Morning

c) Good Morning Dr.Gupta

d) Good Morning name

View Answer

Answer: c.

Explanation:How to intialize a string variable and concatenate string using + operator.

Output:Good Morning Dr.Gupta.

8. Select output for following set of code.

static void Main(string[] args)

int a = 5;

int b = 10;

int c;

Console.WriteLine(c = a-- - ++b);

Console.WriteLine(b);

Console.ReadLine();

}
a) -7, 10

b) -5, 11

c) -6, 11

d) 15, 11

View Answer

Answer: c

Explanation:None.

Output: -6,11.

9. Select output for following set of code .

static void Main(string[] args)

const int a = 5;

const int b = 6;

for (int i = 1; i <= 5; i++)

a = a * i;

b = b * i;

Console.WriteLine(a);

Console.WriteLine(b);

Console.ReadLine();

a) 600, 720
b) Compile time error.

c) 25, 30

d) 5, 6

View Answer

Answer: b

Explanation:The left hand side of an assignment must be a variable,property or indexer i.e for both a
and b

10. Select output for following set of code.

static void Main(string[] args)

string Name = "He is playing in a ground.";

char[] characters = Name.ToCharArray();

StringBuilder sb = new StringBuilder();

for (int i = Name.Length - 1; i >= 0; --i)

sb.Append(characters[i]);

Console.Write(sb.ToString());

Console.ReadLine();

a) He is playing in a grou

b) .ground a in playing is He

c) .dnuorg a ni gniyalp si eH

d) He playing a
View Answer

Answer: c

Explanation:Reversal of array of strings character by character.

Output: .dnuorg a ni gniyalp si eH

1. Choose correct type of variable scope for given defined variables.

class ABC

static int m;

int n;

void fun (int x , ref int y, out int z, int[] a)

int j = 10;

Scope declaration:

a) m = static variable, n = local variable, x = output parameter, y = reference parameter, j = instance


variable, z =output parameter, a[0]=

array element

b) m = static variable, n = instance variable, x = value parameter, y = reference parameter, j = local


variable, z =output parameter , a[0]

= array element

c) m = static variable, n = instance variable, x = reference parameter, y = value parameter, j = local


variable, z =output parameter, a[0] =
array element

d) m = local variable, n = instance variable, x = reference parameter, y = value parameter, j = static


variable, z =output parameter, a[0] =

array element

View Answer

Answer: b

Explanation:By definition of scope of variables.

2. Correct Output for given set of programming code is :

class Program

static void Main(string[] args)

int i ;

for (i = 0; i < 5; i++)

Console.WriteLine(i);

Console.ReadLine();

a) 0, 1, 2, 3, 4, 5

b) 0, 1, 2, 3

c) 0, 1, 2, 3, 4
d) 0, 0, 0, 0, 0

View Answer

Answer: c

Explanation: Scope of i is alive within block in which it is declared. So, change in value of i within for
loop is reserved until

condition of for loop is executing.

Output:0, 1, 2, 3, 4

3. Correct Output for given set of programming code is :

class Program

static void Main(string[] args)

int i;

for ( i = 0; i < 5; i++)

Console. WriteLine(i);

Console. ReadLine();

a) 0, 1, 2, 3, 4, 5

b) 0, 1, 2, 3, 4
c) 5

d) 4

View Answer

Answer: c

Explanation:Since final console statement is outside forloop. So, result will be printed in final values
only.

Output: 5

4. Correct Output for given set of programming code is :

class Program

static void Main(string[] args)

int i ;

for ( i = 0; i < 5; i++)

int j = 0;

j += i;

Console. WriteLine(j);

Console. WriteLine(i);

Console. ReadLine();

a) 0, 1, 2, 3, 4, 5, 6
b) 0, 1, 2, 3, 4, 5

c) 0, 1, 2, 3, 4

d) 0, 1, 2, 3

View Answer

Answer: b

Explanation: None.

Output:0, 1, 2, 3, 4, 5

5. Correct Output for given set of programming code is :

static void Main(string[] args)

int i ;

for (i = 0; i < 5; i++)

int j = 0;

j += i;

Console. WriteLine(j);

Console. WriteLine( i * j);

Console. ReadLine();

a) 0, 1, 6, 18, 40

b) 0, 1, 5, 20, 30

c) Compile time error


d) 0, 1, 2, 3, 4, 5

View Answer

Answer: c

Explanation:The scope of j is local in nature it cannot be extended outside the block in which it is
defined.

6. Scope of variable is related in definition of variable as:

1. Region of code within which variable value is valid and hence can be accessed.

2. No, relation with region where variable is declared its value is valid in entire scope.

a) a

b) b

c) a, b

d) None of the mentioned

View Answer

Answer: a

Explanation: Scope of variable is the area or region within which variable is declared and hence intialized
values of different kind. Based,

on which operations of diffrent kinds are carried out on that variable declared within that scope. Its
value is preserved until and unless

scope of that block ({ })is not expired because as soon as scope gets over hence, variable value gets
expired. Hence, its inaccessible

after it.

7. Select output for following code of statement


class Program

public static void Main(string[] args)

int i = 100;

for (a = 0; a < 5; a++)

int i = 200;

Console. WriteLine(a * i);

Console. ReadLine();

a) 5, 10, 15, 20

b) 0, 5, 10, 20

c) Compile time error

d) 0, 1, 2, 3, 4

View Answer

Answer: c

Explanation: The compiler cannot interpret ate between variable i declared as an instance variable
outside for loop block and variable i

declared as a local variable inside the for loop context. The instance variable id defined before the for
loop is still in scope inside
for loop and hence goes out of scope only when main() is finished executing. The local variable i
declared inside for loop had scope

limited within blocks({ }) in which it is declared and hence create name conflict with instance variable i
so, compiler unable to

distinguish between both. When instance variable i is removed away. The program runs accurately
producing the output as 0, 200, 400, 600,

800, this explains the concept of scope deceleration.

8. Syntax for declaration and initialization of data variable is :

a) <data type><var_name> = <Value>;

b) <datatype><var_name>;

c) <var_name><data type>;

d) <var_name> = <value>;

View Answer

Answer: a

Explanation: By definition.

9. Select correct output for following set of code :

class Program

public static void Main(string[] args)

int i, j;

i = (j = 5) + 10;

Console. WriteLine(i);
Console. WriteLine(j);

Console. ReadLine();

a) 15, 15

b) 10, 5

c) 15, 5

d) 10, 15

View Answer

Answer: c

Explanation : j=5 will return value of 5 stored it in variable j but value assigned to variable i will be
first value of j and hence

incremented a value of 10 in that value of j i. e 15.

Output:15, 5

10. Choose effective differences between Boxing and Unboxing.

a) Boxing is the process of converting a value type to the reference type and Unboxing is the process
of converting reference to value

type

b) Boxing is the process of converting a reference type to value type and Unboxing is the process of
converting value type to reference

type

c) In Boxing we need explicit conversion and in Unboxing we need implicit conversion

d) Both Boxing and Unboxing we need implicit conversion

View Answer
Answer: a

Explanation:By definition

11. Select difference between reference type and value type is :

1. Memory allocated to Value type is from heap and reference type is from System. ValueType

2. Memory allocated to Value type is from System. ValueType and reference type is from Heap

3. Structures, enumerated types derived from System. ValueType are created on stack, hence known as
ValueType and all classes are

reference type because values are stored on heap

a) 1, 3

b) 2, 3

c) 1, 2, 3

d) 1

View Answer

Answer: b

Explanation:By definition.

12. Correct output for following set of code is :

public static void Main(string[] args)

int i = 123;

object o = i;

i = 456;

System. Console. WriteLine("The value-type value = {0}", i);


System. Console. WriteLine("The object-type value = {0}", o);

Console. ReadLine();

a) 123, 123

b) 456, 123

c) 456, 456

d) 123, 456

View Answer

Answer: b.

Explanation :The concept of boxing is implemented here. The variable i of int type is boxed using
variable o of object type and hence

value stored inside it is initialized to the object variable o. In Next, variable i is again initialized with
some value overriding its

previous stored value.

Output:456, 123

13) Correct output for following set of code is :

public static void Main(string[] args)

int i = 546;

object o = i;

int n =(int) o;

o = 70;

System. Console. WriteLine("The value-type value = {0}", n);


System. Console. WriteLine("The object-type value = {0}", o);

Console. ReadLine();

a) 546, 0

b) 546, 546

c) 546, 70

d) 70, 546

View Answer

Answer: c

Explanation : The concept of unboxing is implemented here . To unbox an object back to value type,
we should have to do it explicitly as

int n = (int) o.

Output:546, 70

1. What is need of Conversion of data type in C#?

a) To store a value of one data type into a variable of another data type

b) To get desired data

c) To prevent situations of run time error during change or conversion of data type

d) None of the mentioned

View Answer

Answer: c

Explanation : By Definition.

2. Types of Data Conversion in C#?


a) Implicit Conversion

b) Explicit Conversion

c) Implicit Conversion and Explicit Conversion

d) None of the mentioned

View Answer

Answer: b

Explanation : By Definition.

3.Implicit Conversion follows the order of conversion as per compatibility of datatype as :

a) float > char > int

b) char > int > float

c) int > char > float

d) float > int > char

View Answer

Answer: b

Explanation : None.

4. For given set of code select relevant solution for conversion of data type.

static void Main(string[] args)

int num1 = 20000;

int num2 = 50000;

long total;

total = num1 + num2;


Console.WriteLine("Total is : " +total);

Console.ReadLine();

a) Compiler will generate runtime error

b) Conversion is implicit type no error generation

c) Specifying datatype for conversion externally will solve the problem

d) None of the mentioned

View Answer

Answer: b

Explanation: Since,conversion of datatype is implicit type as int is a subset of longtype hence no need
to explicitly convert data from

one type to another.Compiler will automatically do conversion.

Output : Total is : 70000.

5. Subset of int datatype is :

a) long ,ulong, ushort

b) long, ulong, uint

c) long, float, double

d) long, float, ushort

View Answer

Answer: c

Explanation: By definition.

6. Type of Conversion in which compiler is unable to convert the datatype implicitly is ?

a) ushort to long
b) int to uint

c) ushort to long

d) byte to decimal

View Answer

Answer:b

Explanation: int is 32 bit signed integer whereas uint is 32 bit unsigned integer .Range of int is larger
than uint.So,compiler cannot

implicitly convert from larger datatype to smaller datatype.

7. Explicit Conversion disadvantages are ?

a) Makes program memory heavier

b) Results in loss of data

c) Potentially Unsafe

d) None of the mentioned

View Answer

Answer: b, c

Explanation:By definition.

8. For given set of code is conversion possible?

static void Main(string[] args)

int a = 76;

char b;

b = (char)a;
Console.WriteLine(b);

Console.ReadLine();

a) Compiler will generate runtime error

b) Conversion is explicit type

c) Compiler will urge for conversion from integer to character datatype

d) None of the mentioned

View Answer

Answer: b

Explanation:Since, given conversion is of explicit type as one datatype is in integer and other is in
char.Compiler needed to make clear

distinction between both type of datatype and hence,explicitly one need to specify datatype as compiler
unable to make automatic conversion.

Output : L.

9. For given set of code,predict the relevant output.

static void Main(string[] args)

float sum;

int i;

sum = 0.0F;

for (i = 1; i <= 10; i++)

sum = sum + 1 /(float)i;

}
Console.WriteLine("sum =" +sum);

Console.ReadLine();

a) 2.000

b) 2.910

c) 2.928

d) 3.000

View Answer

Answer: c

Explanation:None.

Output : sum = 2.928698.

10) Which conversions in given program are invalid?

static void Main(string[] args)

int a = 22;

long b = 44;

double c = 1.406;

b = a;

c = a;

a = b;

b = c;

a) c = a, b = c
b) a = b, b = a

c) b = a, c = a

d) All of the mentioned

View Answer

Answer: a ,b

Explanation:Conversion of data type from int to double is implicit in nature for c = a as int is subset
of double but same do not

applicable for b = c as c had wider scope of data range then b so explicit conversion is needed. Same
explanation for option b.

Output :

Error 1 :Cannot implicitly convert type long to int. An explicit conversion exists (are you missing a
cast?).

Error 2 :Cannot implicitly convert type double to long. An explicit conversion exists (are you missing a
cast?).

Correct solution :

static void Main(string[] args)

int a = 22;

long b = 44;

double c = 1.406;

b = a;

c = a;

a = (int)b;

b = (long)c;
}

1. Predict the output for following set of code.

static void Main(string[] args)

float a = 16.4f;

int b = 12;

float c;

c = a * ( b + a) / (a - b) ;

Console.WriteLine("result is :" +c);

Console.ReadLine();

a) 106

b) 104.789

c) 105.8546

d) 103.45

View Answer

Answer: c

Explanation :The first expression evaluated is b+a as both are combined next the expression is
multiplied by operand a i.e a (b+a) the

whole result of numerator is combinedly divided by denominator expression (a b).

Output: result is : 105.8546.


2. Predict the solution for following set of code.

static void Main(string[] args)

int a, b, c, x;

a = 90;

b = 15;

c = 3;

x = a - b / 3 + c * 2 - 1;

Console.WriteLine(x);

Console.ReadLine();

a) 92

b) 89

c) 90

d) 88

View Answer

Answer: c

Explanation:The basic evaluation process includes two left to right passes through the expression.During
first pass,the high priority

operators are applied and during second pass,the low priority operators are applied as they are
encountered.

First pass :

step 1 : x = 90 15 / 3 + 3 * 2 1 (15 / 3 evaluated)

step 2 : x = 90 5 + 3 * 2 1
step 3 : x = 90 5 + 3 * 2 -1 (3 * 2 is evaluated)

step 4 : x = 90 5 + 6 1

Second pass :

step 5 : x = 85 + 6 1 (90 5 is evaluated)

step 6 : x = 91 1( 85 + 6 is evaluated )

step 7 : x = 90(91 1 is evaluated)

Output : 90.

3. Predict the solution for following set of code .

static void Main(string[] args)

int a, b, c, x;

a = 80;

b = 15;

c = 2;

x = a - b / (3 * c) * ( a + c);

Console.WriteLine(x);

Console.ReadLine();

a) 78

b) -84

c) 80

d) 98

View Answer
Answer: b

Explanation:Whenever the parentheses are used,the expressions within parantheses assumes higher
priority.If Two or more sets of parantheses

appear one after another as shown above,the expression contained on the left side is evaluated most
first and right hand side most in last .

First pass:

Step 1: 80 15/(3*2)*(80 + 2)

Step 2: 80 15/6*82 ( (3 * 2) evaluated first and ( 80 + 2) evaluated later )

Second pass:

Step 3: 80 2*82

Step 4: 80 164.

Third pass:

Step 5 : -84. (80 164 is evaluated)

Output : -84 .

4. Correct order of priorities are :

a) / > % > * > +

b) / > * > % > +

c) * > / > % > +

d) % > * > / > +

View Answer

Answer: c

Explanation : By definition.

5. Predict the output for given snippet of code :

int i, j = 1, k;
for (i = 0; i < 3; i++)

k = j++ - ++j;

Console.Write(k + " ");

a) -4 -3 -2

b) -6 -4 -1

c) -2 -2 -2

d) -4 -4 -4

View Answer

Answer: c

Explanation : Here i = 0 , j = 1.

k = 1 3 ( j++ = 2 and ++j = 3)

k = -2.

i = 1 , j = 3.

k = 3 5 ( j++ = 4 and ++j = 5)

k = -2.

i = 2 , j = 5.

k = 5 7 (j++ = 6 and ++j = 7)

k = -2.

Output : -2 ,-2 ,-2.

6. Predict the output for given set of code correctly.

static void Main(string[] args)


{

int b= 11;

int c = 7;

int r = 5;

int e = 2;

int l;

int v = 109;

int k;

int z,t,p;

z = b * c;

t = b * b;

p = b * r * 2;

l = (b * c) + (r * e) + 10;

k = v - 8;

Console.WriteLine(Convert.ToString(Convert.ToChar(z)) + " " + Convert.ToString(Convert.ToChar(t)) +


Convert.ToString(Convert.ToChar

(p)) + Convert.ToString(Convert.ToChar(l)) + Convert.ToString(Convert.ToChar(v)) +


Convert.ToString(Convert.ToChar(k)));

Console.ReadLine();

a) My Name

b) My nAme

c) My name

d) Myname

View Answer
Answer: c

Explanation : Solving the expression l = (b * c) + (r * e) + 10 .While from left to right the parantheses are
given preference first.

Step 1 : b * c is evaluated first inside first parantheses.

Step 2 : r * e is evaluated second on right side of first addition symbol .

Step 3 : After evaluating both parantheses 10 is added to value of both.

Output : My name.

7. Predict the output for following set of code :

static void Main(string[] args)

int n = 5;

int x = 4;

int z, c, k;

for (c = 1; c <= n; c++)

for (k = 1; k <= c; k++)

z = 3 * x * x + 2 * x + 4 / x + 8;

Console.Write(Convert.ToString(Convert.ToChar(z)));

Console.WriteLine("\n");

Console.ReadLine();

a) A
AA

AAA

AAAA

b) A

AB

ABC

ABCD

c) A

AA

AAA

AAAA

AAAAA

d) A

BC

DEF

DEFG

View Answer

Answer: c

Explanation :Solving the expression for value of zas 65.With,each passage of loop value number of z
increases for each row

as Row 1: A

Row 2: AA

Row 5: AAAAA
Output : A

AA

AAA

AAAA

AAAAA

8. Predict the output for following set of code :

static void Main(string[] args)

int n = 5;

int x = 4;

int z, c, k;

z = 3 * x * x + 2 * x + 4 / x + 8;

for (c = 1; c <= n; c++)

for (k = 1; k <= c; k++)

Console.Write(Convert.ToString(Convert.ToChar(z)));

z++;

Console.WriteLine("\n");

Console.ReadLine();

a) A
AA

AAA

AAAA

AAAAA

b) A

AB

ABC

ABCD

ABCDE

c) A

BC

DEF

GHIJ

KLMNO

d) A

AB

BC

BCD

BCDE

View Answer

Answer: c

Explanation :Solving expression z value is 65.Before going inside first loop

Step 1: c = 1,n = 5

k = 1,k <= 1. (as c = 1)


z = 65 converted to 'A' as ascii value of 'A' is 65.

z++ increment for next loop condition by '1'as 66.

Row 1: A

Step 2: c = 2, n = 5

k = 2,k <= 2. (as c = 2)

z = 66 from step 1 converted value of 66 is 'B'.Since,k < =2

loop will again loop to second value after 66 which is 67 as z is

incremented from 66 to +1 as '67'.so,converting ascii value of 67 to character as 'C'.

Row 2: B C

Similarly,

Step 3:

Row 3: D E F

Step 4:

Row 4: G H I J

Step 5:

Row 5: K L M N O.

Output : A

BC

DEF

GHIJ

KLMNO

9. Choose exact solution for following code snippet :

static void Main(string[] args)

{
int a , b;

int c = 10;

int d = 12;

int e = 5;

int f = 6;

a = c * (d + e) / f + d;

Console.WriteLine(a);

b = c * ( d + e / f + d);

Console.WriteLine(b);

if (a < b)

Console.WriteLine(" parantheses changes values");

else if (a > b)

Counterintelligence("they have same value");

Console.ReadLine();

a) They have same value

b) Parentheses changes values

c) Since, both have equal values no conclusion

d) None of the mentioned

View Answer
Answer: b

Explanation: Solving for expression a expression inside parentheses are given preference evaluating
(d+e) as 17.

a = 10 * 17/6 + 12.

a = 40.

Solving for expression b expression inside parentheses (d + e /f + d ) are evaluated as (12 + 5/6 + 12 )

b = 10 *(12 + 5/6 + 12 ).

b = 240.

Output : 40

240

parantheses changes values.

10. The correct way of incrementing the operators are :

a) ++ a ++

b) b ++ 1

c) c += 1

d) d =+ 1

View Answer

Answer: c

Explanation: This += is known as short hand operator which same as variable = variable +1 .Similarly, a-=
1 is a = a-1, a*=1 is a = a * 1.

They are used to make code short and efficient.

1. Select the relevant output for following set of code:


static void Main(string[] args)

int a = 4;

int b = 5;

int c = 6;

int d = 8;

if (((a * b / c) + d) >= ((b * c + d ) / a))

Console.WriteLine("Line 1 - a is greater to b");

Console.WriteLine((a * b / c) + d);

else

Console.WriteLine("Line 1 - a is not greater to b");

Console.WriteLine((b * c + d )/ a);

a) Line 1 a is greater to b

11

b) Line 1 a is not greater to b

c) Both are equal

d) None of the mentioned

View Answer
Answer: a.

Explanation :Now, here in if condition both conditions of parenthesis and hence evaluating operators
based on parenthesis are tested.

for expression : ((a * b / c) + d)

Step 1 : (a*b/c) (Evaluating as 4*5/6 = 3)

Step 2 : ( (a*b/c) + d ) (Evaluating (3 + 8 = 11))

Result : 11

for expression : (b * c + d )/ a

Step 1 : (b*c + d) (Evaluating as 5*6 +8 = 38)

Step 2: (b*c + d) / a (Evaluating as 38 / 4 = 9)

Result : 9

The relational operator >= between both expressions checks for largest figure and hence
consecutively executes if condition.

Output : Line 1 a is greater to b.

11

2. Check for given code whether the given relation operator works according to the if condition or not.

static void Main(string[] args)

int a = 10;

int b = 5;

int c = 12;

int e = 8;

int d;

d = Convert.ToInt32((a * (c - b) / e + (b + c)) <= (e * (c + a) / (b + c) + a));

Console.WriteLine(d);
if (d == 1)

Console.WriteLine("C# is great language!");

Console.WriteLine((a * (c - b) / e + (b + c)));

else

Console.WriteLine("harsh is not great language!");

Console.WriteLine((e * (c + a) / (b + c) + a));

a) 0

C# is great!

20

b) 0

C# is not great!

25

c) 0

C# is great!

25

d) 0

C# is not great!

20

View Answer
Answer: d.

Explanation :The expression (a * (c b) / e + (b + c)) on evaluation parenthesis by parenthesis give result


mathematically as 25.Similarly,

(e * (c + a) / (b + c) + a) on evaluation parenthesis by parenthesis give mathematically result as


20.Relational operator now checks for

condition as in if condition as (25 < 20 ) which is false. So, a false bit in form of '0' assigned to d. Now, in
if condition (d != 1) as d

= 0. So, condition after else is evaluated.

Output :0.

C# is not great!.

20.

3. Which of the following is/are not Relational operators in C#.NET ?

a) >=

b) !=

c) Not

d) <=

e) <>=

View Answer

Answer: c, e.

Explanation:By definition.

4. The relevant output for following set of code is :

int n = 2;

int p = 4;
int q = 5;

int w = 3;

if ( !((p * q) /n <= (q * w) + n/p ))

Console.WriteLine( ++p + w++ + " " + ++n);

Console.WriteLine("b");

else

Console.WriteLine(--p + q-- + " " + --n);

Console.WriteLine("a");

a) 6 2

b) 8 1

c) 6 1

d) 8 1

View Answer

Answer: b

Explanation: After evaluation of the test expression (!((p*q)/n <= (q*w)+n/p )) .The use of logical
operator(!) turns false(0) result to bit
'1' and hence the condition evaluated by 'if' loop is after else as :

--p = 3

q--= 5

--p + q-- = 8 where now value of 'q'is 4.

--n = 2 - 1 =1.

So,values after evaluations are: 8 1.

a.

Output : 8 1

5. Select the relevant output for set of code :

m = 5;

int y;

1. y = m++;

2. y = ++m;

a) y = 5, m = 6 ; y = 5, m = 5

b) y = 6, m = 6; y = 7, m = 6

c) y = 5, m = 6; y = 7, m = 7

d) y = 5, m = 6; y = 7, m = 8

View Answer

Answer: c.

Explanation : step 1 : m = 5, y = m++ i.e y =5 ,m =6.

step 2 : y = ++m , Since m = 6 .So, m = 7 on ++m and hence y = 7.

Output : y = 5, m = 6; y =7 , m = 7.

6. Predict the output for follwing set of code :


static void Main(string[] args)

int a = 3, b = 5, c = 1;

int z = ++b;

int y = ++c;

b = Convert.ToInt32((Convert.ToBoolean(z)) && (Convert.ToBoolean(y)) ||


Convert.ToBoolean(Convert.ToInt32(!(++a == b))));

a = Convert.ToInt32(Convert.ToBoolean(c) || Convert.ToBoolean(a--));

Console.WriteLine(++a);

Console.WriteLine(++b);

Console.WriteLine(c);

a) 2 ,2 ,1

b) 2 ,3 ,2

c) 2 ,2 ,2

d) 2 ,0 ,9

View Answer

Answer: c.

Explanation : z = 6 as ++b.

y = 2 as ++c.

6 && 2 = 1

(++a == b ) which is false as 4!=6. Now, !(false) = true i.e 1.

So, 1 || 1 = 1. So, b = 1.

Similarly, c = 2 and a = 4.Now, 2 || 4 = 1.


So, a = 1.

Hence ++a = 2,++b = 2, c = 2.

Output : 2, 2, 2

7. Select the output for for relevant code set :

static void Main(string[] args)

int a = 4, b = 5, c = 7, u = 9;

int h;

h = (Convert.ToInt32(u < b)) + (a + b--) + 2;

Console.WriteLine(h);

Console.WriteLine(b);

Console.WriteLine(u < b);

a) 12, 5, 0

b) 11, 4, False

c) 11, 5, 0

d) 12, 4, False

View Answer

Answer: b.

Explanation :Step 1: Convert.ToInt32(u < b)(Evaluate result as 9 < 5 which is false in nature.So, solution
is converted from 'false' to

'0').

Step 2: (a + b--) evaluated as 4 + 5 = 9 + 2 =11.


Step 3: u < b evaluated as 'False' without being converted to '0'.

Output : 11

False.

8. Select the suitable output for following set of code :

static void Main(string[] args)

int m = 10, n = 5, p = 20;

bool b1 = m * p / n <= p * n / m ;

int l = p - 2 * m;

bool b2 = l == 0;

int z = Convert.ToInt32(b2);

int k = Convert.ToInt32(b1);

Console.WriteLine(k);

Console.WriteLine(z);

a) 0 0

b) 1 0

c) 0 1

d) 1 1

View Answer

Answer : c
Explanation: Solving the expression for b1 test the condition either it is true or false result in 0.
Similarly, for b2 l on solving

gives 0. So, condition is true for bool b2 as 0 == 0 . Hence, k = 0 and z = 1.

Output : 0 1.

9. Select the output for following set of code :

class method1

public int fun(int m)

return( m++ % 10);

class Program

static void Main(string[] args)

int a = 23, b = 0, c;

method1 z = new method1();

c = z.fun (++b * --a % 2);

int d = (z.fun (c-- + --a));

Console.WriteLine(c);

Console.WriteLine(a++);

Console.WriteLine(d);

Console.ReadLine();
}

a) -1, 22, 0

b) -1, 21, 1

c) 0, 22, 1

d) 0, 22, 0

View Answer

Answer : b.

Explanation:Here, for first value of c, ++b = 1 and 1 * (22%2) = 0 . c = 0 . Now c = 0 and a = 22 1


=21.Now, c is first condition

executed then decremented So, c = -1.Similarly, a++ = 21. Now, as we can see from options we are
confirm over value of c = -1, a = 21. So,

we can easily know that d = 1.

Output:-1 21 1

10. Select the output for following set of Code :

static void Main(string[] args)

int a = 8, b = 6, c = 10;

int d = a * c * 2 / Convert.ToInt32(Math.Pow ((c - b), 2));

if (d == (c = Convert.ToInt32(Math.Sqrt (a * a + b * b))) && c == 10)

Console.WriteLine("figure is hypotenuse");

}
else

Console.WriteLine("figure is square");

a) Figure is square

b) Figure is hypotenuse

c) False

d) None of the mentioned

View Answer

Answer : a.

Explanation : Solving the expression for c we get c==10 in if first condition as (c ==


Convert.ToInt32(Math.Sqrt(a * a + b * b))). The

logical condition when d == (c = 10) suits here . Similarly, going for second condition where c ==10 as
&& operator exists between both

given condition and at last both are evaluated to true as c == 10. So, only first statement is executed.

Output :Figure is square

1. Select the relevant output for the following set of code :

static void Main(string[] args)

byte varA = 10;


byte varB = 20;

long result = varA & varB;

Console.WriteLine("{0} AND {1} Result :{2}", varA, varB, result);

varA = 10;

varB = 10;

result = varA & varB;

Console.WriteLine("{0} AND {1} Result : {2}", varA, varB, result);

Console.ReadLine();

a) 0, 20

b) 10, 10

c) 0, 10

d) 0, 0

View Answer

Answer: c.

Explanation : When OR operations is done on the binary values following are the results of OR.

OR means addition(+) operation.

0 (false) + 0(false) = 0 (false)

1 (True) + 0(false) = 1 (True)

0(false) + 1(True) = 1 (True)

1(True) + 1(True) = 1 (True)

When using OR operation it gives FALSE only when both the values are FALSE. In all other cases OR
operation gives true.

Output : 10 AND 20 Result :0.

10 AND 10 Result :10.


2. Select the relevant output for the following set of code :

public static void Main()

byte varA = 10;

byte varB = 20;

long result = varA | varB;

Console.WriteLine("{0} OR {1} Result :{2}", varA, varB, result);

varA = 10;

varB = 10;

result = varA | varB;

Console.WriteLine("{0} OR {1} Result : {2}", varA, varB, result);

a) 20, 10

b) 30, 10

c) 10, 20

d) 10, 10

View Answer

Answer: b.

Explanation:There are two kinds of Shift operations Right Shift and Left Shift. Right Shift operation is
used for shifting the bits

positions towards right side.Left Shift operation is used for shifting the bits positions towards left side.
When RightShift operations are

done on a binary value the bits are shifted to one position towards right side.
Output :10 OR 20 Result :30.

10 OR 10 Result :10.

3. Select the output for following set of Code:

static void Main(string[] args)

byte b1 = 0 * AB;

byte b2 = 0 * 99;

byte temp;

temp = (byte) ~b2;

Console.Write( temp + " ");

temp = (byte) (b1 << b2);

Console.Write(temp + " ");

temp = (byte)(b2 >> 2);

Console.WriteLine(temp);

Console.ReadLine();

a) 101 0 34

b) 103 2 38

c) 102 0 38

d) 101 1 35

View Answer

Answer: c

Explanation: None.
Output:102 0 38.

4. Which one of the following options is not Bitwise Operators in C#?

a) &, |

b) ^, ~

c) <<, >>

d) +=, -=

View Answer

Answer: d

Explanation:+=, -= are Assignment Operators in C#.

5. Select the output for following set of Code:

bool a = true;

bool b = false;

a |= b;

Console.WriteLine(a);

Console.ReadLine();

a) 0

b) 1

c) True

d) False

View Answer

Answer: c

Explanation: bools are single bits, and so a bit-wise OR is the same as a logical OR.
Output : True.

6. Select the relevant code set to fill the blank for following program :

static void Main(string[] args)

int x = 10, y = 20;

int res;

/*_______________*/

Console.WriteLine(res);

a) x % y == 0 ? (x == y ? (x += 2):(y = x + y)):y = y*10;

b) x % y == 0 ? y += 10:(x += 10);

c) x % y == 0 ? return(x) : return (y);

d) All of the mentioned.

View Answer

Answer: b

Output : {

int x = 10, y = 20;

int res;

x % y == 0 ? y += 10:(x += 10);

Console.WriteLine(res);

7. Select the output for following set of code:


static void Main(string[] args)

int y = 5;

int x;

int k = (!(Convert.ToInt32(y) > 10))? x = y + 3 : x = y + 10;

Console.WriteLine(x);

Console.WriteLine(y);

Console.ReadLine();

a) 5, 8

b) 10, 4

c) 8, 5

d) 11, 8

View Answer

Answer:c.

Explanation:Since condition y > 10 is false and !(false) = true .So, first statement x = y + 3 is executed
which is x = 8 with y = 5.

Output: 8, 5.

8. Which are conditional operators ?

a) :?

b) ?;

c) ?:

d) ??

View Answer
Answer: c.

Explanation:By definition.

9. Select the Output for following set of code :

public static void Main(string[] args)

int a = 4;

int c = 2;

bool b = (a % c == 0 ? true : false);

Console.WriteLine(b.ToString());

if (a/c == 2)

Console.WriteLine("true");

else

Console.WriteLine("false");

Console.ReadLine();

a) True

False

b) False

True

c) True
True

d) False

False

View Answer

Answer: c

Explanation: a % c == 0 condition is true as (4 % 2 == 0). So, b is evaluated as true.Now (a/c == 2) that is if


condition is also true hence

evaluated as true.

Output: True

True

10. Arrange the operators in order of increasing as defined in C#:

!=, ?:, &, ++, &&

a) ?: < && < != < & < ++

b) ?: < && < != < ++ < &

c) ?: < && < & < != < ++

d) ?: < && < != < & < ++

View Answer

Answer: c.

Explanation:By definition.

1. Select the output for following set of code :

static void Main(string[] args)


{

int i = 30;

int j = 25 % 25;

if (Convert.ToBoolean(Convert.ToInt32(i = j)))

Console.WriteLine("In if");

else

Console.WriteLine("In else");

Console.WriteLine("In main");

Console.ReadLine();

a) In if

b) In else

c) In if

In main

d) In else

In main

View Answer

Answer: d

Explanation :Usage of = operator instead of == operator .hence,condition is not true.

Output: In else
In main

2. Select output for following set of Code:

static void Main(string[] args)

int i;

int b = 8, a = 32;

for (i = 0; i <= 10; i++)

if ((a / b * 2)== 2)

Console.WriteLine( i + " ");

continue;

else if (i != 4)

Console.Write(i + " ");

else

break;

Console.ReadLine();

a) 1 2 3 4 5 6 7 8 9

b) 0 1 2 3 4 5 6 7 8

c) 0 1 2 3

d) 0 1 2 3 4
View Answer

Answer: c

Explanation:The if condition will never be fulfilled as ((a / b) * 2 == 2) is never true.Hence,only else part
of condition will be executed

until i! = 4 i.e i = 0,1 ,2 ,3.

Output:0 1 2 3

3. Select the output for following set of Code:

static void Main(string[] args)

Console.WriteLine("Enter a letter:");

char c = (char)Console.Read();

if (Char.IsDigit(c) == true)

Console.WriteLine("A number");

else if (char.IsLower(c) == true)

Console.WriteLine("A lower case letter");

else if (char.IsUpper(c) == true)

Console.WriteLine("An upper case letter");

Console.ReadLine();

1. Enter a letter :

An upper case letter

2. Enter a letter :
A

An upper case letter

3. Enter a letter :

A number

4. Enter a letter :

A lower case letter.

Which of following conditions are true ?

a) a ,b ,c

b) b ,c ,d

c) a ,d ,b

d) b ,c

View Answer

Answer: d

Output :Enter a letter :

An upper case letter

Enter a letter :

A number

4. Select the output for following set of code :

static void Main(string[] args)


{

int i, j;

for (i = 2; i >= 0; i--)

for (j = 0; j <= 2; j++)

if (i == j)

Console.WriteLine("1");

else

Console.WriteLine("0");

Console.WriteLine("\n");

Console.ReadLine();

a) 1 0 0

010

001

b) 0 1 0

100

001
c) 0 0 1

010

100

d) 1 0 0

001

010

View Answer

Answer: c

Explanation : In first row for i = 2 : j = 0 == 0 as if condition fails for (i == j)

i = 2 : j = 1 == 0 as again if condition fails for ( i == j)

i = 2 : j = 2 == 1 as (i == j).

In Second row for i = 1 : j = 0 == 0 as if condition fails for (i == j)

i = 1 : j = 1 == 1 (as i==j)

i = 1 : j = 2 == 0 as (i==j) not true

In Third row for i = 0 : j = 0 == 1 as (i==j) true

i = 0 : j = 1 == 0 as (i==j) not true.

i = 0 : j = 2 == 0 .

So, 0 0 1

010

100

Output: 0 0 1

010

100

5. Select the relevant if statement to be placed in following set of code :


static void Main(string[] args)

int []num = {50, 65, 56, 88, 43, 52};

int even = 0, odd = 0;

for (int i = 0 ;i < num.Length ;i++)

/*___________________________*/

Console.WriteLine("Even Numbers:" +even);

Console.WriteLine("Odd Numbers:" +odd);

Console.ReadLine();

a) if ((num % 2) == 0)

even += 1;

else

odd += 1;

b) if((num * i) == 0)

even += 1;

}
else

odd += 1;

c) if(num[i] % 2 == 0)

even += 1;

else

odd += 1;

d) if(num[i] % 2 = 0)

even += 1;

else

odd += 1;

View Answer

Answer: c

Explanation: int []num = {50, 65, 56, 88, 43, 52};

int even = 0,odd = 0;


for (int i = 0 ;i < num.Length ;i++)

if (num[i] % 2 == 0)

even += 1;

else

odd += 1;

Console.WriteLine("Even Numbers: " +even);

Console.WriteLine("Odd Numbers: " +odd);

Console.ReadLine();

6. What is the output for the following code ?

static void Main(string[] args)

int a = 15, b = 10, c = 1;

if (Convert.ToBoolean(a) && (b > c))

Console.WriteLine("cquestionbank");

else

{
break;

a) cquestionbank

b) It will print nothing

c) Compile time error

d) Run time error

View Answer

Answer: c

Explanation:Keyword break is not part of if-else statement.This keyword used in case of loop or switch
case statement.

7. What is the output for the following code ?

static void Main(string[] args)

int a = 5;

if (Convert.ToBoolean((.002f) -(0.1f)))

Console.WriteLine("Sachin Tendulkar");

else if (a == 5)

Console.WriteLine("Rahul Dravid");

else

Console.WriteLine("Ms Dhoni");

Console.ReadLine();

a) Rahul Dravid
b) Sachin Tendulkar

c) Ms Dhoni

d) Warning : Unreachable Code

View Answer

Answer: b

Explanation:(0.002 0.1f) not equivalent to zero hence it is true. So,only first if clause will execute and
print:Sachin Tendulkar on

console.As,first condition always true so no else if statement will be executed.

Output: Sachin Tendulkar

8. Select the output for following set of Code :

static void Main(string[] args)

int a = -1;

int b = -1;

if (Convert.ToBoolean (++a = ++b))

Console.WriteLine("a");

else

Console.WriteLine("b");

Console.ReadLine();

a) a

b) b

c) Compile time error


d) Code execute successfully with no output

View Answer

Answer: c

Explanation:Both a and b are constants.Illegal to assign a value to constant on left hand of =operator
.Hence,it must be some variable.

Output: static void Main(string[] args)

int a = -1;

int b = -1;

if (Convert.ToBoolean(++a == ++b))

Console.WriteLine(a);

else

Console.WriteLine(b);

Console.ReadLine();

9. Select the output for following set of Code :

static void Main(string[] args)

int a = 5, b = 10;

if (Convert.ToBoolean(Convert.ToInt32(0xB)))

if (Convert.ToBoolean(Convert.ToInt32(022)))

if (Convert.ToBoolean(Convert.ToInt32('\xeb')))

Console.WriteLine("java");

else ;
else ;

else ;

a) Compile time error: Misplaced else

b) Compile time error: Undefined symbol

c) java

d) Warning: Condition is always true

View Answer

Answer: c

Explanation: oxB: hexadecimal integer constant.

022: It octal integer constant.

\xeb: It is hexadecimal character constant.

As,zero is false and any non-zero number is true. All,constants return a non-zero value. So, all if
conditions in the above program are

true.

Output: java.

10. Select the output for following set of Code :

static void Main(string[] args)

int a = 5, b = 10;

if (Convert.ToBoolean(Convert.ToInt32(++a)) || Convert.ToBoolean(Convert.ToInt32(++b)))

Console.WriteLine(a + "\n" + b);


}

else

Console.WriteLine(" C# ");

a) 6 11

b) 6 16

c) 6 12

d) 6 10

View Answer

Answer: d

Explanation: Consider the following expression:( ++a || ++b). In this expression || is Logical OR
operator. Two important properties of

this operator are:

Property 1:

(Expression1) || (Expression2)

|| operator returns 0 if and only if both expressions return a zero otherwise it || operator returns 1.

initial value of a is 5. So ++a will be 6. Since ++a is returning a non-zero so ++b will not execute.

Output : 6 10.

1. Select the output for following set of code.

static void Main(string[] args)

int movie = 1;
switch (movie << 2 + movie)

default:

Console.WriteLine("3 Idiots");

break;

case 4:

Console.WriteLine("Ghazini");

break;

case 5:

Console.WriteLine("Krishh");

break;

case 8:

Console.WriteLine("Race");

break;

Console.ReadLine();

a) 3 Idiots

b) Ghazini

c) Race

d) Krishh

View Answer

Answer: c

Explanation:We can put default case in any order and hence write cases in any order.
Output: Race.

2. Select the output for following set of code :

static void Main(string[] args)

int i = 2, j = 4;

switch (i + j * 2)

case 1 :

case 2 :

Console.WriteLine("1 and 2");

break;

case 3 to 10:

Console.WriteLine("3 to 10");

break;

Console.ReadLine();

a) 3 to 10 will be printed

b) 1 and 2 will be printed

c) The code reports an error as missing ; before :

d) The code gives output as 3 to 10

View Answer

Answer: c
Explanation: Syntax error switch case do not work with syntax as 3 to 10:

Output :

static void Main(string[] args)

int i = 2,j = 4;

switch (i + j * 2)

case 1 :

case 2 :

Console.WriteLine(1 and 2);

break;

case 3 :

Console.WriteLine(3 to 10);

break;

Console.ReadLine();

Here i = 2,j = 4.So,(i + j * 2) gives output as 10 and case 10 is missing.So,prints nothing for given code.

3. Select the output for following set of code :

static void Main(string[] args)

int i = 2, k = 3;

switch (i - k)

{
case -1:

++i;

++k;

break;

case 2:

--i;

++k;

break;

default:

i += 3;

k += i;

break;

Console.WriteLine(i + "\n" + k);

Console.ReadLine();

a) 2 3 3

b) 3 2 3

c) 3 4 4

d) 5 10 10

View Answer

Answer:c

Output: 3

4
4

Explanation:i k = -1.So, case -1 will be executed only .

4. Select output for following set of code :

static void Main(string[] args)

int const p = 0;

switch (3 * 5 / 6)

case p:

Console.WriteLine("A");

break;

case p * 1:

Console.WriteLine("B");

break;

case p - 2:

Console.WriteLine("C");

break;

default:

Console.WriteLine("D");

a) A

b) B

c) C
d) Compile time error

View Answer

Answer: d

Explanation:In case expression we dont have constant variable.

5. Select output for following set of code :

static void Main(string[] args)

int i = 2, j = 3, k = 4;

switch (i + j - k)

case 0: case 2: case 4:

++i;

k += j;

break;

case 1: case 3: case 5 :

--i;

k -= j;

break;

default:

i += j;

break;

Console.WriteLine(i + "\n" + j + "\n" + k);


Console.ReadLine();

a) 1 3 1

b) 2 3 4

c) 5 3 4

d) Compile time error.

View Answer

Answer: a

Explanation:Solving expression (i + j k) gives 1 and hence,solving for case 1:case 3:case 5:.

Output : 1

6. Select the output for following set of code :

static void Main(string[] args)

int i = 9 , j = 7;

switch (i - j + 3)

case 9: 7:

j += 6;

break;

case 5:

i -= 4;
break;

Console.WriteLine(i + "\n" + j);

Console.ReadLine();

a) 5 7

b) 9 13

c) Compile time error

d) 9 7

View Answer

Answer: c

Explanation:Invalid expression7: in case 9:7:.

7. Select the output for code :

static void Main(string[] args)

switch (5)

case 5.0f:

Console.WriteLine("harsh");

break;

case 5:

Console.WriteLine("amish");

break;
case 5.0L:

Console.WriteLine("ANKIT");

break;

default:

Console.WriteLine("ashish");

Console.ReadLine();

a) amish

b) ANKIT

c) harsh

d) Compile time error

View Answer

Answer: d

Explanation: Only integral values are allowed for case expression.

5.0f = (int)5.0f.

5.0L =(int)5.0L.

8. Select output for code:

static void Main(string[] args)

int i;

int j = 1;

int []ar = {21, 22, 13, 4};


switch (ar[j])

case 1:

i++;

break;

case 2:

i += 2;

j = 3;

continue;

case 3:

i %= 2;

j = 4;

continue;

default:

--i;

Console.WriteLine(i);

Console.ReadLine();

a) 23

b) 15

c) Compile time error

d) 12

View Answer
Answer: c

Explanation:Continue cannot be used part of switch statement.

Output :

static void Main(string[] args)

int i;

int j = 1;

int []ar = {21 , 22, 13, };

switch(ar[j])

case 1:

i++;

break;

case 2:

i += 2;

j = 3;

continue;

case 3:

i %= 2;

j = 4;

default:

i;

Console.WriteLine(i);

Console.ReadLine();
}

9. Select the output for following set of Code:

static void Main(string[] args)

char ch = Convert.ToChar('a' | 'b' | 'c');

switch (ch)

case 'A':

case 'a':

Console.WriteLine("case A|case a");

break;

case 'B':

case 'b':

Console.WriteLine("case B|case b");

break;

case 'C':

case 'c':

case 'D':

case 'd':

Console.WriteLine("case D|case d");

break;

Console.ReadLine();

}
a) Compile time error

b) case A|case a

c) case B|case b

d) case D|case d

View Answer

Answer: d

Explanation:Case statement declared last will only be executed as no particular casenumber is declared
is to be called.

Output : case D|case d

10. Select the output for following set of Code:

static void Main(string[] args)

char ch = 'p';

switch (ch)

case 'p':

Console.WriteLine("coco" + "\t" + Convert.ToInt32(ch));

break;

default:

Console.WriteLine("default");

break;

Console.WriteLine("main");

}
a) coco main

b) coco 112

c) coco 112 main

d) compile time error

View Answer

Answer: c

Explanation: ASCII value of p is 112.Hence, coco 112 main.

Output: coco 112 main.

1. Select the output for following set of code :

static void Main(string[] args)

int i;

for (i = 0; ; )

Console.WriteLine("hello");

Console.ReadLine();

a) No output

b) hello

c) hello printed infinite times


d) Code will give error as expression syntax

View Answer

Answer: c

Explanation: Testing condition for the loop is absent.So,loop will continue executing.

Output : hello

hello

hello

2. Select the output for following set of code :

static void Main(string[] args)

float f;

for (f = 0.1f; f <= 0.5; f += 1)

Console.WriteLine( ++f );

Console.ReadLine();

a) 1.1

b) 0.1

c) 0.1 0.2 0.3 0.4 0.5

d) None of the mentioned

View Answer
Answer: a.

Explanation:f =0.1 and ++f = 0.1+1 = 1.1.So,1.1>0.5,Condition fails and hence loop terminates.

Output : 1.1

3. Select the output for following set of code:

static void Main(string[] args)

int I, X;

for (I = 1; I <= (9 % 2 + I); I++)

X = (I * 3 + I * 2) / I;

Console.WriteLine(X);

Console.ReadLine();

a) Output of code is 5 10

b) Output is 5 5 5 5

c) Print 5 infinite times

d) None of the mentioned

View Answer

Answer: c

Explanation:Testing condition always incremented i.e i never > (9%2+I).So,loop will never terminate.

Output : 5 5 5..
4. Select output for following set of code:

static void Main(string[] args)

int I, J = 0;

for (I = 1; I < 10; ) ;

J = J + I;

I += 2;

Console.WriteLine("Sum of first 10 even numbers is:"+J);

Console.ReadLine();

a) 1 2 3 4 5 6 7 8 9

b) 25

c) 1

d) Run time error

View Answer

Answer: d.

Explanation:Due to presence of ; after for()loop condition do not work as according to the


statement.Remove the ;.

Output : 25.

5. Select output for following set of code:

static void Main(string[] args)


{

int i = 5;

for (; Convert.ToBoolean(Convert.ToInt32(i)); Console.WriteLine(i--)) ;

Console.ReadLine();

a) 4 3 2 1

b) 3 2 1

c) 5 4 3 2 1

d) 2 1

View Answer

Answer: c

Explanation:Since, i = 5 and test condition is executed until i!=0.So, i decrements value of i till condition
is satisfied.

Output: 5 4 3 2 1

6. Select the output for following set of code:

static void Main(string[] args)

int i, s = 0;

for (i = 1; i <= 10; s = s + i, i++);

Console.WriteLine(s);

Console.ReadLine();

}
a) Code report error

b) Code runs in infinite loop condition

c) Code gives output as 0 1 3 6 10 15 21 28 36 45

d) Code give output as 55

View Answer

Answer: d

Explanation: Since occurrence of termination symbol(;) at end of for loop.

Output: 55.

7. Which statement is correct of the mentioned statements?

1. The for loop works faster than a while loop

2. for( ; ; )implements an infinite loop

a) Only 1 is correct

b) Only 2 is correct

c) Both 1 and 2 are correct

d) Both 1 and 2 are incorrect

View Answer

Answer: b

Explanation:By defination.

8. Select the output for following set of code :

int i;

Console.WriteLine("Hi");
for (i = 1; i <= 10; i++)

Program.Main(args);

Console.ReadLine();

a) Prints Hi for one time

b) Prints Hi for infinite times

c) Stack overflow exception Condition generated

d) None of above mentioned

View Answer

Answer: c

Explanation: Ocurrence of main() condition after for loop.

Output: Hi

Hi

stack overflow exception.

9. Which of the code should be added to get following output?

*****

****

***

**

static void Main(string[] args)


{

int i,j;

/* Add code here */

a) for (i = 0;i <= 4; i++)

for(j = 0;j <= 4; j++)

console.WriteLine("*");

console.WriteLine("\n");

b) for (i = 0;i <= 4; i++)

for(j = 4;j <= i; j--)

console.WriteLine("*");

console.WriteLine("\n");

c) for (i = 0;i <= 4; i++)

for (j = i;j <= 4; j++)

console.WriteLine("*");

console.WriteLine("\n");

}
d) for ( i = 0;i <= 4; i++)

for (j = 0;j <= i; j++)

console.WriteLine("*");

console.WriteLine("\n");

View Answer

Answer: c

Explanation: Input in Console and run the code.

10. Predict the output for following set of code :

static void Main(string[] args)

int i;

for (i =-3; i <= 3; i++)

switch (i)

case 0:

Console.WriteLine("zero");

break;

if (i > 0)

Console.WriteLine("A");
else if (i < 0)

Console.WriteLine("B");

Console.ReadLine();

a) B B zero A A A

b) B zero A A A

c) B B B zero A A A

d) A A A zero B B B

View Answer

Answer: c

Output: B B B zero A A A.

Explanation: for i =-3,-2,-1 statement executed as B.for i = 0,it is zero and for i =1,2,3 again statement
printed as A seperately for each

value of i.

11. Which of the following is not infinite loop?

a) for( ;0; )

b) for( ;0; )

c) for( ;1; )

d) for( ;1; )

View Answer

Answer: b.

Explanation: None.
12. Select the output for following set of code :

static void Main(string[] args)

int i, j;

for (i = 1, j = i; i <= 3 && j >= 0; i++, j--)

if (i == j)

continue;

else

Console.WriteLine(j);

Console.ReadLine();

a) i = 0, j = 1;

b) i = 1, j = 0;

c) j = 0;

d) None of the mentioned.

View Answer

Answer: c

Explanation: Since for i = 1, j = 1 and 1 <= 3 also 1 >= 0 we had i == j.But after i++ and j. The initial value
of j which is 0 as j

preferred other than value of j in i = j.

Output:j = 0.
13. Select the output for following set of code :

static void Main(string[] args)

int i = -10;

for ( ;Convert.ToBoolean(Convert.ToInt32(i)) ;Console.WriteLine(i++)) ;

Console.ReadLine();

a) -9 -8 -7 -6 -5 -4 -3 -2 -1

b) -10 -9 -8 -7 -6 -5 -4 -3 -2

c) -10 -9 -8 -7 -6 -5 -4 -3 -2 -1

d) -8 -7 -6 -5 -4 -3 -2 -1

View Answer

Answer: c

Explanation:for first value of i = -10.Condition is executed until i!=0.

Output: -10 -9 -8 -7 -6 -5 -4 -3 -2 -1.

1. Select the output for following set of code :

static void Main(string[] args)

int i, j;

for (i = 1; i <= 3; i++)


{

j = 1;

while (i % j == 2)

j++;

Console.WriteLine(i + " " + j);

Console.ReadLine();

a) 11 21 31

b) 1 12 13 1

c) 11 21 31

d) 1 1 2 1 3 1

View Answer

Answer: c.

Explanation:Since, condition never satisfied for any value of i and j for which (i % j == 2).Hence, j is
always constant 1 and i

increments for i = 1, 2, 3.

Output: 11 21 31.

2. Select the output for following set of code:

static void Main(string[] args)

{
float s = 0.1f;

while (s <= 0.5f)

++s;

Console.WriteLine(s);

Console.ReadLine();

a) 0.1

b) 1.1

c) 0.1 0.2 0.3 0.4 0.5

d) No output

View Answer

Answer: b.

Explanation:for first while condition check when s = 0.1f it is true as control goes inside loop ++s
increments value of s by 1 as 1+0.1 =

1.1. So, for next condition while loop fails and hence, prints final value of s as 1.1.

Output: 1.1

3. Select the output for following set of Code:

static void Main(string[] args)

int i;

i = 0;
while (i++ < 5)

Console.WriteLine(i);

Console.WriteLine("\n");

i = 0;

while ( ++i < 5)

Console.WriteLine(i);

Console.ReadLine();

a) 1 2 3 4

12345

b) 1 2 3

1234

c) 1 2 3 4 5

1234

d) 1 2 3 4 5

12345

View Answer

Answer: c

Explanation: for while(i++ < 5) current value of 'i' is checked first and hence prints incremented value
afterwards.So, i =1, 2, 3, 4,
5.But, for while(++i < 5) current value is incremented first and then checks that value with given
condition and hence then prints that

value.So, i = 1, 2, 3, 4.

Output: 1 2 3 4 5

1234

4. Select the output for following set of Code:

static void Main(string[] args)

int x = 0;

while (x < 20)

while (x < 10)

if (x % 2 == 0)

Console.WriteLine(x);

x++;

Console.ReadLine();

a) 1 2 3 4 5 6 7 8 9 10

11 12 13 14 15 16 17 18 19 20
b) 0 2 4 6 8 10 12 14 16 18 20

c) 0 2 4 6 8

d) 0 2 4 6 8 10

View Answer

Answer: c

Explanation:Inner while loop condition checks for even number between 0 an 10 and hence prints
number between the given range.

Output: 0 2 4 6 8.

5. Predict the output for following set of code :

static void Main(string[] args)

int x;

x = Convert.ToInt32(Console.ReadLine());

int c = 1;

while (c <= x)

if (c % 2 == 0)

Console.WriteLine("Execute While " + c + "\t" + "time");

c++;

Console.ReadLine();

}
for x = 8.

a) Execute while 1 time

Execute while 3 time

Execute while 5 time

Execute while 7 time

b) Execute while 2 time

Execute while 4 time

Execute while 6 time

Execute while 8 time

c) Execute while 1 time

Execute while 2 time

Execute while 3 time

Execute while 4 time

Execute while 5 time

Execute while 6 time

Execute while 7 time

d) Execute while 2 time

Execute while 3 time

Execute while 4 time

Execute while 5 time

View Answer

Answer: b

Explanation:Checks condition if number is divisible by 2 then it will print even number times as given for
x = 8 so, prints between 2 to 8
times Similarly, for x = 5, Execute 2 and 4 time.

OUTPUT: Execute while 2 time.

Execute while 4 time.

Execute while 6 time.

Execute while 8 time.

6. Select output for following set of Code:

static void Main(string[] args)

int n, r;

n = Convert.ToInt32(Console.ReadLine());

while (n > 0)

r = n % 10;

n = n / 10;

Console.WriteLine(+r);

Console.ReadLine();

for n = 5432.

a) 3245

b) 2354

c) 2345

d) 5423

View Answer
Answer: c

Explanation:Reverse of number using while loop.

Output: 2345.

7. Correct syntax for while statement is:

a) while

}(condition);

b) while(condition)

};

c) while(condition)

d) while(condition);

View Answer

Answer:c

Explanation: By defination.
8. Select the output for following set of Code:

static void Main(string[] args)

float i = 1.0f, j = 0.05f;

while (i < 2.0f && j <= 2.0f)

Console.WriteLine(i++ - ++j);

Console.ReadLine();

a) 0.05f

b) 1.50f

c) -0.04999995f

d) 1.50f

View Answer

Answer: c

Explanation: for while(i = 1.0f and j = 0.05f). We, had && condition which gives 1. So, control enters
while loop. Since, i = 1 and i++ =

first execute then increment. So, first with i value as 1.0f and ++j = first increment and then executes
we had j = 1.05f and Since

operation (i++ ++j) gives us a negative sign number. So, we can stick our choice to option c clearly.
Now, as i = 2.0f so loop breaks.

Output:-0.04999995f.
9. Select the output for following set of code :

static void Main(string[] args)

int i = 0;

while (i <= 50)

if (i % 10 == 0)

continue;

else

break;

i += 10;

Console.WriteLine(i % 10);

a) code prints output as 0 0 0 0 0

b) code prints output as 10 20 30 40 50

c) infinite loop but donot print anything

d) Code generate error

View Answer

Answer :c

Explanation:None.

10. Select the output for following set of code:


static void Main(string[] args)

int i = 1, j = 1;

while (++i <= 10)

j++;

Console.WriteLine(i+ " " +j);

Console.ReadLine();

a) 12 11

b) 10 11

c) 11 10

d) 11 12

View Answer

Answer :c.

Explanation:As ++i, first increments then execute so, for ++i i is 11 and j++ is first execute then
increments. So, j = 10.

Output:11 10.

11. Select the output for following set of Code :

static void Main(string[] args)

int i = 1;

while (i <= 1)
{

if ('A' < 'a')

Console.WriteLine("Hello...");

else

Console.WriteLine("Hi...");

i++;

Console.ReadLine();

a) Hi

b) Hello.

c) Hiinfinite times

d) Hello infinite times

View Answer

Answer :b

Explanation:Ascii value of A is 65 and a is 97.So, clearly A < 'a'.

Output:Hello.

12. Select the output for following set of codes:

static void Main(string[] args)


{

int i = 0;

while (i++ != 0) ;

Console.WriteLine(i);

Console.ReadLine();

a) -127 to +127

b) 0 to 127

c) 1

d) Infinite loop condition

View Answer

Answer :c

Explanation: i++ = first executes then increments as i = 0. So, i++ != 0, which is false clearly as i = 0. Now,
control goes inside loop

with i = 1. So, statement prints i = 1.

Output: 1.

1. Select output for following set of code :

static void Main(string[] args)

int i = 1, j = 2, k = 3;

do
{

Console.WriteLine((Convert.ToBoolean(Convert.ToInt32(i++))) &&
(Convert.ToBoolean(Convert.ToInt32(++j))));

}while (i <= 3);

Console.ReadLine();

a) 0 0 0

b) True True True

c) 1 1 1

d) False False False

View Answer

Answer :b

Explanation : 1 AND 1 = True.Similarly , non zero number || non zero number = True.

Output:True True True.

2. Select output for following set of code :

static void Main(string[] args)

float i = 1.0f, j = 0.05f;

do

Console.WriteLine(i++ - ++j);

}while (i < 2.0f && j <= 2.0f);

Console.ReadLine();

}
a) 0.05

b) -0.05

c) 0.95

d) -0.04999995

View Answer

Answer :d.

Explanation : None.

Output : -0.04999995

3. Select the output for following code :

static void Main(string[] args)

int i = 1, j = 5;

do

Console.WriteLine(i = i++ * j);

}while (i <= 10);

Console.ReadLine();

a) 5 10 15 20 25 30 35 40 45 50

b) 5 25

c) 5 11 16 21 26 31 36 41 46 51

d) 5 30

View Answer
Answer :b

Explanation : for first step of loop i = 1 .So, i++ * j = 1 * 5 = 5 .For second step of loop i = 5 ,j = 5 .So, i++ *
j = 25.As, i = 25 hence

, 25 >=10 loop condition breaks.

Output: 5 25.

4. Select the set of Code for following :

static void Main(string[] args)

int i = 1234 ,j = 0;

/*ADD CODE HERE */

Console.WriteLine(j);

a) do

j = j + (i % 10);

}while ((i = i / 10)!= 0);

b) do

j = j + (i % 10);

}while ((i / 10)!= 0);

c) do

j = j + (i % 10);
}while ((i % 10)!= 0);

d) do

j = j + (i % 10);

}while ((i/10 == 0)!= 0);

View Answer

Answer :a.

Output :static void Main(string[] args)

int i = 1234,j = 0;

do

j = j +( i % 10);

}while ((i = i / 10)!= 0);

Console.WriteLine(j);

5. Select the output for following set of code :

static void Main(string[] args)

long x;

x = Convert.ToInt32(Console.ReadLine());

do

{
Console.WriteLine(x % 10);

}while ((x = x / 10) != 0);

Console.ReadLine();

enter x = 1234.

a) number of digits present in x

b) prints 1

c) prints reverse of x

d) prints sum of digits of x

View Answer

Answer :c

Explanation : Reverse of digits using while loop statements.

Output: 4321.

6. Select output for following set of code :

static void Main(string[] args)

int i, s = 0, a = 1, d;

i = Convert.ToInt32(Console.ReadLine());

do

d = i % (2 * 4);

s = s + d * a;

}while ((Convert.ToInt32(i = i / (2 * 4))) != 0 && (Convert.ToBoolean(Convert.ToInt32((a) = (a * 10)))));


Console.WriteLine(s);

Console.ReadLine();

enter i = 342.

a) It finds binary equivalent of i

b) It finds octal equivalent of i

c) It finds sum of digits of i

d) It finds reverse of i

View Answer

Answer :b.

Explanation : None.

Output : i = 342.

s = 526.

7. Correct syntax for do while loop is :

a) do;

statement;

}while (condition);

b) do(condition)

statement;

}while;

c) do

{
statement;

}while (condition)

d) do

statement;

}while (condition);

View Answer

Answer:d.

Explanation : By definition

Output:do

statement;

}while (condition);

8. Select the output for following set of code :

static void Main(string[] args)

int x = 10;

do

Console.WriteLine( x++);

while(Convert.ToBoolean(5) && Convert.ToBoolean(4) && Convert.ToBoolean(3) &&


Convert.ToBoolean(2) && Convert.ToBoolean(1) &&
Convert.ToBoolean(0));

Console.ReadLine();

a) 13

b) 15

c) 11

d) 10

View Answer

Answer :d

Explanation: Here in do while condition && i.e ANDoperator return 0 i.e false.So, as condition is false
so program comes out of the

loop.

Output : 10.

9. Select output for following set of code :

static void Main(string[] args)

int x;

for (x = 10; x <= 15; x++)

while (Convert.ToBoolean(Convert.ToInt32(x)))

do

Console.WriteLine(1);
if (Convert.ToBoolean(x >> 1))

continue;

}while (Convert.ToBoolean(0));

break;

Console.ReadLine();

a) 0 0 0.infinite times

b) 1 1 1.infinite times

c) 1 1 1 1 1 1

d) System outofflow exception error.

View Answer

Answer :c

Explanation : the execution of for loop is done for consecutive six times.

Output : 1 1 1 1 1 1

10. Select the output for following set of code :

static void Main(string[] args)

int x = 0;

do

x++;

if (x == 5)
{

x++;

continue;

break;

Console.WriteLine(x + " ");

}while (x < 10);

a) 1 2 3 4 5

b) 10

c) 5 6 7 8 9 10

d) 1 2 3 4 5 6 7 8 9 10

View Answer

Answer:d

Explanation : The condition will print the numbers from 1 to 10 when x == 5 and when x donot satisfy if
condition until x < 10.

Output: 1 2 3 4 5 6 7 8 9 10 .

11. Select the output for following set of code :

static void Main(string[] args)

int x;

for (x = 1; x <= 3; x++)

int j = 1;
do

j++;

}while (x % j == 2);

Console.WriteLine(x + " " + j);

Console.ReadLine();

a) 1 12 1 3 1

b) 1 12 13 1

c) 12 22 32

d) 11 21 31

View Answer

Answer :c

Explanation: None.

Output : 12 22 32.

1. Select output for following set of code :

static void Main(string[] args)

int i;

Console.WriteLine("enter value of i:");


i = Convert.ToInt32(Console.ReadLine());

if (i < 7)

i++;

continue;

Console.WriteLine("final value of i:" +i);

Console.ReadLine();

a) 12

b) 11

c) Compile time error

d) 13.

View Answer

Answer :c

Explanation : Continue loop cannot be used within if loop .replace while with if(i <7).

Output: Compile time error.

2. Select the output for following set of Code :

static void Main(string[] args)

int i;

Console.WriteLine("enter value of i:");

i = Convert.ToInt32(Console.ReadLine());
if ( i % 2 == 0)

goto even:

else

Console.WriteLine("number is odd:");

Console.ReadLine();

even:

Console.WriteLine("number is even:");

Console.ReadLine();

for i = 4.

a) number is odd

b) number is even

c) Compile time error

d) None of the mentioned

View Answer

Answer :c

Explanation: Undefined label even in main().The syntax goto even: is incorrect instead use goto
even;.

Output:

static void Main(string[] args)

int i;

Console.WriteLine(enter value of i:);


i = Convert.ToInt32(Console.ReadLine());

if (i % 2 == 0)

goto even;

else

Console.WriteLine(number is odd:);

Console.ReadLine();

even:

Console.WriteLine(number is even:);

Console.ReadLine();

3. Select the output for following set of code :

static void Main(string[] args)

int i = 1, j;

do

for (j = 1; ; j++)

if (j > 2)

break;

if (i == j)

continue;
Console.WriteLine(i + " " + j);

i++;

} while (i < 3);

Console.ReadLine();

a) 1 2

21

b) 2 1

12

c) 1 3

21

d) 1 1

21

View Answer

Answer :a

Explanation: for i = 1.When control enters in loop first if condition is checked for where j = 1 and as (j >
2) which is false.Control now

passed to console statement with i = 1 and j = 2.Now, in while condition value of i reflected is 2 i.e i = 2
as i++.Since, (i < 3) control

again enters in for loop with i = 2 but j = 1 not j = 2 for j++ and hence,same again condition executes for
console statement.

Output : 1 2

21
4. Select the output for following set of code :

static void Main(string[] args)

int i = 10 , j = 0;

label:

i--;

if ( i > 0)

Console.WriteLine(i+ " ");

goto label;

Console.ReadLine();

a) 1 2 3 4 5 6 7 8 9 10

b) 10 9 8 7 6 5 4 3 2 1 0

c) 9 8 7 6 5 4 3 2 1

d) 10 9 8 7 6 5 4 3 2 1

View Answer

Answer :c

Explanation: for i = 10,loop executes for first time in if loop as (i>0) i.e (9 > 0) and hence printing
9.Similarly,label condition

executes again go for (i) i.e (9-1=8) and hence again prints i = 8.In this way looping condition executes
as 9 ,8 to 3, 2, 1.

OUTPUT :9 8 7 6 5 4 3 2 1.
5. Select the output for following set of code :

static void Main(string[] args)

int i = 0, j = 0;

while (i < 2)

l1: i--;

while (j < 2)

Console.WriteLine("hi\n");

goto l1;

Console.ReadLine();

a) hi hi hi

b) hi hi

c) hi

d) hi hi hi..infinite times

View Answer

Answer :d.

Explanation: Since,i so,test condition for i never satisfies it fails and hence infinite loop in occurs.

output: hi hi hi..
6. Select the output for following set of code :

static void Main(string[] args)

int i = 0;

if (i == 0)

goto label;

label: Console.WriteLine("HI...");

Console.ReadLine();

a) Hiinfinite times

b) Code runs printed nothing

c) Hi Hi

d) Hi

View Answer

Answer :d

Explanation : for i = 0 ,if condition is satisfied as (i == 0).So,label statement is printed.

Output : Hi

7. Select the output for following set of code :

static void Main(string[] args)

{
int i = 0, j = 0;

l1: while (i < 2)

i++;

while (j < 3)

Console.WriteLine("loop\n");

goto l1;

Console.ReadLine();

a) loop printed infinite times

b) loop

c) loop loop

d) Compile time error

View Answer

Answer :c.

Explanation : Since outer while loop i.e while(i<2) executes only for two times.Hence,loop while
executing third time for (j<3) could not

able to satisfy condition i<2 as i = 2.hence,loop breaks and control goes out of loop.

Output : loop loop.

8. Select output for following set of code :


static void Main(string[] args)

int i= 0,k;

label: Console.WriteLine(i);

if (i == 0)

goto label;

Console.ReadLine();

a) 0 0 0 0

b) 0 0 0

c) 0 infinite times

d) 0

View Answer

Answer :c.

Explanation:Since, if condition is always true.Loop will continue executing always without any end
condition.

Output:0 0 0.

9. Select the output for following set of code :

static void Main(string[] args)

int i = 0;

int j = 0;

for (i = 0; i < 4; i++)

{
for (j = 0; j < 3; j++)

if (i > 1)

continue;

Console.WriteLine("Hi \n");

Console.ReadLine();

a) Prints hi 4 times

b) Prints hi 3 times

c) Prints hi 6 times

d) Prints hi infinite times

View Answer

Answer:c.

Explanation : None.

Output : hi

hi

hi

hi

hi

hi.

10. Select the output for following set of code :


static void Main(string[] args)

int a = 0;

int i = 0;

int b;

for (i = 0; i < 5; i++)

a++;

Console.WriteLine("Hello \n");

continue;

Console.ReadLine();

a) print hello 4 times

b) print hello 3 times

c) print hello 5 times

d) print hello infinite times

View Answer

Answer :c

Explanation : Condition executes until and unless i < 5.So,it prints "hello" until 'i' condition is satisfied.

Output : Hello

Hello

Hello

Hello
Hello

11. Select the output for set of code:

static void Main(string[] args)

Console.WriteLine("HI");

continue;

Console.WriteLine("Hello");

Console.ReadLine();

a) Hi Hello

b) Hi

c) Hello

d) Compile time error

View Answer

Answer :d

Explanation: Absence of any loop condition in order to make decision of break or continue.

1. Select output for following set of 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

View Answer

Answer: a

Explanation : An Object reference is required for non static field,method or property.


i.e sample s = new sample();

s.i = 10;

sample.fun(1, 5);

sample.fun(1, 5);

Console.ReadLine();

2. Select which is used to define the member of a class externally?

a) :

b) ::

c) #

d) none of the mentioned

View Answer

Answer: b

Explanation: By definition.

3. The operator used to access member function of a class?

a) :

b) ::

c) .

d) #

View Answer

Answer: c

Explanation : objectname.function name(actual arguments);

4. What is most specified using class declaration ?

a) type
b) scope

c) type & scope

d) None of mentioned

View Answer

Answer: c

Explanation : General form of class declaration in C# is :

class class_name

member variables

variable1;

variable2;

variableN;

method1(parameter_list)

method body

method2(parameter_list)

method body

methodN(parameter_list)

method body

}
}

5. Select the output for following set of 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) Run successfully but prints nothing

View Answer

Answer: c

Explanation:Variable i and j declared with scope public in sample class are accessed using object of
class sample which is s.

Output:1 2.

6. Which of 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) None of the mentioned

View Answer

Answer: a, b, c

Explanation : By definition.

7. 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 the
access to that particular code and

data.

a) Abstraction
b) Polymorphism

c) Inheritance

d) Encapsulation

View Answer

Answer: d

Explanation : By definition.

8. Select the output for following set of 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

View Answer

Answer: c

Output : 10 20

5 125.

Explanation:Member fucntion() set is accessed using object of class z values are passed as parameter
to a and b.Since, variable c1

and c2 are public data member of class z.They are accessed using classname.

9. Correct way of declaration of object of following class is ?


class name

a) name n = new name();

b) n = name();

c) name n = name();

d) n = new name();

View Answer

Answer: a

Explanation:None.

10. The data members of a class by default are ?

a) protected,public

b) private,public

c) private

d) public

View Answer

Answer: c

Explanation:None.

11. Select the output for following set of 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

View Answer

Answer: c

Explanation: Member function show() accessed using object of class z which is n as object.member().

Output : harsh is in new delhi.

12. What do the following code implies ?


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 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

View Answer

Answer: c

Explanation:None.

13. The output of code is ?

class test

public void print()

Console.WriteLine("Csharp:");

class Program

static void Main(string[] args)

test t;

t.print();
Console.ReadLine();

a) Code run successfully print nothing

b) Code run and print Csharp

c) Syntax error as t is unassigned variable which is never used

d) None of above mentioned

View Answer

Answer: c

Explanation: object of class test should be declared as test t = new test();

test t = new test();

t.print();

Console.ReadLine();

1. Which refrence modifier is used to define reference variable?

a) &

b) ref

c) #

d) $

View Answer

Answer :b.

Explanation : None.
2. Select output for following set of 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

View Answer

Answer :d.

Explanation:Here a = 5 .Copy of variable is passed as reference to parameter a.

Output: 25.

3. Select the output for following set of 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.

View Answer

Answer :a

Explanation: array arr after deceleration passed as reference parameter.

a[0] = 1 + 5 = 6.

a[1] = 2 + 5 = 7.

.
a[4] = 5 + 5 = 10.

Output : 15 17 8 29 20.

4. Select the output for following set of 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

View Answer

Answer :b

Explanation : Made use of call by reference parameter.

Output:Result before swap is: 10 20.

Result after swap is:20 10.

5. Select output for set of 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

View Answer

Answer :b

Explanation:Those numbers divisible by 2 are 2,4,6,8,10 and when condition of loop is executed it
increments by 1.

i.e for x[1] = 2%2 == 0.So, x[1] = 2 + 1 =3.

x[3] = 4%2 == 0.So, x[3] = 4 + 1 =5 and so on.

Output : 3 5 7 9 11.

6. Select correct statement about ref keyword in C#?

a) References can be called recursively

b) The ref keyword causes arguements to be passed by reference

c) When ref are used any changes made to parameters in method will be refelected in variable when
control passed back to calling method

d) All of above mentioned

View Answer

Answer: b ,c

Explanation: None.

7. Select correct difference between = and == in C#.


a) == operator used to assign values from one variable to another variable

= operator used to compare value between two variables

b) = operator used to assign values from one variable to another variable

== operator used to compare value between two variables

c) No difference between both operators

d) None of the mentioned

View Answer

Answer :b.

Explanation : None.

8. Select correct output for following set of 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


View Answer

Answer :b.

Explanation:The operator = used is not comparison operator it is assignment operator.Since value


assigned to X = 0.

So,0 value is stored in X and with if condition implementation it is converted to false which directly
means It is not zero but 1

which means true.

9. Select the output for following set of 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

View Answer

Answer : c.

Explanation: X*=X/Y.

X=x*(X/Y).
Output: 18.

10. Select the ouput for following set of 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) None of mentioned

View Answer

Answer :c.

Explanation: x = x b and b = b/(x*b).

Output: 4 0

11. What is output for following set of expression?

int a+= (float) b/= (long)c.

a) float

b) int

c) long

d) None of the mentioned


View Answer

Answer :b

Explanation: None.

12. Select the output for following set of 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

View Answer

Answer :d.

Explanation: Exception handling error of dividing by zero.

13. Select the output for following set of 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

View Answer

Answer:c.

Output: 32 2 8.

Explanation: x / = b / =C is x = x * c /b.

1. What is the output of following set of 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

View Answer

Answer: b.

Explanation: The value of variable a is passed by value while value of variable s and c is passed by
reference.

Output: 25 125.

2. Which of following statements are correct about functions?

a) C# allows a function to have arguements with default values

b) Redefining a method parameter in the methods 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

View Answer
Answer: a.

Explanation: None.

3. What is output of the 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

View Answer
Answer: c

Explanation: First Mul() will be executed to print the number 4 after that function m() will be executed
to print the number 3 and at last

mentioned function Mul() will be executed to print the statement 4 to return the output as 4 3 4.

Output: 4 3 4.

4. What is the output of the 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

View Answer

Answer: c
Explanation: Control of statement when enters for once in m() donot go out then it executes again and
again inside the block until stack

overflow exception occurs.

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

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)

View Answer

Answer: b

Explanation: Correct way of declaration of function is defined as return_type name of


function(returntype).
6. What is the output for following set of 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.00

c) 10

35.78

d) None of the mentioned

View Answer

Answer: c
Explanation: int datatype is sub datatype of double.Hence, when first part of func() is executed it is
integer part and hence when

second part is executed it is double.

Output:10

35.78

7. How many values does a function returns?

a) 0

b) 2

c) 1

d) any number of values

View Answer

Answer: c

Explanation:a method can return only either single value or no value if no then its declared as void
method();

8. Output for following set of 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.

View Answer

Answer: c

Explanation: if loop never gets over it will executed continuously the control never goes out of if
statement.

Output: hi

hi

stack overflow exception

9. 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 mentioned

View Answer

Answer: a.

Explanation: The correct syntax of return statement is defined within block of statements as {
return(statement);}.

10. What is output for selective 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

View Answer

Answer: a

Explanation: invalid definition of function p() inside main().


1. Number of constructors a class can define of ?

a) 1

b) 2

c) Any number

d) None of the mentioned

View Answer

Answer: c

Explanation: A constructor is a simple method which has the same name as the class and hence used to
create object of a class. C# class can

define any number of constructors. Every class contains a default constructor.

2. Correct way of defining constructor of the given class as if objects of classes are created as:

maths s1 = new maths();

maths s2 = new maths(5, 5.4f);

a) public maths(int pp, single tt)

p = pp;

t = tt;

b) sample s;

c) public sample()

{
p = 0;

t = 0.0f;

public sample(int pp, single tt)

p = pp;

t = tt;

d) s = new sample();

View Answer

Answer: a.

Explanation: None.

3. Correct way to define object of sample class with which 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);

View Answer

Answer: d.

Explanation: return types of parameters of object of class matches with defined constructor arguments
types.

4. Correct statement about constructors in C#.NET is ?

a) Constructor cannot be overloaded

b) Constructor allocate space for object in memory

c) Constructor are never called explicitly

d) Constructor have same name as name of the class

View Answer

Answer: d, c

Explanation: None.

5. For following set of code is correct set of statement is :

Constructors are used to

a) initialize the objects

b) construct the data members

c) both a & b

d) None of the mentioned

View Answer

Answer: a
Explanation: Once the object is declared means, the constructor are also declared by default.

6. Can the method add() be overloaded in the following ways in C#?

public int add() { }

public float add(){ }

a) True

b) False

c) None of the mentioned.

View Answer

Answer: b

Explanation:C# provides feature of method overloading which means methods with same name but
different types and arguments.

7. 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

View Answer

Answer: c

Explanation: Static constructor is a constructor which can be called before any object of class is created
or any static method is

invoked.Static constructor implicitly called by .net CLR.

8. What is output of following section of 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.

View Answer

Answer: b.

Explanation: The class abc first calls method()a then object of class k when calls method b .First of
all, the method a will be

executed and hence then executes second statement.

Output :first method

20

first method

second method

9. What is return type of constructors?

a) int
b) float

c) void

d) None of the mentioned

View Answer

Answer: d

Explanation: Constructors do not have any return type not even void included in it.

10. Which method have same name as that of its class?

a) delete

b) class

c) constructor

d) None of mentioned

View Answer

Answer: c

Explanation: By definition.

1. Which operator among following signifies the destructor operator?

a) ::

b) :

c) ~

d) &.

View Answer
Answer :c

Explanation : None.

2. A 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()

View Answer

Answer :c

Explanation: Dispose() is only method called by clients of a class to explicitly release any resource like
network connection,open files

etc.when object is no longer required.Hence,Dispose() provides programmer with such programming


control.

3. Name a method same name as that of class 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

View Answer
Answer :c

Explanation: Definition of destructor.

4. Which of the following statements are correct?

a) There is one garbage collector per program running in memory

b) There is one comman garbage collector for all programs

c) To garbage collect an object set all references to it to null

d) We have to specify run the garbage collector after executing VISUAL STUDIO.NET

View Answer

Answer :b, c.

Explanation :None.

5. Operator used to free the memory when memory is allocated ?

a) new

b) free

c) delete

d) None of the mentioned

View Answer

Answer :c

Explanation: New is used to allocate memory in the constructors.Hence,we should use delete to free
that memory.

6. Select correct 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 above mentioned


View Answer

Answer :a, b

Explanation : None.

7. Output from following set of 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

View Answer

Answer :d

Explanation: First constructor sample is called and hence then destructor ~sample is evaluated.

Output : 10.5, 5.5

8. What is return type of destructor ?

a) int

b) void

c) float

d) None of the mentioned.

View Answer

Answer :d

Explanation: Destructors donot have any return type not even void.

9. What is output for following set of 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

View Answer

Answer: c

Explanation : We cannot use anykind of modifier with destructor.

10. Output from selective set of code is :

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 execute successfully but print nothing

c) Compile time error

d) 180

View Answer

Answer :d

Explanation:None.

Output: 180.
1. What is output of following set of code ?
1. static void Main(string[] args)
2. {
3. int i, j;
4. int[, ] arr = new int[ 3, 3];
5. for (i = 0; i < 3; ++i)
6. {
7. for (j = 0; j < 3; ++j)
8. {
9. arr[i, j] = i * 2 + i * 2;
10. Console.WriteLine(arr[i, j]);
11. }
12. Console.ReadLine();
13. }
14. }
a) 0,0,0 4,4,4 8,8,8
b) 4,4,4 8,8,8 12,12,12
c) 8,8,8 12,12,12 16,16,16
d) 0,0,0 1,1,1, 2,2,2
View Answer
Answer :a.
Explanation: Since,with each value of of i the value of j is executed three times i.e
for i = 0, j = 0, 0, 0, i = 1, j = 2, 2, 2.
Output: 0, 0, 0 4, 4, 4 8, 8, 8.
2. What is output for following set of code?
1. static void Main(string[] args)
2. {
3. char A = 'K';
4. char B = Convert.ToChar(76);
5. A++;
6. B++;
7. Console.WriteLine(A+ " " +B);
8. Console.ReadLine();
9. }
a) M L
b) U L
c) L M
d) A B
View Answer
Answer :c.
Explanation: ++ increments the value of character by 1. A and B are given values K and 76, when
we use increment operator their values increments by 1, A and B becomes L and M.
Output: L, M.
3. Complete following set of code with foreach condition:
1. int[][]a = new int[2][];
2. a[0] = new int[3]{3, 4, 2};
3. a[1] = new int[2]{8, 5};
4. foreach( int[]i in a)
5. {
6. /* add for loop */
7. console.write( j+ " ");
8. console.writeline();
9. }
(a) foreach (int j = 1;(j(<)(a(0).GetUpperBound)); (j++));
(b) foreach (int j = 1;(j(<)(a.GetUpperBound(0))); (j++));
(c) foreach (int j in a.Length);
(d) foreach (int j in i);
View Answer
Answer :d
Explanation : None.
4. What is output for following set of code ?
1. static void Main(string[] args)
2. {
3. double a = 345.09;
4. byte c = (byte) a;
5. Console.WriteLine(c);
6. Console.ReadLine();
7. }
a) 98
b) 89
c) 88
d) 84
View Answer
Answer :b.
Explanation:Type casting a larger variable into a smaller variable results in modules of larger
variable by range of smaller variable. a is 345.09 which is larger than bytes range i:e -128 to 127.
Output : 89.
5. Which statement is correct about following c#.NET code ?
int[] a= {11, 3, 5, 9, 6};
a)a is reference to the array created on stack
b)a is a reference to an object created on stack
c)a is a reference to an object of a class that compiler drives from
System.Array class
d) None of the mentioned
View Answer
Answer :c.
Explanation: A perfect of defining single array in C# which derived from automatically class
System.Array.
6. What is advantage of using 2D jagged array over 2D rectangular array?
a) Easy intialization of elements
b) Allow unlimited elements as well as also rows which had 0 or are empty in
nature
c) All of the mentioned
d) None of the mentioned
View Answer
Answer: b.
Explanation: In many applications where 2 dimensional arrays are used,not all rows need to have all
the elements i.e they are sparse.Many rows have 0 elements.In such cases its better to use 2D
jagged arrays as they allow unequal number of elements in each row and also allow for empty rows.
7. Which statement is correct about following set of code ?
int[, ]a={{5, 4, 3},{9, 2, 6}};
a)a represents 1-D array of 5 integers
b) a.GetUpperBound(0) gives 9
c)a represents rectangular array of 2 columns and 3 arrays
d) a.GetUpperBound(1) gives 2
View Answer
Answer: c, d.
Explanation: By definition.
8. What is output of following set of code?
1. static void Main(string[] args)
2. {
3. Program p = new Program();
4. p.display(2, 3, 8);
5. int []a = { 2, 56, 78, 66 };
6. Console.WriteLine("example of array");
7. Console.WriteLine("elements added are");
8. p.display(a);
9. Console.ReadLine();
10. }
11. public void display(params int[] b)
12. {
13. foreach (int i in b)
14. {
15. Console.WriteLine("ARRAY IS HAVING:{0}", i);
16. }
17. }
a) Compile time error
b) Run time error
c) Code runs successfully but prints nothing
d) Code runs successfully and prints given on console
View Answer
Answer :d
Explanation: Object p makes a call to invoke function display() and hence consecutively prints the
output. Array a is declared with elements again object p makes a call to display() and hence,
consecutively prints the output with given elements.
Output: ARRAY IS HAVING:2
ARRAY IS HAVING:3
ARRAY IS HAVING:8
elements added are:
ARRAY IS HAVING:2
ARRAY IS HAVING:56
ARRAY IS HAVING:78
ARRAY IS HAVING:66
9. Which is correct way of defining and initialize an array of 3 integers?
a) int[] a={78, 9, 54};
b) int[] a;
a = new int[3];
a[1] = 78;
a[2] = 9;
a[3] = 54;
c) int[] a;
a = new int{78, 9, 54};
d) int[] a;
a = new int[3]{78, 9, 54};
View Answer
Answer :a, d
Explanation : None.
10. Choose selective difference between array in c# and array in other
programming languages.
a) Declaring array in C# the square bracket([]) comes after the type but not after
identifier
b) It is not necessary to declare size of an array with its type
c) No, difference between declartion of array in c# as well as as in other
programming languages
d) All of the above mentioned
e) None of above mentioned
View Answer
Answer :a, b.
Explanation:
1. When declaring an array in C#, the square brackets ([]) come after the type, not the identifier
brackets after the identifier is
not legal syntax in C#.
example : int[] IntegerArray;
2. The size of the array is not part of its type as it is in the C language. This allows to declare an
array and assign any array
of int objects to it, regardless of the arrays length.
int[] IntegerArray;
IntegerArray = new int[10];
IntegerArray = new int[50];

1. Which of the following string() method are used to compare two strings with
each other?
a) CopyTo()
b) Copy()
c) Compare()
d) CompareTo()
View Answer
Answer: b
Explanation: Create a new string by copying one string to another.
2. Choose the base class for string() method :
a) System.Array
b) System.char
c) System.String
d) None of the mentioned
View Answer
Answer: c
Explanation: String is an alias for the predefined System.string class from which most of the string()
methods are derived.
3. What is output of for following set of code:
1. static void Main(string[] args)
2. {
3. string s1 = " Cshr ";
4. string s2 = s1.Insert(3 , " a ");
5. string s3 = s2.Insert(5 , " p ");
6. for (int i = 0;i < s3.Length; i++)
7. Console.WriteLine(s3[i]);
8. Console.ReadLine();
9. }
a) Cshar
b) CsharP
c) Csharp
d) Cshrap
View Answer
Answer: c
Explanation: Insertion of character a at postion 3 using insert() which returns a new string with a
substring inserted at a specified location.
Output: Csharp
4. Which of the following statement is correct about a string in C#.NET?
a) The System.Array class is used to represent a string
b) A string has a zero-based index
c) A number cannot be represented in the form of a string
d) A string is mutable because it can be modified once it has been created
View Answer
Answer: b
Explanation: None.
5. What is output of for following set of code?
1. static void Main(string[] args)
2. {
3. string s1 = "Hello";
4. string s2 = "hello";
5. if (s1 == s2)
6. Console.WriteLine("Equal");
7. else
8. Console.WriteLine("Unequal");
9. if (s1.Equals (s2))
10. Console.WriteLine("Equal");
11. else
12. Console.WriteLine("Unequal");
13. Console.ReadLine();
14. }
a) Equal
Unequal
b) Unequal
Equal
c) Equal
Equal
d) Unequal
Unequal
View Answer
Answer: d
Explanation:In first comparison it is being checked either two strings are equal or not but in second
comparison it is checked whether two references are equal or not.
Output: Unequal
Unequal
6. Choose Output for following set of code :
1. static void Main(string[] args)
2. {
3. string s1 = "Hello" + " I " + "Love" + " ComputerScience ";
4. Console.WriteLine(s1);
5. Console.ReadLine();
6. }
a) HelloILoveComputerScience
b) Hello I Love ComputerScience
c) Compile time error
d) Hello
View Answer
Answer: b
Explanation: Here + defined operator works as concatenation for strings.
Output : Hello I Love ComputerScience.
7. Correct way to find if contents of two strings are equal or not?
a) if (s1 = s2)
b) if (s1 == s2)
c) if (strcmp (s1 ,s2))
d) if ( s1 is s2)
View Answer
Answer: b , c
Explanation: == operator used to compare length of two strings and strcmp() inbuilt method derived
from string class.
8. Which of the following statements are correct?
a) String is value type
b) String literals can contain any character literal including escape sequences
c) The equality operators are defined to compare values of string objects as well
as references
d) All of the mentioned
View Answer
Answer: b
Explanation: None
9. Which of these operators can be used to concatenate two or more String
objects?
a) +
b) +=
c) &
d) ||
View Answer
Answer: a
Explanation: string s1 = Hello+ I + Love + ComputerScience ;
Console.WriteLine(s1);
Hello I Love ComputerScience.
10. Method use to remove white space from string?
a) Split()
b) Substring()
c) Trim()
d) TrimStart()
View Answer
Answer: c
Explanation: Perfectly removes a whitespace from string whereas TrimStart() removes a string of
characters from the end of the string.

1. What is String in C# meant for?


a) Variable
b) Character Array
c) Object
d) Class
View Answer
Answer: c
Explanation: C# Support a predefined reference type known as string.When we declare a string
using string type hence we are declaring the object to be of type System.String.
2. What does the term immutable means in term of string objects?
a) We can modify characters included in the string
b) We cannot modify characters contained in the string
c) We cannot perform various operation of comparison,inserting,appending etc
d) None of the mentioned
View Answer
Answer: b
Explanation: String objects are immutable it means we cannot modify the characters contained in
string also operation on string produce a modified version of string rather then modifying characters
of string.
3. To perform comparison operation on strings supported operations are :
a) Compare().
b) Equals().
c) Assignment == operator.
d) None of the mentioned.
View Answer
Answer: a, b, c
Explanation: None.
4. What will be output of following set of code :
1. static void Main(string[] args)
2. {
3. string s1 = "Hello I Love Csharp ";
4. Console.WriteLine(Convert.ToChar( (s1.IndexOf('I') - s1.IndexOf('l')) * s1.Inde
xOf('p'));
5. Console.ReadLine();
6. }
a) I
b) Hello I
c) Love
d) H
View Answer
Answer: d
Explanation: I = index position[6] ,l = index position[2].So, I l = 6-2= 4*(index position of p = 18) =
72. Character with ASCII Value 72 = H.
Output : H
5. Correct way to convert a string to uppercase using string class method()?
a) Upper()
b) ToUpper()
c) Object.ToUpper()
d) None of the mentioned
View Answer
Answer: c
Explanation: string s1 = Hello I Love Csharp ;
Console.WriteLine(s1.ToUpper());
Output: HELLO I LOVE CSHARP.
6. What would be the output for following set of code?
1. static void Main(string[] args)
2. {
3. String obj = "hello";
4. String obj1 = "world";
5. String obj2 = obj;
6. Console.WriteLine (obj.Equals(obj2) + " " + obj2.CompareTo(obj) );
7. Console.ReadLine();
8. }
a) True True
b) False False
c) True 0
d) False 1
View Answer
Answer: c
Explanation: Equal() checks that are two string objects obj and obj2 are equal or not and hence
returns true or false.Similarly, CompareTo operator check two objects and since string obj2 = obj,it
returns bool value 0. Hence,they are equal.
Output : True 0
7. What would be the output for code below?
1. static void Main(string[] args)
2. {
3. String obj = "hello";
4. String obj1 = "world";
5. String obj2 = obj;
6. Console.WriteLine(obj + " " + obj1);
7. string s = obj + " " + obj1;
8. Console.WriteLine(s.Length);
9. Console.ReadLine();
10. }
a) hello world
10
b) hello world
6
c) hello world
11
d) hello world
5
View Answer
Answer: c
Explanation: Length() method calculates number of characters in a string . Obj2 assume value of
object obj in itself.
Output: hello world
11
8. What is output for following set of Code?
1. static void Main(string[] args)
2. {
3. String obj = "hello";
4. String obj1 = "world";
5. String obj2 = obj;
6. string s = obj+" "+obj1;
7. Console.WriteLine(s.IndexOf('r'));
8. Console.ReadLine();
9. }
a) 7
b) 8
c) 9
d) 10
View Answer
Answer: b
Explanation: IndexOf() used to find absolute position of a character of substring.
Output: 8
9. What is output for set of code?
1. static void Main(string[] args)
2. {
3. String obj = "hello";
4. String obj1 = "world";
5. String obj2 = obj;
6. string s = obj + " " + obj1;
7. Console.WriteLine(s.Substring(6 ,5));
8. Console.ReadLine();
9. }
a) hello
b) orld
c) world
d) o world
View Answer
Answer: c
Explanation: Substring() extract substrings from a given string using overloaded substring() method
provided by string class.
Output: world
10. What will be the output for set of given code?
1. static void Main(string[] args)
2. {
3. String obj = "hello";
4. String obj1 = "worn";
5. String obj2 = obj;
6. Console.WriteLine(obj + " " + (obj1.Replace('w' ,'c')));
7. Console.ReadLine();
8. }
a) hello hello
b) hello worn
c) hello corn
d) hello
View Answer
Answer: c
Explanation: Replace() method provided by string builder class used to replace characters.
Output: hello corn

1. Which of these method of class String is used to compare two String objects
for their equality?
a) equals()
b) Equals()
c) isequal()
d) Isequal()
View Answer
Answer: a
Explanation : None.
2. Which of these method is used to compare two string such that after
comparison output returns different integer values as ( 0 for false, 1 for true)?
a) Equals ()
b) == operator
c) Compare()
d) None of the mentioned
View Answer
Answer: c
Explanation: The comparison is case sensitive in nature and hence different integer values are
return for different conditions as under :
1. zero integer (0), if string s1 equal to string s2.
2. positive integer(+1) , if string s1 greater than s2.
3. Negative integer(-1) , if string s1 is less than s2.
3. Which of these method of class String is used to check weather a substring
exists at beginning of the particular string?
a) StartsWith()
b) EndsWith()
c) Starts()
d) ends()
View Answer
Answer: a
Explanation : Method startswith() of string class used to check that whether a substring exists in the
beginning of string or not.
4. Which method returns the string such that some characters which are
specified to be removed from the end of strings are removed from string by
mentioning number of characters to be removed?
a) Trim()
b) Remove()
c) TrimEnd()
d) Split()
View Answer
Answer: a
Explanation : Remove a string of characters from the end of string by mentioning number of
characters to be removed from the string.
5. What is the value returned by function compareTo() if the invoking string is
less than the string compared?
a) zero
b) value less than zero
c) value greater than zero
d) None of the mentioned
View Answer
Answer: b
Explanation : compareTo() function returns zero when both the strings are equal, it returns a value
less than zero if the invoking string is less than the other string being compared and value greater
than zero when invoking string is greater than the string compared to.
6. Which of these data type value is returned by equals() method of String class?
a) char
b) int
c) boolean
d) All of the mentioned
View Answer
Answer: c
Explanation : equals() method of string class returns boolean value true if both the string are equal
and false if they are unequal.
7. What is output of the given set of Code?
1. class Program
2. {
3. static void Main(string[] args)
4. {
5. String c = "i love Csharp";
6. bool a;
7. a = c.StartsWith("I");
8. Console.WriteLine(a);
9. Console.ReadLine();
10. }
11. }
a) true
b) false
c) 0
d) 1
View Answer
Answer: b
Explanation: StartsWith() method is case sensitive i and I are treated differently, hence false is
stored in a.
Output: false
8. What is output of the given set of Code?
1. class Program
2. {
3. static void Main(string[] args)
4. {
5. String s1 = "I love You";
6. String s2 = s1;
7. Console.WriteLine((s1 == s2) + " " + s1.Equals(s2));
8. Console.ReadLine();
9. }
10. }
a) true true
b) false false
c) true false
d) false true
View Answer
Answer: a
Explanation : The == operator tests the equality of strings and since s1 = I love You and also s2 =
s1 .So, true is returned Similarly,Equals() returns true
as content of both s1 and s2 are equal in nature.
Output : true true
9. What is output of the given set of Code?
1. class Program
2. {
3. static void Main(string[] args)
4. {
5. String []chars = {"z", "x", "y", "z", "y"};
6. for (int i = 0; i < chars.Length; ++i)
7. for (int j = i + 1; j < chars.Length; ++j)
8. if(chars[i].CompareTo(chars[j]) == 0)
9. Console.WriteLine(chars[j]);
10. Console.ReadLine();
11. }
12. }
a) zx
b) xy
c) zy
d) yz
View Answer
Answer: c
Explanation : compareTo() function returns zero when both the strings are equal, it returns a value
less than zero if the invoking string is less than the other string being compared and value greater
than zero when invoking string is greater than the string compared To.4
Output : z
y
10. What will be the output for given set of code ?
1. String a = "Csharp";
2. String b = "CSHARP";
3. int c;
4. c = a.CompareTo(b);
5. Console.WriteLine(c);
a) 0
b) 1
c) -2
d) -1
View Answer
Answer: d
Explanation : Negative integer -1 returned as a is less than b by CompareTo() method.
Output : -1

1. Which of these method of class String is used to seperate a substring from a


String object?
a) substring()
b) Substring()
c) SubString()
d) None of the mentioned
View Answer
Answer: b
Explanation : None.
2. What will be the output for given set of code?
1. static void Main(string[] args)
2. {
3. String a = "Ilove";
4. String b = "CSHARP";
5. b = string.Concat(a, ' ', b);
6. Console.WriteLine(b);
7. Console.ReadLine();
8. }
a) IloveCSHARP
b) I loveCSHARP
c) Ilove
d) Ilove CSHARP
View Answer
Answer: d
Explanation : Concat() method used to join two strings without use of + operator .
Output : Ilove CSHARP
3. Which of the method of class used to remove the leading and backward
whitespaces?
a) startsWith()
b) trim()
c) Trim()
d) doTrim()
View Answer
Answer: c
Explanation : None.
4. What will be the output for set of code?
1. static void Main(string[] args)
2. {
3. String a = "Ilove";
4. String b = "CSHARP";
5. b = string.Concat(a,' ',b);
6. string d = b.TrimStart('I', 'l', 'o', 'H');
7. Console.WriteLine(d);
8. Console.ReadLine();
9. }
a) Ilove CSHARP
b) love CSHARP
c) ve CSHARP
d) ve CSARP
View Answer
Answer: c
Explanation : trimstart() removes character mentioned consecutively in front positions not characters
in mentioned in between positions.
Output : ve CSHARP
5. What will be the output for set of code?
1. static void Main(string[] args)
2. {
3. String c = " Hello Computer ";
4. String a = c.Trim();
5. Console.WriteLine("\"" + s + "\"");
6. }
a) Hello Computer
b) HelloComputer
c) Hello Computer
d) Hello Computer
View Answer
Answer: c
Explanation : Trim() method used to remove forward and backward spaces in strings.
Output : Hello Computer
6. What will be the output for given set of code?
1. static void Main(string[] args)
2. {
3. String c = "Hello";
4. String a = c + "Bye";
5. Console.WriteLine(a);
6. Console.ReadLine();
7. }
a) Hello Bye
b) HelloBye
c) Hello Bye
d) HelloBye
View Answer
Answer: d
Explanation : + operator method works in the form of concatenate method() and hence used to join
two strings together.
Output : HelloBye
7. What will be the output for given set of code?
1. static void Main(string[] args)
2. {
3. String c = "Hello";
4. String a ;
5. a = c.Replace('l', 'w');
6. Console.WriteLine(a);
7. Console.ReadLine();
8. }
a) Helloll
b) Hewlo
c) Helwo
d) Hewwo
View Answer
Answer: d
Explanation : None.
Output : Hewwo
8. Which of the following statement is correct?
a) replace() replace() method replaces last occurrence of a character in invoking
string with another character
b) replace() method replaces only first occurances of a character in invoking
string with another character
c) replace() method replaces all occurrences of one character in invoking string
with another character
d) None of the mentioned
View Answer
Answer: c
Explanation : By definition.
9. What will be the output of given code snippet?
1. static void Main(string[] args)
2. {
3. String c = "Hello i love you";
4. String a ;
5. a = c.Substring(12, 3);
6. Console.WriteLine(a);
7. Console.ReadLine();
8. }
a) ove
b) you
c) yo
d) love you
View Answer
Answer: c
Explanation : None.
Output : yo
10. Which among the following is the correct way to find out the index of second
s in the string She sold her beauty in one night to someone else?
a) String a = She sold her beauty in one night to someone else;
int i;
i = a.SecondIndexOf(s);
b) String a = She sold her beauty in one night to someone else;
int i, j;
i = a.FirstIndexOf(s);
j = a.IndexOf(s, i + 1);
c) String a = She sold her beauty in one night to someone else;
int i, j;
i = a.IndexOf(s);
j = a.IndexOf(s, i + 1);
d) None of the mentioned
View Answer
Answer: c
Explanation : static void Main(string[] args)
{
String c = She sold her beauty in one night to someone else;
int i,j;
i = c.IndexOf(s);
j = c.IndexOf(s, i + 1);
Console.WriteLine(i + + j);
Console.ReadLine();
}
Output : 4, 36

1. Which of these method of class String is used to obtain length of String object?
a) get()
b) Sizeof()
c) lengthof()
d) length()
View Answer
Answer: d
Explanation: Method length() of string class is used to get the length of the object as string.Length
and hence invoke length() method.
2. Which of these methods is an alternative to getChars() that stores the
characters in an array of bytes?
a) getBytes()
b) GetByte()
c) giveByte()
d) Give Bytes()
View Answer
Answer: a
Explanation : getBytes() stores the character in an array of bytes. It uses default character to byte
conversions.
3. Which of these methods can be used to convert all characters in a String into a
character array?
a) CharAt()
b) getChars()
c) TocharArray()
d) All of the mentioned
View Answer
Answer: c
Explanation: None.
4. What will be the output of given code snippet?
1. static void main(String args[])
2. {
3. char chars[] = {'x', 'y', 'z'};
4. String s = new String(chars);
5. Console.WriteLine(s);
6. }
a) x
b) xy
c) z
d) xyz
View Answer
Answer: d
Explanation : String(chars) is a constructor of class string, it initializes string s with the values stored
in character array chars, therefore s contains xyz.
Output yz
5. Choose the effective stringBuilder method which helps in producing given
output for give code?
1. static void Main(string[] args)
2. {
3. StringBuilder s = new StringBuilder("object");
4. s./*______*/("Oriented Language");
5. Console.WriteLine(s);
6. Console.ReadLine();
7. }
8. Output : objectOriented Language
a) Insert()
b) Add()
c) Append()
d) Join()
View Answer
Answer: c
Explanation : static void Main(string[] args)
{
StringBuilder s = new StringBuilder(object);
s.Append(Oriented Language);
Console.WriteLine(s);
Console.ReadLine();
}
Output : objectOriented Language
6. What will be the output for the given code snippet?
1. static void Main(string[] args)
2. {
3. string s = " i love you";
4. Console.WriteLine(s.IndexOf('l') + " " + s.lastIndexOf('o') + " " + s.IndexO
f('e'));
5. Console.ReadLine();
6. }
a) 3 5 7
b) 4 5 6
c) 3 9 6
d) 2 4 6
View Answer
Answer: c
Explanation : indexof(l) and lastIndexof(o) are pre defined function which are used to get the index
of first and last occurrence of
the character pointed by l and c respectively in the given array.
Output : 3, 9, 6
7. Which of these method of class String is used to extract a all characters from a
String object?
a) CHARAT()
b) Remove()
c) charAt()
d) Replace()
View Answer
Answer: b
Explanation : Replace() replaces all instances of a character with a new character while Remove
extracts characters from the string.
8. What will be the output of given code snippet?
1. static void Main(string[] args)
2. {
3. string c = "hello";
4. string c1 = c.Remove(1);
5. Console.WriteLine(c1);
6. Console.ReadLine();
7. }
a) ello
b) h
c) hell
d) None of the mentioned
View Answer
Answer: b
Explanation : The remove() deletes characters from the string except the character which is
specified with its given position.
Output : h
9. How is a string typically processed?
a) On a character by character basis
b) On a string by string basis
c) Both a & b
d) None of the mentioned
View Answer
Answer: a
Explanation : None.
10. How to print \\ on the screen?
a) Console.WriteLine(\\);
b) Console.WriteLine(\\\);
c) Console.WriteLine(\\\\);
d) Console.WriteLine(\\\\\\);
View Answer
Answer: c
Explanation : Console.WriteLine(\\\\);
Output : \\

1. Which of these is used as default specifier for a member of class if no access


specifier is used for it?
a) private
b) public
c) public, within its own class
d) protected
View Answer
Answer :a
Explanation: By definition it is defined if a class has no access specifiers,it defaults to private
accessibility.
2. Which of these is used to access member of class before object of that class is
created?
a) public
b) private
c) static
d) protected
View Answer
Answer :c
Explanation: None.
3. Which of these base class are accessible to the derived class members?
a) static
b) protected
c) private
d) Shared
View Answer
Answer :b
Explanation: None.
4. What is the process by which we can control what parts of a program can
access the members of a class?
a) Polymorphism
b) Abstraction
c) Encapsulation
d) Recursion
View Answer
Answer :c
Explanation: By definition.
5. What will be the output of following set of code?
1. class sum
2. {
3. public int x;
4. private int y;
5. public void math(int a, int b)
6. {
7. x = a * 4;
8. y = b;
9. }
10. }
11. class Program
12. {
13. static void Main(string[] args)
14. {
15. sum p = new sum();
16. p.math(12, 30);
17. Console.WriteLine(p.x + " " + p.y);
18. Console.ReadLine();
19. }
20. }
a) 48, 30
b) 48, 0
c) 0, 0
d) Compile time error
View Answer
Answer :d
Explanation : variable y is not accessible due to its access level.
Output : Change private y to public y
6. What will be the output of following set of code?
1. class sum
2. {
3. public int x;
4. public int y;
5. public int add (int a, int b)
6. {
7. x = a + b;
8. y = x + b;
9. return 0;
10. }
11. }
12. class Program
13. {
14. static void Main(string[] args)
15. {
16. sum obj1 = new sum();
17. sum obj2 = new sum();
18. int a = 2;
19. obj1.add(a, a + 1);
20. obj2.add(5, a);
21. Console.WriteLine(obj1.x + " " + obj2.y);
22. Console.ReadLine();
23. }
24. }
a) 6, 9
b) 5, 9
c) 9, 10
d) 3, 2
View Answer
Answer :b
Explanation :Here, a = 2, a + 1 = 2 + 1 = 3.
So, a = 2, b = 3.
x = 2 + 3 = 5.
y = 5 + 3 = 8.
Similarly, a = 5, b = a + 1 = 4.
y = 5 + 4 = 9.
Output : 5, 9.
7. What will be the output of code?
1. class math
2. {
3. public int a,b;
4. public math(int i, int j)
5. {
6. a = i;
7. b = j;
8. }
9. public void sum(math m)
10. {
11. m.a *= 2;
12. m.b += 2;
13. }
14. }
15. class Program
16. {
17. static void Main(string[] args)
18. {
19. math t = new math(20, 10);
20. t.sum(t);
21. Console.WriteLine(t.a + " " + t.b);
22. Console.ReadLine();
23. }
24. }
a) 10, 20
b) 20, 10
c) 40, 12
d) 5, 40
View Answer
Answer :c
Explanation: t.sum(t) sends object t as parameter whose variables a & b are multiplied and added
by 2 respectively by sum() function of class math.Hence, a & b becomes 40 and 12 respectively.
Output : 40, 12
8. Accessibility modifier defined in a class are?
a) public, private, protected
b) public, internal, protected internal.
c) public, private, internal, protected internal.
d) public, private, protected, internal, protected internal
View Answer
Answer :d
Explanation: None.
9. Choose statements which are true in nature:
a) The base class member functions can access public member functions of
derived class
b) An object of a derived class cannot access private member of the base class
c) Private members of base class cannot accessed by derived class member
functions or objects of derived class
d) None of the mentioned
View Answer
Answer : b, c
Explanation: None.
10. Which of these access specifiers must be used for main() method?
a) private
b) public
c) protected
d) None of the mentioned
View Answer
Answer :a
Explanation: By default main() is declared private if no other access specifier is used for it.

1. What is output for following code snippet?


1. class Program
2. {
3. static void Main(string[] args)
4. {
5. int i = 5;
6. int j;
7. method1(ref i);
8. method2(out j);
9. Console.writeline(i + " " + j);
10. }
11. static void method1(ref int x)
12. {
13. x = x + x;
14. }
15. static void method2(out int x)
16. {
17. x = 6;
18. x = x * x;
19. }
20. }
a) 36, 10
b) 10, 36
c) 0, 0
d) 36, 0
View Answer
Answer :b
Explanation :variable i is passed as reference parameter declared with ref modifier and variable j
is passed as a output parameter declared with out keyword .Reference parameter used to pass
value by reference same is case with out parameter.
Output : 10, 36
2. Statements about ref keyword used in C#.NET are?
a) The ref keyword causes arguements to be passed by reference
b) While using ref keyword any changes made to the parameter in the method
will be reflected in the variable when control passed back to the calling method
c) No,change reflected back to variable if made any to the parameter when
control passed back to calling method
d) Ref usage eliminates overhead of copying large data items
View Answer
Answer :a, b, d
Explanation : None.
3. What will be the output for given set of code?
1. static void main(string[] args)
2. {
3. int n = 1;
4. method(n);
5. console.Writeline(n);
6. method1(ref n);
7. console.Writeline(n);
8. }
9. static void method(int num)
10. {
11. num += 20;
12. console.writeline(num);
13. }
14. static void method1(ref int num)
15. {
16. num += 20;
17. console.writeline(num);
18. }
a) 1
1
1
1
b) 21
1
21
21
c) 11
21
21
11
d) 21
1
21
21
View Answer
Answer :d
Explanation : None.
Output :21 1 21 21
4. Which method does following set of code explains?
1. static void Main(string[] args)
2. {
3. int a = 10, b = 20;
4. method(ref a, ref b);
5. console.writeline(a + " " + b);
6. }
7. static void swap(ref int i, ref int j)
8. {
9. int t;
10. t = i;
11. i = j;
12. j = t;
13. }
a) Call by reference
b) Call by value
c) Output parameter
d) parameter arrays
View Answer
Answer :a
Explanation :The following set of code explains swapping of numbers by reference parameters
which makes usage of call by reference process.
5. What will be the output for given set of code?
1. static void main(string[] args)
2. {
3. int []arr = new int[]{ 1, 2, 3, 4, 5};
4. fun (ref arr);
5. for (int i = 0; i < arr.Length ; i++)
6. Console.WriteLine( arr[i] + " ");
7. }
8. static void fun(ref int[]a)
9. {
10. a = new int[6];
11. a[3] = 32;
12. a[1] = 24;
13. }
a) 0, 0, 32, 0, 0, 0
b) 0, 24, 0, 32, 0, 0
c) 24, 0, 32, 0, 0, 0
d) 0, 0, 32, 0, 0, 0
View Answer
Answer :b
Explanation :index positions which are assigned the new values are passed as a reference
parameter and hence rest positions are filled with zero values.
Output : 0 24 0 32 0 0
6. What will be the output of given set of code?
1. static void main(string[] args)
2. {
3. int i;
4. int res = fun (out i);
5. console.writeline(res);
6. console.readline();
7. }
8. static int fun(out int i)
9. {
10. int s = 1;
11. i = 7;
12. for (int j = 1; j <= i; j++ )
13. s = s * j;
14. return s;
15. }
a) 4490
b) 5040
c) 5400
d) 3500
View Answer
Answer :b
Explanation :None.
Output: 5040
7. What will be the output of given set of code?
1. static void Main(string[] args)
2. {
3. int a = 5;
4. int b = 0, c = 0;
5. method (a, ref b, ref c);
6. Console.WriteLine(b + " " + c);
7. Console.ReadLine();
8. }
9. static int method(int x, int p, ref int k)
10. {
11. p = x + x * x;
12. k = x * x + p;
13. return 0;
14. }
a) 30, 55
b) 55, 30
c) Compile time error
d) 0, 0
View Answer
Answer :c
Explanation :Error occurence as mismatch in parameter of method() definition.Keyword ref should
be used with parameter p as ref int p
8. Keyword used to define call by reference paramter in C# .NET?
a) &
b) out
c) ref
d) &&
View Answer
Answer :c
Explanation :By definition.
9. Select the correct match of parameter declaration:
1. static Void main(string[] args)
2. {
3. int a = 5;
4. int b = 6;
5. float c = 7.2f;
6. math (ref a, ref b, ref c);
7. Console.WriteLine(a + " " + b + " " + c);
8. }
9. static int math(/*add parameter decelaration */)
10. {
11. a += b;
12. b *= (int)c;
13. c += a * b;
14. return 0;
15. }
a) ref int a, int b, ref float c
b) ref int a, ref float c, ref int b
c) ref int a, ref int b, float c
d) ref int a, ref int b, ref float c
View Answer
Answer :d
Explanation : static Void main(string[] args)
{
int a = 5;
int b = 6;
float c = 7.2f;
math(ref a, ref b, ref c);
console.writeLine(a + + b + + c);
}
10. Which statement is/are correct?
a) An arguement passed to a ref parameter need not to be intialized first
b) variables passed as out arguments need to be intialized prior to being passed
c) to use a ref parameter only the calling method must explicitly use the ref
keyword
d) None of the mentioned
View Answer
Answer :d
Explanation : None.

1. Method in which large or variable number of arguements are handled are


known as:
a) Value parameters
b) output parameters
c) parameter arrays
d) None of the mentioned
View Answer
Answer :c
Explanation: None.
2. The modifiers used to define an array of parameters or lists of arguements:
a) ref
b) out
c) param
d) var
View Answer
Answer :c
Explanation: None.
3. What will be the output for given set of code ?
1. static void Main(string[] args)
2. {
3. object[] a = {" 1 ", 4.0f, " harsh "};
4. fun(a);
5. Console.ReadLine();
6. }
7. static void fun(params object[] b)
8. {
9. for (int i = 0; i < b.Length - 1; i++)
10. Console.WriteLine(b[i] + " ");
11. }
a) 1 4.0 harsh
b) 1 4
c) 1 4 hars
d) 1 4 harsh
View Answer
Answer :d
Explanation : a is declared as array of objects which is passed as a parameter to single method
fun() using variable number of parameters.
Output : 1 4 harsh
4. Which of following statements are correct?
a) C SHARP allows a functions to have arguments with default values
b) C SHARP allows a functions to have variable number of arguments
c) Params used to specify the syntax for a function with variable number of
arguments
d) Omitting the return value type in method definition results into an exception
View Answer
Answer :b, c
Explanation: None.
5. What will be the output of set of code?
1. static void Main(string[] args)
2. {
3. int [] a = {1, 2, 3, 4, 5};
4. fun(a);
5. Console.ReadLine();
6. }
7. static void fun(params int[] b )
8. {
9. int[] k = { 3, 4, 7, 8,'\0' };
10. for (int i = 0; i < b.Length; i++)
11. {
12. b[i] = b[i] + k[i] ;
13. Console.WriteLine( b[i] + " ");
14. }
15. }
a) Compile time error
b) 3, 4, 7, 8, 5
c) 3, 4, 7, 8, 5, 1, 2, 3, 4, 5
d) 4, 6, 10, 12, 5
View Answer
Answer :d
Explanation : Passing of array parameters declared in main() and hence adding elements of array
passed using param to another array k[] declared in fun() method.
Output : 4, 6, 10, 12, 5
6. What will be the output of given set of code?
1. static void Main(string[] args)
2. {
3. int [] a = {1, 2, 3, 4, 5};
4. fun(a);
5. Console.ReadLine();
6. }
7. static void fun(params int[] b )
8. {
9. for (int i = 0; i < b.Length; i++)
10. {
11. b[i] = b[i] * 5 ;
12. Console.WriteLine(b[i] + "");
13. }
14. }
a) 1, 2, 3, 4, 5
b) 5, 10, 15, 20, 25
c) 5, 25, 125, 625, 3125
d) 6, 12, 18, 24, 30
View Answer
Answer :b
Explanation : None.
Output : 5, 10, 15, 20, 25.
7. What will be the output of given set of code?
1. static void Main(string[] args)
2. {
3. int[] a = { 2, 21, 34, 46, 85, 88, 90};
4. fun(a);
5. Console.WriteLine(a + " ");
6. Console.ReadLine();
7. }
8. static void fun(params int [] b )
9. {
10. int [] c = { 1, 2, 3, 4, 5, 6, 7};
11. int i ;
12. for (i = 0 ;i < b.Length ;i++)
13. if (b[i] % 2 == 0)
14. {
15. c[i] = b[i];
16. }
17. Console.WriteLine("even numbers are:");
18. for (i = 0 ;i <= b.Length ;i++)
19. {
20. Console.WriteLine(c[i]);
21. }
22. }
a) Compile time error
b) 2, 21, 34, 4, 6, 46, 88, 90
c) 2, 4, 34, 46, 6, 88, 90
d) 2, 34, 46, 88, 90
View Answer
Answer :d
Explanation : None.
8. Select correct declaration of defining array of parameters:
a) void func(int[] x)
{
}
b) void func(int x)
{
}
c) void func(param int[])
{
}
d) void fun(param int[] x)
{
}
View Answer
Answer :d
Explanation: None.
9. What will be the output of given set of code?
1. static void Main(string[] args)
2. {
3. int[] x = { 80, 82, 65, 72, 83, 67 };
4. fun(x);
5. Console.ReadLine();
6. }
7. static void fun(params int [] b )
8. {
9. int i;
10. for (i = 5; i >=0 ; i--)
11. {
12. Console.WriteLine(Convert.ToChar(b[i]));
13. }
14. }
a) 67 83 72 65 82 80
b) P R A H S C
c) C S H A R P
d) 80 82 65 72 83 67
View Answer
Answer :c
Explanation: None.
10. What will be the output of given set of code?
1. static void Main(string[] args)
2. {
3. int[] x = {65, 66, 67, 68, 69, 70};
4. fun(x);
5. Console.ReadLine();
6. }
7. static void fun(params int[] b )
8. {
9. int i;
10. for (i = 5; i > 0 ; i--)
11. {
12. b[i] = b[i] + 32;
13. Console.WriteLine(Convert.ToChar(b[i]));
14. }
15. }
a) A, B, C, D, E, F
b) F, E, D, C, B, A
c) f, e, d, c, b
d) b, c, d, e, f
View Answer
Answer :c
Explanation: None.

1. 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
View Answer
Answer :b
Explanation : None.
2. Select the output for given set of code?
1. public class sample
2. {
3. public static int x = 100;
4. public static int y = 150;
5.
6. }
7. public class newspaper :sample
8. {
9. new public static int x = 1000;
10. static void Main(string[] args)
11. {
12. console.writeline(sample.x + " " + sample.y + " " + x);
13. }
14. }
a) 100 150 1000
b) 1000 150 1000
c) 100 150 1000
d) 100 150 100
View Answer
Answer :c
Explanation : sample.x = 100
sample.y = 150
varhiable within scope of main() is x = 1000
Output : 100 150 1000
3. Which of following keyword used to change data and behaviour of a base
class by replacing a member of a base class with a
new derived member?
a) Overloads
b) Overrides
c) new
d) base
View Answer
Answer : c
Explanation : None.
4. 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 above
View Answer
Answer :d
Explanation : None.
5. Correct statement about C# code is?
1. public class maths
2. {
3. public int x;
4. public virtual void a()
5. {
6.
7. }
8.
9. }
10. public class subject : maths
11. {
12. new public void a()
13. {
14.
15. }
16.
17. }
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
View Answer
Answer :d
Explanation: None.
6. Select the sequence of execution of function f1(), f2() & f3() in C# .NET
CODE?
1. class base
2. {
3. public void f1() {}
4. public virtual void f2() {}
5. public virtual void f3() {}
6. }
7. class derived :base
8. {
9. new public void f1() {}
10. public override void f2() {}
11. public new void f3() {}
12. }
13. class Program
14. {
15. static void Main(string[] args)
16. {
17. baseclass b = new derived();
18. b.f1 ();
19. b.f2 ();
20. b.f3 ();
21. }
22. }
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
View Answer
Answer :b
Explanation :None.
7. Which of the following statement are 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
View Answer
Answer :c
Explanation: None.
8. Correct code to be added for overloaded operator for C# .net code given
below?
1. class csharp
2. {
3. int x, y, z;
4. public csharp()
5. {
6.
7. }
8. public csharp(int a ,int b ,int c)
9. {
10. x = a;
11. y = b;
12. z = c;
13. }
14. Add correct set of code here
15. public void display()
16. {
17. console.writeline(x + " " + y + " " + z);
18. }
19. class program
20. {
21. static void Main(String[] args)
22. {
23. csharp s1 = new csharp(5 ,6 ,8);
24. csharp s3 = new csharp();
25. s3 = - s1;
26. s3.display();
27. }
28. }
29. }
a) public static csharp operator -(csharp s1)
{
csharp t = new csharp();
t.x = s1.x;
t.y = s1.y;
t.z = -s1.z;
return t;
}
b) public static csharp operator -(csharp s1)
{
csharp t = new csharp();
t.x = s1.x;
t.y = s1.y;
t.z = s1.z;
return t;
}
c) public static csharp operator -(csharp s1)
{
csharp t = new csharp();
t.x = -s1.x;
t.y = -s1.y;
t.z = -s1.z;
return t;
}
d) None of the mentioned
View Answer
Answer :c
Explanation: None.
9. Selecting appropriate method out of number of overloaded methods by
matching arguements in terms of number ,type and order and binding that
selected method to object at compile time is called?
a) Late binding
b) Static binding.
c) Static Linking.
d) Compile time polymorphism.
View Answer
Answer : b, c, d
Explanation: None.
10. Correct 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 overriden in a derived class
d) Both override method and virtual method must have same access level
modifier.
View Answer
Answer :a, d, b
Explanation: None.

1. Correct statement about C#.NET code given below is?


1. struct book
2. {
3. private String name;
4. private int pages;
5. private Single price;
6. }
7. 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) When the program terminates, variable b will get garbage collected
View Answer
Answer: c
Explanation: None.
2. Correct statement about the C#.NET code given below is?
1. class trial
2. {
3. int i;
4. float d;
5. }
6. struct sample
7. {
8. private int x;
9. private Single y;
10. private trial z;
11. }
12. sample s = new sample();
a) trial object referred by z 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
View Answer
Answer: d
Explanation: None.
3. Choose correct statement which support facts that why C# doesnot allow
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 has no data
associated with which donot make any sense in C#.NET
c) Basic reason to create structures is inability to represent real life objects using
standard data types offered by the language
d) All of the above mentioned
View Answer
Answer: d
Explanation: Basic definition of structures in C#.NET.
4. Choose correct statement about structures 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 used to represent user defined data types that consists of
small amount of data in them hence using stack for deceleration of such
variables is not problem.
c) All of the mentioned
d) None of the mentioned
View Answer
Answer: c
Explanation: None.
5. Choose correct statement about structures in C#.NET?
a) Structures can be declared within a procedure
b) Structs can implement an interface but they cannot inherit from another struct
c) Struct members cannot be declared as protected
d) A structure can be empty
View Answer
Answer: b, c
Explanation: None.
6. The correct way to define a variable of type struct abc among following is?
1. struct abc
2. {
3. public string name;
4. protected internal int age;
5. private Single sal;
6. }
a) abc e = new abc();
b) abc e;
c) abc e;
e = new abc;
d) abc e = new abc;
View Answer
Answer: a, b
Explanation: None.
7. Which is the correct way to settle down values into the structure variable e
defined as?
1. struct emp
2. {
3. public String name;
4. public int age;
5. public Single sal;
6. }
7. emp e = new emp();
a) e.name = Ankit;
e.age = 24;
e.sal = 200;
b) With emp e
{
.name = Ankit;
.age = 24;
.sal = 200;
}
c) name = Ankit;
age = 24;
sal = 200;
d) All of the above mentioned
View Answer
Answer: a
Explanation: None.
8. When does structure variable get destroyed?
a) When no reference refers to it,it will get garbage collected
b) Depends on either 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()
View Answer
Answer: c
Explanation: None.
9. Calculate number of bytes a structure variable s occupy in memory if it is
defined as below shown?
1. class abc
2. {
3. int i;
4. Decimal d;
5. }
6. struct sample
7. {
8. private int x;
9. private Single y;
10. private trial z;
11. }
12. sample s = new sample();
a) 24 bytes
b) 8 bytes
c) 16 bytes
d) 12 bytes
View Answer
Answer: d
Explanation: None.
Output 12 bytes
10. Which is the correct output for the C#.NET program code given below?
1. {
2. struct abc
3. {
4. public int i;
5. }
6. class Program
7. {
8. static void Main(string[] args)
9. {
10. sample a = new sample();
11. a.i = 10;
12. fun(ref a);
13. Console.WriteLine(a.i);
14. }
15. public static voidn fun(ref sample x)
16. {
17. x.i = 20;
18. Console.WriteLine(x.i);
19. }
20. }
21. }
a) 10
10
b) 20
10
c) 10
20
d) 20
20
View Answer
Answer: d
Explanation: None.
Output 20
20
11. Select correct statements among the following?
a) A struct can contain properties
b) A struct can contain constructors
c) A struct can contain protected data members
d) A struct cannot contain constants
View Answer
Answer: a, b
Explanation: None.
12. Which is the correct result for the given statement in the C#.NET statement
given below?
p=q
1. struct employee
2. {
3. private int employee id;
4. private string city;
5. }
6. employee q = new employee();
7. employee p;
8. p = q;
a) Elements of q will be copied into corresponding elements of p.
b) Address stored in q will be 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.
View Answer
Answer: a
Explanation: None.
13. Which of the following will be correct output for the program given below?
1. {
2. struct abc
3. {
4. int i;
5. }
6. class Program
7. {
8. static void Main(string[] args)
9. {
10. abc x = new abc();
11. abc z;
12. x.i = 10;
13. z = x;
14. z.i = 15;
15. console.Writeline(x.i + " " + y.i)
16. }
17. }
18. }
a) 10 10
b) 10 15
c) 15 10
d) 15 15
View Answer
Answer: b
Explanation: None.
Output: 10 15
1. Choose 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
View Answer
Answer: c
Explanation: None.
2. Which among the following cannot be used as a datatype for an enum in
C#.NET?
a) short
b) double
c) int
d) float
View Answer
Answer: d, b
Explanation: None.
3. Choose correct output for the given C#.NET given below?
1. enum days:int
2. {
3. sunday = -3,
4. monday,
5. tuesday
6. }
7. Console.WriteLine((int)days.sunday);
8. Console.WriteLine((int)days.monday);
9. Console.WriteLine((int)days.tuesday);
a) -3 0 1
b) 0 1 2
c) -3 -2 -1
d) sunday monday tuesday
View Answer
Answer: c
Explanation: None.
4. Choose correct statement about the C#.NET code given below?
1. enum color:byte
2. {
3. yellow = 500,
4. green = 1000,
5. pink = 1300
6. }
a) bytes value cannot be assigned to enum elements
b) enum elements should always take successive values
c) enum must always be of int type
d) As valid range of byte exceeded the compiler will report an error
View Answer
Answer: d
Explanation: None.
5. Correct statement about enum used in C#.NET is?
a) An enum can be declared inside a class
b) An object can be assigned to an enum variable
c) An enum can be declared outside a class
d) An enum can have Single, Double values
View Answer
Answer: a, c
Explanation: None.
6. Choose the correct output for given set of code?
1. enum per
2. {
3. a,
4. b,
5. c,
6. d,
7. }
8. per.a = 10;
9. Console.writeline(per.b);
a) 11
b) 1
c) 2
d) compile time error
View Answer
Answer: d
Explanation: It will report an error since enum element cannot assigned a value outside the enum
declaration.
7. Choose the correct output for given set of code?
1. enum color:int
2. {
3. red,
4. green,
5. blue = 5,
6. cyan,
7. pink = 10,
8. brown
9. }
10. console.writeline((int)color.green);
11. console.writeline((int)color.brown);
a) 2 10
b) 2 11
c) 1 11
d) 1 5
View Answer
Answer: c
Explanation: None.
Output: 1 11
8. Correct output for the C#.NET code given below is?
1. enum letters
2. {
3. a,
4. b,
5. c
6. }
7. letters l;
8. l = letters.a;
9. Console.writeline(l);
a) -1
b) 0
c) a
d) letters.a
View Answer
Answer: c
Explanation: None.
Output: a
9. Correct output for the C#.NET code given below is?
1. enum colors
2. {
3. red,
4. black,
5. pink
6. }
7. colors s = colors.black;
8. type t;
9. t = c.GetType();
10. string[] str;
11. str = Enum.GetNames(t);
12. Console.WriteLine(str[0]);
a) 0
b) black
c) red
d) 1
View Answer
Answer: c
Explanation: None.
Output: red
10. Choose correct statement about enum used in C#.NET ?
a) By default the first enumerator had a value equals to number of elements
present in the list
b) Values of enum elements cannot be populated from database
c) The value of each successive enumerator is decreased by 1
d) An enumerator had white space in its name
View Answer
Answer: b
Explanation: None.
11. Choose the correct differences which diferent enum from C#.NET than enum
in C language?
a) C is a stricly typed language also C#.NET 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
c) C is not a strictly typed language while C#.NET is a strictly typed language
d) All of the mentioned
View Answer
Answer: b, c
Explanation: None.

1. Which procedure of 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) Containership
View Answer
Answer : b, d.
Explanation: None.
2. Number of levels of inheritance are?
a) 5
b) 4
c) 3
d) 2
View Answer
Answer : b
Explanation: None.
3. What does following code signifies?
1. class a
2. {
3.
4.
5.
6. }
7. class b : a
8. {
9. variable decelaration;
10. method decelaration;
11. }
a) Deceleration of base class
b) Deceleration of sub class
c) Deceleration of base class & sub class and how subclass inherit base class
d) None of the mentioned
View Answer
Answer : c
Explanation: None.
4. In an inheritance chain through which of given following the base class and its
components accessible to derived class?
a) Scope resolution operator(:)
b) Class visibilty modifiers (public,private etc.)
c) Dot operator (.)
d) All of the mentioned
View Answer
Answer :b
Explanation: None.
5. 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
View Answer
Answer :b
Explanation: None.
6. In Inheritance concept which of following members of base class are
accessible to derived class members?
a) static
b) protected
c) private
d) shared
View Answer
Answer :b
Explanation: None.
7. Correct 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
View Answer
Answer : c, a
Explanation:None.
8. A class member declared protected becomes member of subclass of which
type?
a) public member
b) private member
c) protected member
d) static member
View Answer
Answer : d
Explanation: A class member declared protected becomes private member of subclass.
9. Which of the following functionality 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) Implements containership
View Answer
Answer : a, b, c, d
Explanation:None.
10. Which statement 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 different from multiple levels of inheritance
c) Creating a derived class from base class requires fundamental changes to
base class
d) It is legal to make objects of one class as members of another class
View Answer
Answer : a, b, d
Explanation: None.
11. 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 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
View Answer
Answer : a, b
Explanation: None.
12. Which is correct way to create an object of 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
View Answer
Answer : a
Explanation: None.
13. Given the class sample inherited by class sample 1. Which are 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
View Answer
Answer : c
Explanation: None.
14. Which form of inheritance is not supported directly by C# .NET?
a) Multiple inheritance
b) Multilevel inheritance
c) Single inheritance
d) Hierarchical inheritance
View Answer
Answer : a
Explanation: Supported in form of interfaces in secondary form.
15. If no access modifier for a class is specified,hence still class accessibility is
defined as?
a) public
b) protected
c) private
d) internal
View Answer
Answer :c
Explanation: By default it is specified private in nature.

1. Select output for set of code?


1. class sample
2. {
3. public int i;
4. void display()
5. {
6. Console.WriteLine(i);
7. }
8. }
9. class sample1 : sample
10. {
11. public int j;
12. public void display()
13. {
14. Console.WriteLine(j);
15. }
16. }
17. class Program
18. {
19. static void Main(string[] args)
20. {
21. sample1 obj = new sample1();
22. obj.i = 1;
23. obj.j = 2;
24. obj.display();
25. Console.ReadLine();
26. }
27. }
a) 1
b) 3
c) 2
d) Compile Time error
View Answer
Answer :c
Explanation : class sample & class sample1 both contain display() method, class sample1 inherits
class sample, when display() method is called by object of class sample 1, display() method of class
sample 1 is executed rather than that of Class sample.
2. Correct statement about C#.NET code is?
1. class sample
2. {
3. protected int index;
4. public sample()
5. {
6. index = 0;
7. }
8. }
9. class sample 1: sample
10. {
11. public void add()
12. {
13. index += 1;
14. }
15. }
16. class Program
17. {
18. static void Main(string[] args)
19. {
20. sample 1 z = new sample 1();
21. z . add();
22. }
23. }
a) Index should be declared as public if it is needed to be available in inheritance
chain
b) Index should be declared as protected if it is to become available inheritance
chain
c) Constructor of sample class do not get inherited in sample 1 class
d) During constructing an object referred to by z.Here, Firstly constructor of
sample class will be called followed by constructor of sample 1 class
View Answer
Answer : b, c, d
Explanation : None.
3. The following set of code run on single level of inheritance. Find correct
statement about the code?
1. class sample
2. {
3. int i = 10;
4. int j = 20;
5. public void display()
6. {
7. Console.WriteLine("base method ");
8. }
9. }
10. class sample1 : sample
11. {
12. public int s = 30;
13. }
14. class Program
15. {
16. static void Main(string[] args)
17. {
18. sample1 obj = new sample1();
19. Console.WriteLine("{0}, {1}, {2}", obj.i, obj.j, obj.s);
20. obj.display();
21. Console.ReadLine();
22. }
23. }
a) 10, 20, 30
base method
b) 10, 20, 0
c) compile time error
d) base method
View Answer
Answer :c
Explanation : i and j are inaccessible due to protection level.Declare them as public variable and
hence will be accessed in code.
4. What will be size of object created depicted by csharp code snippet?
1. class baseclass
2. {
3. private int a;
4. protected int b;
5. public int c;
6. }
7. class derived : baseclass
8. {
9. private int x;
10. protected int y;
11. public int z;
12. }
13. class Program
14. {
15. static Void Main(string[] args)
16. {
17. derived a = new derived();
18. }
19. }
a) 20 bytes
b) 12 bytes
c) 16 bytes
d) 24 bytes
View Answer
Answer :d
Explanation : Explained in fundamental of inheritance.
5. What would be output of following set of code?
1. class sample
2. {
3. public sample()
4. {
5. Console.WriteLine("THIS IS BASE CLASS constructor");
6. }
7. }
8. public class sample1 : sample
9. {
10.
11. }
12. class Program
13. {
14. static void Main(string[] args)
15. {
16. sample1 obj = new sample1();
17. Console.ReadLine();
18. }
19. }
a) Code execute successfully prints nothing
b) This is base class constructor
c) Compile time error
d) None of the mentioned
View Answer
Answer :c
Explanation : base class accessibility level is much less than as compared to derived class.Declare it
public to get desired output.
6. Select statement added to the current set of code to get output as 10 20 ?
1. class baseclass
2. {
3. protected int a = 20;
4. }
5. class derived : baseclass
6. {
7. int a = 10;
8. public void math()
9. {
10. /* add code here */
11. }
12. }
a) Console.writeline( a + + this.a);
b) Console.Writeline( mybase.a + + a);
c) console.writeline(a + + base.a);
d) console.writeline(base.a + + a);
View Answer
Answer :c
Explanation :None.
7. Correct statement about following C#.NET code is?
1. class baseclass
2. {
3. int a;
4. public baseclass(int a1)
5. {
6. a = a1;
7. console.writeline(" a ");
8. }
9. class derivedclass : baseclass
10. {
11. public derivedclass (int a1) : base(a1)
12. {
13. console.writeline(" b ");
14. }
15. }
16. class program
17. {
18. static void main(string[] args)
19. {
20. derivedclass d = new derivedclass(20);
21. }
22. }
23. }
a) Compile time error
b) Output : b
a
c) Output : a
b
d) the program will work correctly if we replace base(a1) with base.baseclass(a1)
View Answer
Answer :c
Explanation: None.
Output : a
b
8. Which statement should be added in function a() of class y to get output i love
csharp?
1. class x
2. {
3. public void a()
4. {
5. console.write("bye");
6. }
7. }
8. class y : x
9. {
10. public void a()
11. {
12. /* add statement here */
13. console.writeline(" i love csharp ");
14. }
15. }
16. class program
17. {
18. static void main(string[] args)
19. {
20. y obj = new obj();
21. obj.a();
22. }
23. }
a) x.a();
b) a();
c) base.a();
d) x::a();
View Answer
Answer :c
Explanation: None.
9. Which statements are correct?
a) If a base class consists of a member function fun() and a derived class donot
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 derived from class A.
c) If a base class and a derived class each include a member funtion with same
name,the member function of the derived class will be called by object of derived
class
d) The size of a derived class object is equal to sum of sizes of data members in
base class and derived class
View Answer
Answer : a, b, c, d
Explanation: None.
10. Select the output for following set of code?
1. class A
2. {
3. public int i;
4. protected int j;
5. }
6. class B : A
7. {
8. public int j;
9. public void display()
10. {
11. base.j = 3;
12. Console.WriteLine(i + " " + j);
13. }
14. }
15. class Program
16. {
17. static void Main(string[] args)
18. {
19. B obj = new B();
20. obj.i = 1;
21. obj.j = 2;
22. obj.display();
23. Console.ReadLine();
24. }
25. }
a) 2 1
b) 1 0
c) 0 2
d) 1 2
View Answer
Answer :d
Explanation : Both class A & B have member with same name that is j, member of class B will be
called by default if no specifier is used. i contains 1 & j contains 2, printing 1 2.
Output: 1, 2
11. Select the output of following set of code?
1. class A
2. {
3. public int i;
4. private int j;
5. }
6. class B :A
7. {
8. void display()
9. {
10. base.j = base.i + 1;
11. Console.WriteLine(base.i + " " + base.j);
12. }
13. }
14. class Program
15. {
16. static void Main(string[] args)
17. {
18. B obj = new B();
19. obj.i = 1;
20. obj.j = 2;
21. obj.display();
22. Console.ReadLine();
23. }
24. }
a) 1, 3
b) 2, 3
c) 1, 2
d) compile time error
View Answer
Answer :d
Explanation: class contains a private member variable j, this cannot be inherited by subclass B and
does not have access to it.
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
View Answer
Answer :b
Explanation: Whenever a subclass needs to refer to its immediate super class, it can do so by use of
the keyword base.
13. Which of these operator must be used to inherit a class?
a) :
b) &
c) ::
d) extends
View Answer
Answer :a
Explanation : class a
{
}
class b : a
{

14. What is output following set of code ?


1. using System;
2. public class BaseClass
3. {
4. public BaseClass()
5. {
6. Console.WriteLine("I am a base class");
7. }
8. }
9. public class ChildClass : BaseClass
10. {
11. public ChildClass()
12. {
13. Console.WriteLine ("I am a child class");
14. }
15. static void Main()
16. {
17. ChildClass CC = new ChildClass();
18. }
19. }
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
View Answer
Answer : a
Explanation: This is because base classes are automatically instantiated before derived classes.
Notice the output, The BaseClass constructor executed before the ChildClass constructor.
Output: I am a base class
I am a child class

1. The process of defining two or more methods within same class that have
same name but different parameters lists?
a) method overloading
b) method overriding
c) Encapsulation
d) None of the mentioned
View Answer
Answer :a
Explanation: Two or more methods can have same name as long as their parameters declaration
and definitions is different, the methods are said to be overloaded and process is called method
overloading. Method overloading is used when methods are required to perform similar tasks but
using different input parameters.
2. Which of these can be overloaded?
a) Constructors
b) Methods
c) Both a & b
d) None of the mentioned
View Answer
Answer :c
Explanation: None.
3. What could be the output of following set of code?
1. class Program
2. {
3. static void Main(string[] args)
4. {
5. Console.WriteLine( vol(10));
6. Console.WriteLine( vol(2.5f, 5));
7. Console.WriteLine( vol( 5l, 4, 5));
8. Console.ReadLine();
9. }
10. static int vol(int x)
11. {
12. return(x * x * x);
13. }
14. static float vol(float r, int h)
15. {
16. return(3.14f * r * r * h);
17. }
18. static long vol(long l, int b, int h)
19. {
20. return(l * b * h);
21. }
22. }
a) 1000
0
100
b) 0
0
100
c) compile time error
d) 1000
98.125
100
View Answer
Answer :d
Explanation :The concept of method overloading is implemented in method vol with same name
but different definitions and parameter lists which is overloaded three times and in each time return
type is different for each method and hence matches the method using types of parameters .
Output: 1000
98.125
100
4. What could be the output for set of code?
1. class overload
2. {
3. public int x;
4. int y;
5. public int add(int a)
6. {
7. x = a + 1;
8. return x;
9. }
10. public int add(int a, int b)
11. {
12. x = a + 2;
13. return x;
14. }
15. }
16. class Program
17. {
18. static void Main(string[] args)
19. {
20. overload obj = new overload();
21. overload obj1 = new overload();
22. int a = 0;
23. obj.add(6);
24. obj1.add(6, 2);
25. Console.WriteLine(obj.x);
26. Console.WriteLine(obj1.x);
27. Console.ReadLine();
28. }
29. }
a) 8
8
b) 0
2
c) 8
10
d) 7
8
View Answer
Answer :d
Explanation: None.
Output: 7, 8
5. What will be the output for set of code?
1. static void Main(string[] args)
2. {
3. int i = 5;
4. int j = 6;
5. add(ref i);
6. add(6);
7. Console.WriteLine(i);
8. Console.ReadLine();
9. }
10. static void add(ref int x)
11. {
12. x = x * x;
13. }
14. static void add(int x)
15. {
16. Console.WriteLine(x * x * x);
17. }
a) Compile time error
b) 25
0
c) 216
0
d) 216
25
View Answer
Answer :d
Explanation: None.
Output: 216
25
6. What would be output for set of code?
1. class maths
2. {
3. public int x;
4. public double y;
5. public int add(int a, int b)
6. {
7. x = a + b;
8. return x;
9. }
10. public int add(double c, double d)
11. {
12. y = c + d;
13. return (int)y;
14. }
15. public maths()
16. {
17. this.x = 0;
18. this.y = 0;
19. }
20. }
21. class Program
22. {
23. static void Main(string[] args)
24. {
25. maths obj = new maths();
26. int a = 4;
27. double b = 3.5;
28. obj.add(a, a);
29. obj.add(b, b);
30. Console.WriteLine(obj.x + " " + obj.y);
31. Console.ReadLine();
32. }
33. }
a) 4, 3.5
b) 8, 0
c) 7.5, 8
d) 8, 7
View Answer
Answer :d
Explanation :None
Output: 8, 7
7. What will be output for given set of code?
1. class maths
2. {
3. public static void fun1()
4. {
5. Console.WriteLine("method 1 :");
6. }
7. public void fun2()
8. {
9. fun1();
10. Console.WriteLine("method 2 :");
11. }
12. public void fun2(int k)
13. {
14. Console.WriteLine(k);
15. fun2();
16. }
17. }
18. class Program
19. {
20. static void Main(string[] args)
21. {
22. maths obj = new maths();
23. maths.fun1();
24. obj.fun2(20);
25. Console.ReadLine();
26. }
27. }
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:
View Answer
Answer :d
Explanation: None.
Output : method 1:
20
method 1:
method 2:
8. 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
View Answer
Answer :d
Explanation : None.
9. What will be the output for following set of code?
1. class maths
2. {
3. public int fun1(int k)
4. {
5. k = 20;
6. return k;
7. }
8. public Single fun1(float t)
9. {
10. t = 3.4f;
11. return t;
12. }
13. }
14. class Program
15. {
16. static void Main(string[] args)
17. {
18. maths obj = new maths();
19. int i;
20. i = obj.fun1(30);
21. Console.WriteLine(i);
22. Single j;
23. j = obj.fun1(2.5f);
24. Console.WriteLine(j);
25. Console.ReadLine();
26. }
27. }
a) 30
2.5f
b) 2.5f
30
c) 20
2.5f
d) 20
3.4f
View Answer
Answer :d
Explanation : None.
Output: 20
3.4f
10. What will be the output for given set of code?
1. class maths
2. {
3. public int fun(int k, int y)
4. {
5. return k + y;
6. }
7. public int fun1(int t, float z)
8. {
9. return (t+(int)z);
10. }
11. }
12. class Program
13. {
14. static void Main(string[] args)
15. {
16. maths obj = new maths();
17. int i;
18. int b = 90;
19. int c = 100;
20. int d = 12;
21. float l = 14.78f;
22. i = obj.fun(b, c);
23. Console.WriteLine(i);
24. int j = (obj.fun1(d, l));
25. Console.WriteLine(j);
26. Console.ReadLine();
27. }
28. }
a) 190, 26.78f
b) 0, 26.78f
c) 190, 26
d) 190, 0
View Answer
Answer :c
Explanation : None.
Output: 190
26
11. What will be the output for set of code?
1. class maths
2. {
3. public int fun(int k, int y, int n)
4. {
5. Console.WriteLine(k + " " + y + " " + n);
6. return (k);
7. }
8. public int fun1(int t,float z)
9. {
10. Console.WriteLine(t + " " + z);
11. return t;
12. }
13. }
14. class Program
15. {
16. static void Main(string[] args)
17. {
18. maths obj = new maths();
19. int b = 90;
20. int c = 100;
21. int d ;
22. float l;
23. int i = obj.fun(b, c, 12);
24. int j = (obj.fun1(12, 14.78f));
25. Console.ReadLine();
26. }
27. }
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
View Answer
Answer :d
Explanation: None.
Output: 90, 100, 12
12, 14.78
12. What will be the output for given set of code?
1. class maths
2. {
3. public int fun(int ii)
4. {
5. return(ii > 0 ? ii :ii * -1);
6. }
7. public long fun(long ll)
8. {
9. return(ll > 0 ? ll :ll * -1);
10. }
11. public double fun( double dd)
12. {
13. return(dd > 0 ? dd :dd * -1);
14. }
15. }
16. class Program
17. {
18. static void Main(string[] args)
19. {
20. maths obj = new maths();
21. int i = -25;
22. int j ;
23. long l = -100000l ;
24. long m;
25. double d = -12.34;
26. double e;
27. j = obj.fun(i);
28. m = obj.fun(l);
29. e = obj.fun(d);
30. Console.WriteLine(j + " " + m + " " + e);
31. Console.ReadLine();
32. }
33. }
a) 1 1 1
b) 0 0 0
c) 25 100000 12.34
d) -25 -100000 -12.34
View Answer
Answer :c
Explanation :None.
Output: 25 100000 12.34

1. Which keyword is used to declare a base class method while performing


overidding of base class methods?
a) this
b) virtual
c) override
d) extend
View Answer
Answer :b
Explanation : None.
2. The process of defining a method in subclass having same name & type
signature as a method in its superclass?
a) Method overloading
b) Method overriding
c) Method hiding
d) None of the mentioned
View Answer
Answer :b
Explanation : None.
3. Which of given modifiers can be used to prevent Method overriding?
a) Static
b) Constant
c) Sealed
d) final
View Answer
Answer :c
Explanation :When an instance method deceleration includes sealed modifier,the method is said to
be sealed method.It means a derived class cannot override this method.
4. 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 types signatures of the override
method must be the same as the virtual method that is being overriden
d) We can override virtual as well as non virtual methods
View Answer
Answer :c
Explanation :None.
5. Which of the following can be used to declared as a virtual in a class?
a) Methods
b) Properties
c) Events
d) Fields
View Answer
Answer : a, b, c
Explanation :None.
6. What will be the output for given set of code?
1. class A
2. {
3. public int i;
4. public void display()
5. {
6. Console.WriteLine(i);
7. }
8. }
9. class B: A
10. {
11. public int j;
12. public void display()
13. {
14. Console.WriteLine(j);
15. }
16. }
17. class Program
18. {
19. static void Main(string[] args)
20. {
21. B obj = new B();
22. obj.i = 1;
23. obj.j = 2;
24. obj.display();
25. Console.ReadLine();
26. }
27. }
a) 0
b) 2
c) 1
d) Compile time error
View Answer
Answer :b
Explanation :When method display() is called using objects of class B. The method display() for
class B is called instead of class A as class B is inherited by class A.
Output :2
7. What will be the output for given set of code?
1. class A
2. {
3. public virtual void display()
4. {
5. Console.WriteLine("A");
6. }
7. }
8. class B: A
9. {
10. public override void display()
11. {
12. Console.WriteLine(" B ");
13. }
14. }
15. class Program
16. {
17. static void Main(string[] args)
18. {
19. A obj1 = new A();
20. B obj2 = new B();
21. A r;
22. r = obj1;
23. r.display();
24. r = obj2;
25. r.display();
26. Console.ReadLine();
27. }
28. }
a) A, A
b) B, B
c) Compile time error
d) A, B
View Answer
Answer :d
Explanation :The method overidding procedure has been used to produce the values from two
display().
Output : A B
8. The modifier used to hide the base class methods?
a) Virtual
b) New
c) Override
d) Sealed
View Answer
Answer :b
Explanation :Used in condition when we cannot use virtual to override a base class method hence
then we use New to hide the base class methods and redefine the method defined in sub class.
9. To override a method in subclass in baseclass method should be defined as?
a) virtual
b) abstract
c) Static
d) Override
View Answer
Answer : a, b, d
Explanation :None.
10. What will be the output for given set of code?
1. class a
2. {
3. public void fun()
4. {
5. Console.WriteLine("base method");
6. }
7. }
8. class b: a
9. {
10. public new void fun()
11. {
12. Console.WriteLine(" derived method ");
13. }
14. }
15. class Program
16. {
17. static void Main(string[] args)
18. {
19. b k = new b();
20. k.fun();
21. Console.ReadLine();
22. }
23. }
a) base method
b) derived method
c) Code run successfully print nothing
d) Compile time error
View Answer
Answer :b
Explanation : Use of new modifier hide the inherited member i.e it makes only inherited member
inaccessible in derived class and hence calls suitable method().
Output :derived method

1. What will be the output of given set of code?


1. class maths
2. {
3. public int length;
4. public int breadth;
5. public maths(int x, int y)
6. {
7. length = x;
8. breadth = y;
9. Console.WriteLine(x + y);
10. }
11. public maths(double x, int y)
12. {
13. length = (int)x;
14. breadth = y;
15. Console.WriteLine(x * y);
16. }
17. }
18. class Program
19. {
20. static void Main(string[] args)
21. {
22. maths m = new maths(20, 40);
23. maths k = new maths(12.0, 12);
24. Console.ReadLine();
25. }
26. }
a) 60, 24
b) 60, 0
c) 60, 144
d) 60, 144.0
View Answer
Answer :c
Explanation: Matching the values passed as parameters.The respective constructors are overloaded
as according to the matching parameter type.
Output : 60
144
2. What will be the output of given set of code?
1. class maths
2. {
3. public int length;
4. public int breadth;
5. public maths(int x)
6. {
7. length = x + 1;
8. }
9. public maths(int x, int y)
10. {
11. length = x + 2;
12. }
13. }
14. class Program
15. {
16. static void Main(string[] args)
17. {
18. maths m = new maths(6);
19. maths k = new maths(6, 2);
20. Console.WriteLine(m.length);
21. Console.WriteLine(k.length);
22. Console.ReadLine();
23. }
24. }
a) 8, 8
b) 0, 2
c) 8, 10
d) 7, 8
View Answer
Answer :d
Explanation : None.
3. What will be the output of given set of code?
1. class maths
2. {
3. public maths()
4. {
5. Console.WriteLine("constructor 1 :");
6. }
7. public maths(int x)
8. {
9. int p = 2;
10. int u;
11. u = p + x;
12. Console.WriteLine("constructor 2: " +u);
13. }
14. }
15. class Program
16. {
17. static void Main(string[] args)
18. {
19. maths k = new maths(4);
20. maths t = new maths();
21. Console.ReadLine();
22. }
23. }
a) constructor 1:
constructor 2: 6
b) constructor 2: 6
constructor 2: 6
c) constructor 2: 6
constructor 1:
d) None of the mentioned
View Answer
Answer :c
Explanation: None.
Output: constructor 2: 6
constructor 1:
4. What will be the output of given set of code?
1. class maths
2. {
3. int i;
4. public maths(int x)
5. {
6. i = x;
7. Console.WriteLine(" hello: ");
8. }
9. }
10. class maths1 : maths
11. {
12. public maths1(int x) :base(x)
13. {
14. Console.WriteLine("bye");
15. }
16. }
17. class Program
18. {
19. static void Main(string[] args)
20. {
21. maths1 k = new maths1(12);
22. Console.ReadLine();
23. }
24. }
a) hello bye
b) 12 hello
c) bye 12
d) Compile time error
View Answer
Answer :a
Explanation : None.
5. What will be the output of given set of code?
1. class maths
2. {
3. int i;
4. public maths(int ii)
5. {
6. ii = 12;
7. int j = 12;
8. int r = ii * j;
9. Console.WriteLine(r);
10. }
11. }
12. class maths1 : maths
13. {
14. public maths1(int u) :base(u)
15. {
16. u = 13;
17. int h = 13;
18. Console.WriteLine(u + h);
19. }
20. }
21. class maths2 : maths1
22. {
23. public maths2(int k) :base(k)
24. {
25. k = 24;
26. int o = 6 ;
27. Console.WriteLine(k /o);
28. }
29. }
30. class Program
31. {
32. static void Main(string[] args)
33. {
34. maths2 t = new maths2(10);
35. Console.ReadLine();
36. }
37. }
a) 4, 26, 144
b) 26, 4, 144
c) 144, 26, 4
d) 0, 0, 0
View Answer
Answer :c
Explanation :None.
6. Which keyword used to refer baseclass constructor to subclass constructor?
a) This
b) static
c) base
d) extend
View Answer
Answer :c
Explanation :None.
7. 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 type of parameters to decide which constructor to be
overloaded.The process is also known as?
a) Method overriding
b) Inheritance
c) Polymorphism
d) Encapsulation
View Answer
Answer :c
Explanation :None.
8. Correct statements about constructor overloading in C# is?
a) Overloaded constructors have same name as the class name
b) Overloaded constructors cannot use optional arguments
c) Overloaded constructors can have different type of number of arguements as
well as differ in number of arguements
d) All of above mentioned
View Answer
Answer :c
Explanation :By definition of overloaded constructors.
9. What will be the output of given set of code?
1. class maths
2. {
3. static maths()
4. {
5. int s = 8;
6. Console.WriteLine(s);
7. }
8. public maths(int f)
9. {
10. int h = 10;
11. Console.WriteLine(h);
12. }
13. }
14. class Program
15. {
16. static void Main(string[] args)
17. {
18. maths p = new maths(0);
19. Console.ReadLine();
20. }
21. }
a) 10, 10
b) 0, 10
c) 8, 10
d) 8, 8
View Answer
Answer :c
Explanation : None.
Output: 8, 10
10. What will be the output of given set of code?
1. class maths
2. {
3. int i;
4. public maths(int ii)
5. {
6. ii = -25;
7. int g;
8. g = ii > 0 ? ii : ii * -1;
9. Console.WriteLine(g);
10. }
11. }
12. class maths1 :maths
13. {
14. public maths1(int ll) :base(ll)
15. {
16. ll = -1000;
17. Console.WriteLine((ll > 0 ? ll : ll * -1));
18. }
19. }
20. class Program
21. {
22. static void Main(string[] args)
23. {
24. maths1 p = new maths1(6);
25. Console.ReadLine();
26. }
27. }
a) -25
-1000
b) -1000
-25
c) 25
1000
d) None of the mentioned
View Answer
Answer :c
Explanation : None.
Output : 25, 1000

1. 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
View Answer
Answer :c
Explanation : None.
2. 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
View Answer
Answer :d
Explanation : abstract class Base
{
}
class derived : Base
{
}
Base b1; /*object of Base class which can never be possible */
Derived d1; /*object of derived class which is possible */

3. Choose the correct statements among the following:


a) An abstract method does not have implementation
b) An abstract method can take only either static or virtual modifiers
c) An abstract method can be declared only in abstract class
d) All of the mentioned
View Answer
Answer :d
Explanation :None.
4. What will be the output for given set of code?
1. namespace ConsoleApplication4
2. {
3. abstract class A
4. {
5. int i;
6. public abstract void display();
7. }
8. class B: A
9. {
10. public int j;
11. public override void display()
12. {
13. Console.WriteLine(j);
14. }
15. }
16. class Program
17. {
18. static void Main(string[] args)
19. {
20. B obj = new B();
21. obj.j = 2;
22. obj.display();
23. Console.ReadLine();
24. }
25. }
26. }
a) 0
b) 2
c) Compile time error
d) 1
View Answer
Answer :b
Explanation :Here in abstract class A abstract method display() is declared and its full
implementation i.e definition is given in subclass of class A.
Output :2
5. What will be the output for given set of code?
1. namespace ConsoleApplication4
2. {
3. abstract class A
4. {
5. public int i ;
6. public int j ;
7. public abstract void display();
8. }
9. class B: A
10. {
11. public int j = 5;
12. public override void display()
13. {
14. this.j = 3;
15. Console.WriteLine(i + " " + j);
16. }
17. }
18. class Program
19. {
20. static void Main(string[] args)
21. {
22. B obj = new B();
23. obj.i = 1;
24. obj.display();
25. Console.ReadLine();
26. }
27. }
28. }
a) 1, 5
b) 0, 5
c) 1, 0
d) 1, 3
View Answer
Answer :d
Explanation : obj.i = 1 initializes value of i as 1 as it is abstract member of abstract class A. Now,j
is also same member as class A since it is initialized value of 5 when declared in subclass but since
abstract method is redefined in subclass using this keyword as this.j = 3.So,method will execute
only abstract class member j not subclass B own defined data member j.
Output : 1, 3
6. What will be the output for given set of code?
1. namespace ConsoleApplication4
2. {
3. abstract class A
4. {
5. public int i;
6. public abstract void display();
7. }
8. class B: A
9. {
10. public int j;
11. public int sum;
12. public override void display()
13. {
14. sum = i + j;
15. Console.WriteLine(+i + "\n" + +j);
16. Console.WriteLine("sum is:" +sum);
17. }
18. }
19. class Program
20. {
21. static void Main(string[] args)
22. {
23. A obj = new B();
24. obj.i = 2;
25. B obj1 = new B();
26. obj1.j = 10;
27. obj.display();
28. Console.ReadLine();
29. }
30. }
31. }
a) 2, 10
12
b) 0, 10
10
c) 2, 0
2
d) 0, 0
0
View Answer
Answer :c
Explanation: Abstract method implementation processed in subclass B also the object obj of
abstract class A initialize value of i as 2.The object of class B also intialize value of j as 10.Since,
the method display() is called using object of class A which is obj and hence i = 2 whereas j = 0 .So,
sum = 2.
Output : 2 0
sum is : 2
7. If a class inheriting an abstract class does not define all of its function then it
will be known as?
a) abstract
b) A simple class
c) Static class
d) None of the mentioned
View Answer
Answer :a
Explanation : Any subclass of an abstract class must either implement all of the abstract method in
the super class or be itself declared abstract.
8. Which of the following modifier is used when an abstract method is redefined
by a derived class?
a) Overloads
b) Override
c) Base
d) Virtual
View Answer
Answer :b
Explanation :None.
9. What will be the output for given set of code?
1. namespace ConsoleApplication4
2. {
3. public abstract class A
4. {
5. public int i = 7;
6. public abstract void display();
7. }
8. class B: A
9. {
10. public int j;
11. public override void display()
12. {
13. Console.WriteLine(i);
14. Console.WriteLine(j);
15. }
16. }
17. class Program
18. {
19. static void Main(string[] args)
20. {
21. B obj = new B();
22. A obj1 = new B();
23. obj.j = 1;
24. obj1.i = 8;
25. obj.display();
26. Console.ReadLine();
27. }
28. }
29. }
a) 0, 8
b) 1, 8
c) 1, 7
d) 7, 1
View Answer
Answer :d
Explanation : Data member i of abstract class A will be preferred over variable initialized and
executed by obj1 as obj1.i = 8 as obj of class B execute display() method.
Output : 7, 1.
10. What will be the output for given set of code?
1. namespace ConsoleApplication4
2. {
3. class A
4. {
5. public int i;
6. public void display()
7. {
8. Console.WriteLine(i);
9. }
10. }
11. class B: A
12. {
13. public int j;
14. public void display()
15. {
16. Console.WriteLine(j);
17. }
18. }
19. class Program
20. {
21. static void Main(string[] args)
22. {
23. B obj = new B();
24. obj.j = 1;
25. obj.i = 8;
26. obj.display();
27. Console.ReadLine();
28. }
29. }
30. }
a) 8, 1
b) 8
c) 1
d) 1, 8
View Answer
Answer :c
Explanation :class A & class B both contain display() method, class B inherits class A, when
display() method is called by object of class B, display() method of class B is executed rather than
that of Class A.
Output: 1.

1. Which of the following keyword used to overload user defined types by


defining static member functions?
a) op
b) opoverload
c) operator
d) operatoroverload
View Answer
Answer: c
Explanation : None.
2. Which of 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
View Answer
Answer: a
Explanation : None.
3. Arrange the following overloaded operators in increasing order of precedence?
%, <<, &, /, +
a) '%' < '<<' < '+' < '-' < '&' < '/'
b) '<<' < '&' < '%' < '-' < '/' < '+'
c) '&' < '-' <'%' < '<<' < '/' < '+'
d) '/' < '-' < '%' < '+' < '<<' < '&'
View Answer
Answer: b
Explanation : None.
4. Operators that cannot be overloaded are?
a) ||
b) +=
c) +
d) []
View Answer
Answer: a, b, d
Explanation : None.
5. 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
View Answer
Answer: d
Explanation : None.
6. 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
View Answer
Answer :c
Explanation : None.
7. 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)
View Answer
Answer :c
Explanation : None.
8. Choose correct statement among the below mentioned statements:
a) Forgetting to declare an operator method as public
b) Forgetting to declare an opartor method as static
c) Forgetting to return a bool type value while overloading a relational operator
d) None of the mentioned
View Answer
Answer : a, b, c
Explanation : None
9. What is vector in operator overloading?
a) class
b) method()
c) data type
d) None of the mentioned
View Answer
Answer : C
Explanation : It is a data type of class . It is defined as : public static Vector operator + (Vector a,
Vector b).
10. Choose correct statement from the given statements?
a) All operators in C#.NET can 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 the different type
than the class or struct that declares the operators
View Answer
Answer : b, c
Explanation : None.

1. What is Recursion in CSharp defined as?


a) Recursion another form of class
b) Recursion 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 call again this method
View Answer
Answer: c
Explanation :Recursion is the process of defining something in terms of itself. It allows us to define
method that calls itself repeatedly until meets some base case condition.
2. Which of these will happen if recursive method does not have a base case?
a) infinite loop condition occurence
b) System gets hangup
c) After 10000 executions programme will be automatically stopped.
d) None of the mentioned
View Answer
Answer: a
Explanation : If a recursive method does not have a base case which is necessary to meet the end
of condition then an infinite loop occurs which results in stackoverflow exception error.
3. 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 programmers written loop to call the
function repeatedly using a stack
View Answer
Answer: c
Explanation : No matter whatever be the programming language recursion is always managed by
operating system.
4. What will be the correct output for given code snippet?
1. class recursion
2. {
3. int fact(int n)
4. {
5. int result;
6. if (n == 1)
7. return 1;
8. result = fact(n - 1) * n;
9. return result;
10. }
11. }
12. class Program
13. {
14. public static void main(String args[])
15. {
16. recursion obj = new recursion() ;
17. Console.WriteLine(obj.fact(4));
18. }
19. }
a) 24
b) 30
c) 120
d) 144
View Answer
Answer: a
Explanation : None.
5. What will be the correct output for given code snippet?
1. class maths
2. {
3. int fact(int n)
4. {
5. int result;
6. if (n == 1)
7. return 1;
8. result = fact(n - 1) * n;
9. return result;
10. }
11. }
12. class Output
13. {
14. static void main(String args[])
15. {
16. maths obj = new maths() ;
17. Console.WriteLine(obj.fact(1));
18. }
19. }
a) 2
b) 10
c) 1
d) 0
View Answer
Answer: c
Explanation : fact() calculates recursively factorial of a number when n turns to be 1 consecutively
base case is executed and hence 1 is returned.
Output: 1
6. What will be the correct output for given code snippet?
1. class maths
2. {
3. int fact(int n)
4. {
5. int result;
6. if (n == 1)
7. return 1;
8. result = fact(n - 1) * n;
9. return result;
10. }
11. }
12. class Output
13. {
14. static void main(String args[])
15. {
16. maths obj = new maths() ;
17. Console.WriteLine(obj.fact(4)*obj.fact(2));
18. }
19. }
a) 64
b) 60
c) 120
d) 48
View Answer
Answer: d
Explanation : 4! = 4*3*2*1 & 2! = 2*1 .So, 24*2 = 48.
Output : 48
7. What will be the correct output for given code snippet?
1. class maths
2. {
3. int fact(int n)
4. {
5. int result;
6. if (n == 1)
7. return 1;
8. result = fact(n - 1) * n;
9. return result;
10. }
11. }
12. class Output
13. {
14. static void main(String args[])
15. {
16. maths obj = new maths() ;
17. Console.WriteLine(obj.fact(4)*(3));
18. }
19. }
a) 64
b) 60
c) 72
d) 84
View Answer
Answer: c
Explanation : 4! = 4 * 3 *2 * 1 = 24 * 3 = 72.Not factorial of 3 but just multiply the number with 3.
Output : 72
8. Which of these data types is used by operating system to manage the
Recursion in Csharp?
a) Array
b) Queue
c) Tree
d) Stack
View Answer
Answer: d
Explanation : None.
9. What will be the output of given code snippet?
1. class maths
2. {
3. public int fact(int n)
4. {
5. int result;
6. result = fact(n - 1) * n;
7. return result;
8. }
9. }
10. class Program
11. {
12. static void Main(string[] args)
13. {
14. maths obj = new maths();
15. Console.WriteLine(obj.fact(4));
16. Console.ReadLine();
17. }
18. }
a) 24
b) 30
c) Compile time error
d) Runtime Error
View Answer
Answer: d
Explanation : Absence of base case condition so absence of limit or end for execution of a loop and
hence results in stackoverflow exception error.
10. What will be the correct output for given code snippet?
1. class maths
2. {
3. public int fact(int n)
4. {
5. int result;
6. if (n == 2)
7. return 1;
8. result = fact(n - 1) * n;
9. return result;
10. }
11. }
12. class Program
13. {
14. static void Main(string[] args)
15. {
16. maths obj = new maths();
17. Console.WriteLine(obj.fact(4));
18. Console.ReadLine();
19. }
20. }
a) 24
b) 0
c) 12
d) 1
View Answer
Answer: c
Explanation : fact() calculates factorial of number 4 but this time base case condition is executed
upto 2 only as soon as n reaches 2 it returns 2.

1. Choose the correct statement among the followings?


a) Indexers are location indicators
b) Indexers are used to access class objects
c) Indexer is a form of property and works in same way as a property
d) None of the mentioned
View Answer
Answer: a, b, c
Explanation : By definition.
2. Choose the keyword which declares the indexer?
a) base
b) this
c) super
d) extract
View Answer
Answer: b
Explanation : The indexer is declared using the name this.
3. Choose the operator/operators which is/are used to access the [] operator in
indexers?
a) get
b) set
c) access
d) All of the mentioned
View Answer
Answer: a, b
Explanation : The indexer is implemented through the get and set accessors for the [] operator as:
public double this[int idx]
{
get
{
if()
{
}
else
{
return([idx]);
}
}
set
{
array[idx];

}
}

4. Choose the correct statement among the following?


a) A property can be a static member whereas an indexer can is always an
instance member
b) A get accessor of a property corresponds to a method with no parameters
whereas get accessor of an indexer corresponds to a method with same formal
parameters lists as the indexer
c) It is an error for an indexer to declare a local variable with same name as as
indexer parameters
d) All of the mentioned
View Answer
Answer: d
Explanation : None.
5. For a class student consist of indexer,So choose among the following
declaration of indexers to make code running successfully ?
student a = new student();
a[1,2] = 20;
a) class student
{
int[,] p = new int[6, 6];
public property WriteOnly int this[int i, int j]
{
set
{
a[i, j] = value;
}
}
}
b) class student
{
int[,] a = new int[6, 6];
public int this[int i, int j]
{
set
{
a[i, j] = value;
}
}
}
c) class student
{
int[,] a = new int[6, 6];
public int property WriteOnly
{
set
{
a[i, j] = value;
}
}
}
d) None of the mentioned
View Answer
Answer: b
Explanation : None.
6. Select correct advantages of using indexers:
a) To use collection of items at large scale we make use of indexers as they
utilize objects of class that represent a collection as an array
b) Indexers are also convenient as they can also make use of different types of
indexers like int, string etc
c) None of the mentioned
d) All of the mentioned
View Answer
Answer: a, b
Explanation : Indexers provides a view at large scale to visualize a collection of items as an array.It
is realy easy to use the object of the class that represents a collection as if it is an array.Hence,
indexed properties allow us to represent such a view. Indexers can also use different types of
indexes like int , string etc. Use int as an index where sequential access to a collection is
desired.When symbolic access is needed,use string as an index.
7. Choose the correct statement about properties describing the indexers?
a) No need to use the name of the property while using an indexed property
b) An indexer property should accept at least one arguement
c) Indexers can be overloaded
d) All of the mentioned
View Answer
Answer: d
Explanation : None.
8. Choose among the alternatives to correctly utilize the indexed property such
that a group named class had indexed property which stores or retrieve value
to/from an array of 5 numbers?
a) group[3] = 34;
b) group g = new group();
g[3] = 34;
c) Console.WriteLine(group[3]);
d) group g = new group();
Console.WriteLine(g[3]);
View Answer
Answer: b, d
Explanation : None.
9. Choose correct option among indexer which correctly allow to index in same
way as an array?
a) A class
b) An interface
c) A function
d) A property
View Answer
Answer: a, b
Explanation: None.
10. Choose the output for given set of code?
1. class list
2. {
3. ArrayList array = new ArrayList();
4. public object this[int index]
5. {
6. get
7. {
8. if (index < 0 || index >= array.Count)
9. {
10. return null;
11. }
12. else
13. {
14. return (array[index]);
15. }
16. }
17. set
18. {
19. array[index] = value;
20. }
21. }
22. public int Count
23. {
24. get;
25. set;
26. }
27. }
28. class Program
29. {
30. static void Main(string[] args)
31. {
32. list list1 = new list();
33. list1[0] = "123";
34. list1[1] = " abc ";
35. list1[2] = "xyz";
36. for (int i = 0; i<=list1.Count; i++)
37. Console.WriteLine(list1[i]);
38. Console.ReadLine();
39. }
40. }
a) Compile time error
b) Run time error
c) 123, abc, xyz
d) 0
View Answer
Answer: b
Explanation: Index out of range which arises only when index is non negative or less than collection
of size.

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


a) Each property consists of accessor as get and set
b) A property can be either read or write only
c) Properties can be used to store and retrieve values to and from the data
members of a class
d) Properties are like as actually methods which work like data members
View Answer
Answer: d, c
Explanation: None.
2. Choose the statements which make use of properties essential than making
data member public in C#.NET?
a) Properties have their own access levels like private, public, protected etc.
which allows to have better control about manageing read and write properties
b) Properties gives us control about what values may be assigned to a member
variables of a class they represent
c) Properties consist of set accessor inside which we can validate the value
before assigning it to the data variable
d) All of the above mentioned
View Answer
Answer: d
Explanation: None.
3. Where the properties can be declared?
a) Class
b) Struct
c) Interface
d) Namespace
View Answer
Answer: a, b, c
Explanation : None.
4. Select the modifiers which can be used with the properties?
a) Private
b) Public
c) Protected Internal
d) Protected
View Answer
Answer: a, b, c, d
Explanation : None.
5. Choose the correct statements about write-only properties in C#.NET?
a) Properties which can only be set
b) Properties once set and hence values cannot be read back in nature
c) Useful for usage in classes which store sensitive information like password of
a user
d) None of the above mentioned
View Answer
Answer: a, b, c
Explanation : None.
6. Consider a class maths and we had a property called as sum.b is a reference
to a maths object and we want the statement b.sum = 10 to fail.Which is the
correct
solution to ensure this functionality?
a) Declare sum property with both get and set accessors
b) Declare sum property with only get accessor
c) Declare sum property with get, set and normal accessors
d) None of the mentioned
View Answer
Answer: c
Explanation : None.
7. Consider a class maths and we had a property called as sum.b is a reference
to a maths object and we want the statement Console.WriteLine(b.sum)to
fail.Which is the correct solution to ensure this functionality?
a) Declare sum property with only get accessor
b) Declare sum property with only set accessor
c) Declare sum property with both set and get accessor
d) Declare sum property with both set, get and normal accessor
View Answer
Answer: b
Explanation : None.
8. Consider a class maths and we had a property called as sum.b is a reference
to a maths object and we want the code below to work.Which is the correct
solution to ensure this functionality?
b.maths = 10;
Console.WriteLine(b.maths);
a) Declare maths property with get and set accessors
b) Declare maths property with only get accessors
c) Declare maths property with only set accessors
d) Declare maths property with only get, set and normal accessors
View Answer
Answer: a
Explanation : None.
9. If math class had add property with get and set accessors then which
statements will work correctly?
a) math.add = 20;
b) math m = new math();
m.add = 10;
c) Console.WriteLine(math.add);
d) math m = new math();
m.add = m.add + 20;
View Answer
Answer: b, d
Explanation : None.
10. If math class had add property with get accessors then which statements will
work correctly?
a) math m = new math();
m.add = 10;
b) math m = new math();
m.add = m.add + 20;
c) math m = new math();
int i;
i = m.add;
d) math.add = 20;
View Answer
Answer: c
Explanation : None.

1. Correct way to implement a read only property add in a math class?


a)
1. class math
2. {
3. int ad;
4. public int add
5. {
6. get
7. {
8. return ad;
9. }
10. }
11.
12. }
b)
1. class math
2. {
3. public int add
4. {
5. get
6. {
7. return ad;
8. }
9. }
10. }
c)
1. class math
2. {
3. int ad;
4. public int add
5. {
6. get
7. {
8. return ad;
9. }
10. set
11. {
12. ad = value;
13. }
14. }
15. }
d) None of the mentioned
View Answer
Answer: a
Explanation : None.
2. Correct way to implement a write only property add in a math class?
a)
1. class math
2. {
3. public int add
4. {
5. set
6. {
7. add = value;
8. }
9. }
10. }
b)
1. class math
2. {
3. int ad;
4. public int add
5. {
6. set
7. {
8. ad = value;
9. }
10. }
11. }
c)
1. class math
2. {
3. int ad;
4. public int add
5. {
6. get
7. {
8. return ad;
9. }
10. set
11. {
12. ad = value;
13. }
14. }
15. }
d) None of the mentioned
View Answer
Answer: b
Explanation : None.
3. Select the correct statement about properties in C#.NET?
a) A property can simultaneously be read or write only
b) A property can be either read only or write only
c) A write only property will have only get accessor
d) A read only property will have only get accessor
View Answer
Answer: b, d
Explanation : None.
4. What will be the output of following snippet of code?
1. class number
2. {
3. private int num1;
4. private int num2;
5. public int anumber
6. {
7. get
8. {
9. return num1;
10. }
11. set
12. {
13. num1 = value;
14. }
15. }
16. public int anumber1
17. {
18. get
19. {
20. return num2;
21. }
22. set
23. {
24. num2 = value;
25. }
26. }
27. }
28. class Program
29. {
30. public static void Main(string[] args)
31. {
32. number p = new number();
33. p.anumber = 20;
34. number k = new number();
35. k.anumber1 = 40;
36. int m = p.anumber;
37. int t = k.anumber1;
38. int r = p.anumber + k.anumber1;
39. Console.WriteLine("number = " +m);
40. Console.WriteLine("number = " +t);
41. Console.WriteLine("sum = " +r);
42. Console.ReadLine();
43. }
44. }
a) 0
b) Compile time error
c) 60
d) None of the above mentioned
View Answer
Answer: c
Explanation: None.
Output : 60
5. What will be the output of following snippet of code?
1. class number
2. {
3. private int num1 = 60;
4. private int num2 = 20;
5. public int anumber
6. {
7. get
8. {
9. return num1;
10. }
11. set
12. {
13. num1 = value;
14. }
15. }
16. public int anumber1
17. {
18. get
19. {
20. return num2;
21. }
22. set
23. {
24. num2 = value;
25. }
26. }
27. }
28. class Program
29. {
30. public static void Main(string[] args)
31. {
32. number p = new number();
33. number k = new number();
34. int m = p.anumber;
35. int t = k.anumber1;
36. int r = p.anumber * k.anumber1;
37. Console.WriteLine("sum = " + r);
38. Console.ReadLine();
39. }
40. }
a) 0
b) 120
c) 1200
d) Compile time error
View Answer
Answer: c
Explanation: None.
Output : 1200
6. What will be the output of following snippet of code?
1. class number
2. {
3. int length = 50;
4. public int number1
5. {
6. get
7. {
8. return length;
9. }
10. set
11. {
12. length = value;
13. }
14. }
15. }
16. class Program
17. {
18. public static void Main(string[] args)
19. {
20. number p = new number();
21. p.number1 = p.number1 + 40;
22. int k = p.number1 * 3 / 9;
23. Console.WriteLine(k);
24. Console.ReadLine();
25. }
26. }
a) 0
b) 180
c) 30
d) Compile time error
View Answer
Answer: c
Explanation : None.
Output : 30
7. What will be the output of following snippet of code?
1. class number
2. {
3. int length = 60;
4. public int number1
5. {
6. get
7. {
8. return length;
9. }
10. }
11. }
12. class Program
13. {
14. public static void Main(string[] args)
15. {
16. number p = new number();
17. int l;
18. l = p.number1 + 40;
19. int k = l * 3 / 4;
20. Console.WriteLine(k);
21. Console.ReadLine();
22. }
23. }
a) 30
b) 75
c) 80
d) 0
View Answer
Answer: b
Explanation : None.
Output : 75
8. What will be the output of following snippet of code?
1. class student
2. {
3. int []scores = new int[5] {23, 42, 54, 11, 65};
4. public int this[int index]
5. {
6. get
7. {
8. if (index < 5)
9. return scores[index];
10. else
11. {
12. Console.WriteLine("invalid index");
13. return 0;
14. }
15. }
16. set
17. {
18. if (index < 5)
19. scores[index] = value;
20. else
21. Console.WriteLine("invalid index");
22. }
23. }
24. }
25. class Program
26. {
27. public static void Main(string[] args)
28. {
29. student s = new student();
30. Console.WriteLine(s[4] + 8);
31. Console.ReadLine();
32. }
33. }
a) 73
b) 37
c) 0
d) Run time error
View Answer
Answer: a
Explanation : None.
Output : 73
9. Correct way to implement the property for which property reports the error
invalid index if user attempts to cross bounds of the array for a student class
with 5 intger arrays.
a)
1. class student
2. {
3. int []scores = new int[5] {23, 42, 54, 11, 65};
4. public int this[int index]
5. {
6. get
7. {
8. if (index < 5)
9. return scores[index];
10. else
11. {
12. Console.WriteLine("invalid index");
13. return 0;
14. }
15. }
16. set
17. {
18. if (index < 5)
19. scores[index] = value;
20. else
21. Console.WriteLine("invalid index");
22. }
23. }
24. }
b)
1. class student
2. {
3. int []scores = new int[5] {23, 42, 54, 11, 65};
4. public int this[int index]
5. {
6. get
7. {
8. if (index < 5)
9. return scores[index];
10. else
11. {
12. Console.WriteLine("invalid index");
13. return 0;
14. }
15. }
16. }
17. }
c)
1. class student
2. {
3. int []scores = new int[5]{23, 42, 54, 11, 65};
4. public int this[int index]
5. {
6. set
7. {
8. if (index < 5)
9. return scores[index];
10. else
11. {
12. Console.WriteLine("invalid index");
13. return 0;
14. }
15. }
16. }
17. }
d) None of the above mentioned
View Answer
Answer: a, b
Explanation : None.
10. What will be the output of following snippet of code?
1. class student
2. {
3. int []scores = new int[3] {13, 32, 24};
4. public int this[int index]
5. {
6. get
7. {
8. if (index < 3)
9. return scores[index];
10. else
11. {
12. Console.WriteLine("invalid index");
13. return 0;
14. }
15. }
16. private set
17. {
18. if (index < 3)
19. scores[index] = value;
20. else
21. Console.WriteLine("invalid index");
22. }
23. }
24. }
25. class Program
26. {
27. public static void Main(string[] args)
28. {
29. student s = new student();
30. int[] scores1 = new int[3] {8, 19, 40};
31. for (int i = 0; i < 3; i++)
32. {
33. if (scores1[i] > s[i])
34. {
35. Console.WriteLine(" scores1 had greater value :" + scores1[i]);
36. }
37. else
38. {
39. Console.WriteLine("scores had greater value :" + s[i]);
40. }
41. }
42. Console.ReadLine();
43. }
44. }
a) 0
b) Compile time error
c) Run time error
d) scores had greater value : 13
scores had greater value : 32
scores1 had greater value : 40
View Answer
Answer: d
Explanation : None.
Output : scores had greater value : 13
scores had greater value : 32
scores1 had greater value : 40

1. Which statement correctly defines about 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
View Answer
Answer: d
Explanation :Leaving all options only option a is correct as interfaces can be inherited i.e
inheritance can be performed in csharp .net.
2. Which of the following can be used to declare an interface correctly?
a) Properties
b) Methods
c) Structures
d) Events
View Answer
Answer: a, b, d
Explanation :None.
3. A class consists of two interfaces with each interface consisting of three
methods.The class had no instance data which indicates correct size of object
created from this class?
a) 12 bytes
b) 16 bytes
c) 0 bytes
d) 24 bytes
View Answer
Answer: d
Explanation : None.
4. Statement correctly defines about the implementation of interface?
a) The calls to implementations of interface method 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
View Answer
Answer: a, b
Explanation : None.
5. 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 above mentioned
View Answer
Answer: b
Explanation : None.
6. Which keyword used for correct implementation of an interface in C#.NET?
a) interface
b) Interface
c) intf
d) Intf
View Answer
Answer: a
Explanation : None.
7. Choose 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) None of the mentioned
View Answer
Answer: a, b, c
Explanation : None.
8. Which of the following is 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
View Answer
Answer: a
Explanation : None.
9. Does C#.NET supports partial implementation of interfaces?
a) True
b) False
c) Cant Say
d) None of the above mentioned
View Answer
Answer: b
Explanation :Interface is a behaviour. It represents a protocol or contract of sorts.Hence, it is
impossible to implement an interface partially.
10. Select the correct implementation of the interface which is mentioned below.
interface a1
{
int fun(int i);
}
a)
1. class a
2. {
3. int fun(int i) as a1.fun
4. {
5. }
6. }
b)
1. class a: implements a1
2. {
3. int fun(int i)
4. {
5. }
6. }
c)
1. class a: a1
2. {
3. int a1.fun(int i)
4. {
5. }
6. }
d) None of the mentioned
View Answer
Answer: c
Explanation : None.
11. 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
View Answer
Answer: c
Explanation : None.
12. Access specifiers which can be used for an interface?
a) Public
b) Protected
c) Private
d) All of the mentioned
View Answer
Answer: a
Explanation : Access specifier of interface is either public or no specifier.When no access specifier is
specified then only default access specifier is used due to which interface is available only to other
members of the package in which it is declared,
when declared public it can be used by any code declared anywhere in the class area.

1. Correct statement about c#.NET code snippet given below is?


1. interface a1
2. {
3. void f1();
4. int f2();
5. }
6. class a :a1
7. {
8. void f1()
9. {
10. }
11. int a1.f2()
12. {
13. }
14. }
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
View Answer
Answer : c
Explanation : None.
2. Choose the correct 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
View Answer
Answer : b, a
Explanation : None.
3. Choose the correct statement about following code snippet given below:
1. interface a1
2. {
3. void f1();
4. void f2();
5. }
6. class a :a1
7. {
8. private int i;
9. void a1.f1()
10. {
11. }
12. }
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
View Answer
Answer : b
Explanation : None.
4. Choose the correct statement about following code snippet in C#.NET:
1. interface abc
2. {
3. String FirstName
4. {
5. get;
6. set;
7. }
8. String LastName
9. {
10. get;
11. set;
12. }
13. void print();
14. void stock();
15. int fun();
16. }
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
View Answer
Answer : b
Explanation : None.
5. What will be the output of given code snippet?
1. interface calc
2. {
3. void cal(int i);
4. }
5. public class maths :calc
6. {
7. public int x;
8. public void cal(int i)
9. {
10. x = i * i;
11. }
12. }
13. class Program
14. {
15. public static void Main(string[] args)
16. {
17. display arr = new display();
18. arr.x = 0;
19. arr.cal(2);
20. Console.WriteLine(arr.x);
21. Console.ReadLine();
22. }
23. }
a) 0
b) 2
c) 4
d) None of the mentioned
View Answer
Answer :c
Explanation : None.
Output : 4
6. What will be the output of given code snippet?
1. interface calc
2. {
3. void cal(int i);
4. }
5. class displayA :calc
6. {
7. public int x;
8. public void cal(int i)
9. {
10. x = i * i;
11. }
12. }
13. class displayB :calc
14. {
15. public int x;
16. public void cal(int i)
17. {
18. x = i / i;
19. }
20. }
21. class Program
22. {
23. public static void Main(string[] args)
24. {
25. displayA arr1 = new displayA();
26. displayB arr2 = new displayB();
27. arr1.x = 0;
28. arr2.x = 0;
29. arr1.cal(2);
30. arr2.cal(2);
31. Console.WriteLine(arr1.x + " " + arr2.x);
32. Console.ReadLine();
33. }
34. }
a) 0 0
b) 2 2
c) 4 1
d) 1 4
View Answer
Answer : c
Explanation :class displayA executes the interface calculate by doubling the value of item similarly
class displayB implements the interface by dividing item by item.So, variable x of class displayA
stores 4 and variable x of class displayB stores 1.
Output : 4, 1
7. Choose the correct output of following given code snippet?
1. interface i1
2. {
3. void fun();
4. }
5. interface i2
6. {
7. void fun();
8. }
9. public class maths :i1, i2
10. {
11. void i1.fun()
12. {
13. Console.WriteLine("i1.fun");
14. }
15. void i2.fun()
16. {
17. Console.WriteLine("i2.fun");
18. }
19. }
20. class Program
21. {
22. static void Main(string[] args)
23. {
24. Sample obj = new Sample();
25. i1 i = (i1) obj;
26. i.fun();
27. i2 ii = (i2) obj;
28. ii.fun();
29. }
30. }
a) i1.fun
b) i2.fun
i1.fun
c) 0
d) i1.fun
i2.fun
View Answer
Answer :d
Explanation :None.
8. Correct way to implement the interface given below?
interface abc
{
string name
{
get;
set;
}
}
a)
class emp :employee
{
private string str;
public string firstname;
{
get
{
return str;
}
set
{
str = value;
}
}
}
b)
class emp :implements person
{
private string str;
public string firstname
{
get
{
return str;
}
set
{
str = value;
}
}
}
c)
class emp: implements person
{
private string str;
public string person.firstname
{
get
{
return str;
}
set
{
str = value;
}
}
}
d) None of the mentioned
View Answer
Answer :a
Explanation : None.
9. Choose the correct output of following given code snippet?
1. interface i1
2. {
3. void f1();
4. }
5. interface i2 :i1
6. {
7. void f2();
8. }
9. public class maths :i2
10. {
11. public void f2()
12. {
13. Console.WriteLine("fun2");
14. }
15. public void f1()
16. {
17. Console.WriteLine("fun1");
18. }
19. }
20. class Program
21. {
22. static Void Main()
23. {
24. maths m = new maths();
25. m.f1();
26. m.f2();
27. }
28. }
a) fun2
b) fun1
c) fun1
fun2
d) fun2
fun1
View Answer
Answer :c
Explanation :None.
10. In order to avoid ambiguity among an interface derived from two base
interfaces with same method name(and signature).Select right code among the
following given codes.
a)
1. interface i1
2. {
3. void m1();
4. }
5. interface i2
6. {
7. void m1();
8. }
9. interface i3 :i1, i2
10. {
11. }
12. class c3 :i3
13. {
14. void i1.m1()
15. {
16. }
17. void i1.m1()
18. {
19. }
20. }
b)
interface i1
{
void m1();
}
interface i2
{
void m1();
}
interface i3 :i1, i2
{
}
class c3 :i3
{
void i1.i2.m1()
{
}
}
c)
interface i1
{
void m1();
}
interface i2
{
void m1();
}
interface i3 :i1, i2
{
}
class c3 :i3
{
void i1.m1()
{
}
void i2.m1()
{
}
}
d) All of the mentioned
View Answer
Answer :c
Explanation : None.

1. Select which among is NOT an exception?


a) Stack Overflow
b) Arithmetic Overflow or underflow
c) Incorrect Arithmetic Expression
d) All of the above mentioned
View Answer
Answer :c
Explanation :None.
2. Select which among is NOT considered as .NET Exception class?
a) Exception
b) StackUnderflow Exception
c) File Found Exception
d) Divide By zero Exception
View Answer
Answer :b, c
Explanation :None.
3. Which is the object oriented way to handle run time errors?
a) Error codes
b) HERRESULT
c) OnError
d) Exceptions
View Answer
Answer :d
Explanation :None.
4. Select the statements which describes correctly usage of exception handling
over conventional error handling approaches?
a) As errors can be ignored but exceptions cannot be ignored
b) Exception handling allows seperation of programs logic from error handling
logic making software more reliable and maintainable
c) try catch finally structure allows guaranteed cleanup in event of errors
under all circumstances
d) All of the above mentioned
View Answer
Answer :d
Explanation : None.
5. Select the correct statement about an Exception?
a) It occurs during loading of program
b) It occurs during Just-In-Time compilation
c) It occurs at run time
d) All of the above mentioned
View Answer
Answer :c
Explanation :None.
6. Which of these keywords is not a part of exception handling?
a) try
b) finally
c) thrown
d) catch
View Answer
Answer :c
Explanation :Exceptional handling is managed via 5 keywords try, catch, throws, throw and finally.
7. Which of these keywords must be used to monitor for exceptions?
a) try
b) finally
c) throw
d) catch
View Answer
Answer :a
Explanation :None.
8. Which of these keywords is used to manually throw an exception?
a) try
b) finally
c) throw
d) catch
View Answer
Answer :c
Explanation :None.
9. Choose the correct output for given set of code:
1. class program
2. {
3. static void main(string[] args)
4. {
5. int i = 5;
6. int v = 40;
7. int[] p = new int[4];
8. try
9. {
10. p[i] = v;
11. }
12. catch(IndexOutOfRangeException e)
13. {
14. Console.WriteLine("Index out of bounds");
15. }
16. Console.WriteLine("Remaining program");
17. }
18. }
a) value 40 will be assigned to a[5];
b) The output will be :
Index out of bounds
Remaining program
c) The output will be :
Remaining program
d) None of the above mentioned
View Answer
Answer :b
Explanation :None.
10. Choose the correct output for given set of code:
1. static void Main(string[] args)
2. {
3. try
4. {
5. Console.WriteLine("csharp" + " " + 1/Convert.ToInt32(0));
6. }
7. catch(ArithmeticException e)
8. {
9. Console.WriteLine("Java");
10. }
11. Console.ReadLine();
12. }
a) csharp
b) java
c) Run time error
d) csharp 0
View Answer
Answer :b
Explanation : 1 / 0, hence system out of flow exception error.
11. Which is correct statement about exception handling in C#.NET?
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
d) All of the above mentioned
View Answer
Answer : a, c
Explanation : None.
12. Choose the correct output for given set of code:
1. class Program
2. {
3. static void Main(string[] args)
4. {
5. try
6. {
7. Console.WriteLine("csharp" + " " + 1/0);
8. }
9. finally
10. {
11. Console.WriteLine("Java");
12. }
13. Console.ReadLine();
14. }
15. }
a) csharp 0
b) Run time Exception generation
c) Compile time error
d) Java
View Answer
Answer : b
Explanation : Run time Error of division by zero.

1. What will be the output of following set of code?


1. {
2. int sum = 10;
3. try
4. {
5. int i;
6. for (i = -1; i < 3; ++i)
7. sum = (sum / i);
8. }
9. catch (ArithmeticException e)
10. {
11. Console.WriteLine("0");
12. }
13. Console.WriteLine(sum);
14. Console.ReadLine();
15. }
a) 0
b) 0 5
c) 0 -10
d) Compile time error
View Answer
Answer :c
Explanation : Value of variable sum is printed as sum is defined outside try & catch block if defined
inside the try block then sum would be undefined for execution.
Output : 0 -10
2. What will be the output of following set of code?
1. {
2. try
3. {
4. int []a = {1, 2, 3, 4, 5};
5. for (int i = 0; i < 5; ++i)
6. Console.WriteLine(a[i]);
7. int x = (1 / Convert.ToInt32(0));
8. }
9. catch(IndexOutOfRangeException e)
10. {
11. Console.WriteLine("A");
12. }
13. catch(ArithmeticException e)
14. {
15. Console.WriteLine("B");
16. }
17. Console.ReadLine();
18. }
a) 1234
b) 12345
c) Run time error
d) 12345B
View Answer
Answer :d
Explanation : Due to occurence of arithmetic exception here it is printed B after 12345.
Output : 12345B
3. What will be the output of given code snippet?
1. {
2. try
3. {
4. int []a = {1, 2, 3, 4, 5};
5. for (int i = 0; i < 7; ++i)
6. Console.WriteLine(a[i]);
7. }
8. catch(IndexOutOfRangeException e)
9. {
10. Console.WriteLine("0");
11. }
12. Console.ReadLine();
13. }
a) 12345
b) 123450
c) 1234500
d) Compile time error
View Answer
Answer :b
Explanation : When array index goes out of bound then IndexOutOfBoundsException exception is
thrown by the system.
Output : 123450
4. What would be the output of following code snippet?
1. {
2. try
3. {
4. int a, b;
5. b = 0;
6. a = 10 / b;
7. Console.WriteLine("A");
8. }
9. catch(ArithmeticException e)
10. {
11. Console.WriteLine("B");
12. }
13. Console.ReadLine();
14. }
a) A
b) B
c) Compile time error
d) Run time error
View Answer
Answer :b
Explanation : Since b = 0 since a = 10 / 0 so, arithmetic exception is caught and hence statement in
catch block is executed.
Output : B
5. What would be the output of following code snippet?
1. {
2. try
3. {
4. int i, sum;
5. sum = 10;
6. for (i = -1 ;i < 3 ;++i)
7. {
8. sum = (sum / i);
9. Console.WriteLine(i);
10. }
11. }
12. catch(ArithmeticException e)
13. {
14. Console.WriteLine("0");
15. }
16. Console.ReadLine();
17. }
a) -1
b) 0
c) -1 0
d) -1 0 -1
View Answer
Answer: c
Explanation : None.
Output : -1 0
6. What would be the output of following code snippet?
1. {
2. try
3. {
4. int a, b;
5. b = 0;
6. a = 5 / b;
7. Console.WriteLine("A");
8. }
9. catch(ArithmeticException e)
10. {
11. Console.WriteLine("B");
12. }
13. finally
14. {
15. Console.WriteLine("C");
16. }
17. Console.ReadLine();
18. }
a) A
b) B
c) B C
d) Run time error
View Answer
Answer: c
Explanation : finally keyword usage used to execute before catch and try block is executed.
Output : B C
7. What would be the output of given code snippet?
1. class Program
2. {
3. static void Main(string[] args)
4. {
5. int i;
6. int v = 40;
7. int[] x = new int[5];
8. try
9. {
10. Console.WriteLine(" Enter the number: ");
11. index = Convert.ToInt32(Console.ReadLine());
12. x[index] = v;
13. }
14. catch(Exception e)
15. {
16. Console.WriteLine("Exception occured");
17. }
18. Console.WriteLine("Program executed");
19. }
20. }
a) Exception occured
b) Program executed
c) Exception occured
Program executed
d) Program executed
Exception occured
View Answer
Answer :c
Explanation : None.
Output : Exception occured
Program executed
8. When no exception is caught thrown at runtime then who will catch it?
a) CLR
b) Operating System
c) Loader
d) Compiler
View Answer
Answer :a
Explanation :None.
9. What would be the output of given code snippet?
1. public static void Main(string[] args)
2. {
3. try
4. {
5. int a, b, c = 5;
6. b = 0;
7. a = c / b;
8. Console.WriteLine("A");
9. }
10. catch (ArithmeticException e)
11. {
12. int c = 5;
13. int i = 10;
14. int z = 2 * c - i;
15. Console.WriteLine("B");
16. Console.WriteLine(z);
17. }
18. Console.ReadLine();
19. }
a) Compile time error
b) Run time error
c) B 0
d) B
View Answer
Answer :c
Explanation : The catch block is called as exception is caught by the same block and hence
statements are executed consecutively.
Output : B 0
10. Choose the correct statement which makes exception handling work in
C#.NET?
a) .Net runtime makes search for the exception handler where exception occurs
b) If no exception is matched hence exception handler goes up the stack and
hence finds the match there
c) If no match is found at highest level of stack call then unhandledException is
generated and hence termination of program occurs
d) None of the mentioned
View Answer
Answer : a, b, c
Explanation : By definition of exceptionhandling mechanism in C#.NET .

1. Which of these clause will be executed even if no exceptions are found?


a) throws
b) finally
c) throw
d) catch
View Answer
Answer: b
Explanation: finally keyword is used to define a set of instructions that will be executed irrespective
of the exception found or not.
2. A single try block must be followed by which of these?
a) finally
b) catch
c) Both a & b
d) None of the mentioned
View Answer
Answer: c
Explanation: try block can be followed by any of finally or catch block, try block checks for exceptions
and work is performed by finally and catch block as per the exception.
3. Which of these exceptions handles the divide by zero error?
a) ArithmeticException
b) MathException
c) IllegalAccessException
d) IllegarException
View Answer
Answer: a
Explanation: None.
4. Which of these exceptions will occur if we try to access the index of an array
beyond its length?
a) ArithmeticException
b) ArrayException
c) ArrayArguementException
d) IndexOutOfRangeException
View Answer
Answer: d
Explanation: IndexOutOfRangeException is a built in exception that is caused when we try to access
an index location which is beyond the length of an array.
5. What will be the output of given code snippet?
1. class program
2. {
3. public static void Main(string[] args)
4. {
5. try
6. {
7. int a = args.Length;
8. int b = 1 / a;
9. Console.WriteLine(a);
10. }
11. catch (ArithmeticException e)
12. {
13. Console.WriteLine("1");
14. }
15. Console.ReadLine();
16. }
17. }
a) 0
b) 1
c) Compile time error
d) Runtime error
View Answer
Answer: b
Explanation: None.
6. what will be the output of given code snippet?
1. class program
2. {
3. public static void Main(string[] args)
4. {
5. try
6. {
7. throw new NullReferenceException("C");
8. Console.WriteLine("A");
9. }
10. catch (ArithmeticException e)
11. {
12. Console.WriteLine("B");
13. }
14. Console.ReadLine();
15. }
16. }
a) A
b) B
c) Compile time error
d) Runtime error
View Answer
Answer: d
Explanation: try block is throwing NullPointerException but the catch block is used to counter
Arithmetic Exception. Hence NullPointerException occurs since no catch is there which can handle
it, runtime error occurs.
7. what will be the output of given code snippet?
1. class Program
2. {
3. public static void Main(string[] args)
4. {
5. try
6. {
7. int a = 1;
8. int b = 10 / a;
9. try
10. {
11. if (a == 1)
12. a = a / a - a;
13. if (a == 2)
14. {
15. int[] c = { 1 };
16. c[8] = 9;
17. }
18. }
19. finally
20. {
21. Console.WriteLine("A");
22. }
23. }
24. catch (IndexOutOfRangeException e)
25. {
26. Console.WriteLine("B");
27. }
28. Console.ReadLine();
29. }
30. }
a) A
b) B
c) AB
d) BA
View Answer
Answer: a
Explanation: The inner try block does not have a catch which can tackle IndexOutOfRangeException
hence finally is executed which prints A the outer try block does have catch for
IndexOutOfBoundException exception but no such exception occurs in it hence its catch is never
executed and only A is printed.
8. what will be the output of given code snippet?
1. class Program
2. {
3. public static void Main(string[] args)
4. {
5. try
6. {
7. int a = args.Length;
8. int b = 10 / a;
9. Console.WriteLine(a);
10. try
11. {
12. if (a == 1)
13. a = a / a - a;
14. if (a == 2)
15. {
16. int[] c = { 1 };
17. c[8] = 9;
18. }
19. }
20. catch (IndexOutOfRangeException e)
21. {
22. Console.WriteLine("TypeA");
23. }
24. }
25. catch (ArithmeticException e)
26. {
27. Console.WriteLine("TypeB");
28. }
29. Console.ReadLine();
30. }
31. }
a) TypeA
b) TypeB
c) 0TypeA
d) Compile time error
View Answer
Answer :b
Explanation: None.
9. Which of these keywords is used to by the calling function to guard against the
exception that is thrown by called function?
a) try
b) throw
c) throws
d) catch
View Answer
Answer :c
Explanation: If a method is capable of causing an exception that it does not handle. It must specify
this behaviour the behaviour so that callers of the method can guard themselves against that
exception. This is done by using throws clause in methods declaration.
10. Which of these class is related to all the exceptions that are explicitly thrown?
a) Error
b) Exception
c) Throwable
d) Throw
View Answer
Answer :c
Explanation: None.

1. What is the use of try & catch?


a) It is used to manually handle the exception
b) It helps to fix the errors
c) It prevents automatic terminating of the program in cases when an exception
occurs
d) All of the mentioned
View Answer
Answer: d
Explanation: None.
2. What is the output of this program?
1. class Output
2. {
3. public static void main(String args[])
4. {
5.
6. try
7. {
8. int a = 9;
9. int b = 5;
10. int c = a / b - 5;
11. Console.WriteLine("Hello");
12. }
13. catch(Exception e)
14. {
15. Console.WriteLine("C");
16. }
17. finally
18. {
19. Console.WriteLine("sharp");
20. }
21. }
22. }
a) Hello
b) C
c) Hellosharp
d) Csharp
View Answer
Answer: d
Explanation: finally block execution takes place after the tryblock, no matter exception is found or
not. catch block is executed only when exception is found. Here divide by zero exception is found
hence both catch and finally are executed.
3. Choose the statement which is incorrect?
a) try block do not need to be followed by catch block
b) try block can be followed by finally block instead of catch block
c) try can be followed by both catch and finally block
d) try need not to be followed by anything
View Answer
Answer: d
Explanation: try followed by either catch or finally block.
4. What will be the output of the program?
1. class Output
2. {
3. public static void main(String args[])
4. {
5. try
6. {
7. int a = 10;
8. int b = 5;
9. int c = a / b - 5;
10. Console.WriteLine("Hi");
11. }
12. catch(Exception e)
13. {
14. Console.WriteLine("hello");
15. }
16. }
17. }
a) Hi
b) hello
c) Hihello
d) Compile time error
View Answer
Answer: b
Explanation: None.
5. Which of the keywords used for the block to be examined for exceptions?
a) try
b) catch
c) throw
d) check
View Answer
Answer: a
Explanation: try is used for the block that needs to checked for exception.
6. Which of these keywords are used for the block to handle the exceptions
generated by try block?
a) try
b) catch
c) throw
d) check
View Answer
Answer :b
Explanation: None.
7. What is the output of this program?
1. class Output
2. {
3. public static void main(String args[])
4. {
5. try
6. {
7. int a = 5;
8. int b = 10;
9. int c = b / a - 5;
10. Console.WriteLine("Csharp");
11. }
12. }
13. }
a) Csharp
b) sharp
c) C
d) Compile time error
View Answer
Answer: d
Explanation: try should be followed by either catch or finally.
8. What is the output of the given code snippet?
1. class Output
2. {
3. public static void main(String args[])
4. {
5. try
6. {
7. int a = 0;
8. int b = 5;
9. int c = a / b - 5;
10. Console.WriteLine("C");
11. }
12. finally
13. {
14. Console.WriteLine("sharp");
15. }
16. }
17. }
a) C
b) sharp
c) Csharp
d) None of the mentioned
View Answer
Answer: c
Explanation: finally block is always executed after try block, no matter exception is found or not.
9. What will be the output of code snippet?
1. class Output
2. {
3. public static void main(String args[])
4. {
5. try
6. {
7. int a = 10;
8. int b = 5;
9. int c = b - 5 / 5;
10. Console.WriteLine("Hi");
11. }
12. catch(Exception e)
13. {
14. Console.WriteLine("hello");
15. }
16. }
17. }
a) Hi
b) hello
c) Hihello
d) Compile time error
View Answer
Answer: a
Explanation: None.
10. Which of these keywords are used for generating an exception manually?
a) try
b) catch
c) throw
d) check
View Answer
Answer: c
Explanation: None.
1. Once applied and hence further which of the following cannot inspect the
applied attribute?
a) Linker
b) ASP.NET Runtime
c) Language compilers
d) CLR
View Answer
Answer :a
Explanation : None.
2. To apply an attribute to an Assembly the correct way of implementation is?
a) [AssemblyInfo: AssemblyDescription ("Csharp")]
b) [assembly: AssemblyDescription("Csharp")]
c) [AssemblyDescription("Csharp")]
d) (Assembly:AssemblyDescription(Csharp)]
View Answer
Answer :b
Explanation : None.
3. The correct method to pass parameter to an attribute is?
a) By name
b) By address
c) By position
d) By reference
View Answer
Answer :c, a
Explanation : None.
4. Which is the correct form of applying an attribute?
a)class sample
{
}
b)(Serializable())class sample
{
}
c)[Serializable()] class sample
{
}
d) None of the mentioned
View Answer
Answer :c
Explanation : By definition.
5. Which among the following cannot be a target for a custom attribute?
a) Enum
b) Event
c) Interface
d) Namespace
View Answer
Answer :d
Explanation : None.
6. Select the correct statement about Attributes used in C#.NET?
a) The CLR can change the behaviour of the code depending on attributes
apllied to it
b) If a bugFixAttribute is to recieve three paramteres so the BugFixAttribute class
should implement a zero arguement constructor
c) To create a custom attribute we need to create a custom attribute structure
and derive it from System.Attribute
d) None of the mentioned
View Answer
Answer :a
Explanation : None.
7. The correct way to apply the custom attribute called Employer which receives
two arguements name of the employee and employeeid?
a) Custom attribute cannot be applied to an assembly
b) [assembly : Employer("Ankit",employeeid.one)]
c) [ Employer("Ankit", employeeid.second)] class employee
{
}
d) Custom attribute cannot be applied to a class
View Answer
Answer : b, c
Explanation : None.
8. Which is correct statement about inspecting an attribute in C#.NET?
a) An attribute can be inspected at link time
b) An attribute can be inspected at design time
c) An attribute can be inspected at run time
d) None of the mentioned
View Answer
Answer : a
Explanation : None.
9. Attributes could be applied to
a) Method
b) Class
c) Assembly
d) Enum
View Answer
Answer : a, b, c
Explanation : None.
10. The [Serializable()] attributes gets inspected at:
a) compile time
b) run time
c) design time
d) linking time
View Answer
Answer : b
Explanation : None.

1. Which of the class provides the operation of reading from and writing to the
console in C#.NET?
a) System.Array
b) System.Output
c) System.ReadLine
d) System.Console
View Answer
Answer :d
Explanation :The method for reading and writing to the console in C#.NET is provided by
System.Console class.This class gives us access to the standard input,output and standard error
streams.
2. Which of the given stream method provides the access to the output console
by default in C#.NET?
a) Console.In
b) Console.Out
c) Console.Error
d) All of the mentioned
View Answer
Answer :b
Explanation :The standard output stream Console.Out sends output to the screen by default.
3. Which of the given stream method provides the access to the input console in
C#.NET?
a) Console.Out
b) Console.Error
c) Console.In
d) All of the mentioned
View Answer
Answer :c
Explanation : Console.In is an instance of TextReader, and we can use the methods and properties
defined by TextReader to access it to read the input from the keyboard.
4. The number of input methods defined by the stream method Console.In in
C#.NET is?
a) 4
b) 3
c) 2
d) 1
View Answer
Answer :b
Explanation :Two basic methods : read() and readline() and third method readkey() introduced in
.NET FrameWork 2.0.
5. Select the correct methodS provided by Console.In?
a) Read(), ReadLine()
b) ReadKey(), ReadLine()
c) Read(), ReadLine(), ReadKey()
d) ReadKey(), ReadLine()
View Answer
Answer :c
Explanation :The two method Read() and ReadLine() available in .NET Framework 1.0 and Third
method ReadKey() was added by .NET Framework 2.0.
6. Choose the output return when read() reads the character from the console?
a) String
b) Char
c) Integer
d) Boolean
View Answer
Answer :c
Explanation : Read() returns the character read from the console. It returns the result. The character
is returned as an int, which should be cast to char.
7. Choose the output returned when error condition generates while read() reads
from the console.
a) False
b) 0
c) -1
d) All of the mentioned
View Answer
Answer :c
Explanation : Read() returns 1 on error. This method also throws an IOException on failure.
8. Choose the object of TextReader class.
a) Console.In
b) Console.Out
c) Console.Error
d) None of the mentioned
View Answer
Answer :a
Explanation :Console.In is an instance(object) of TextReader class and we can use the methods and
properties defined by TextReader to invoke the object console.in.
9. Choose the object/objects defined by the Textwriter class.
a) Console.In
b) Console.Out
c) Console.Error
d) None of the mentioned
View Answer
Answer :b, c
Explanation :Console.Out and Console.Error are objects of type TextWriter class.
10. Choose the output for the given set of code:
1. static void Main(string[] args)
2. {
3. int a = 10, b = 0;
4. int result;
5. Console.Out.WriteLine("This will generate an exception.");
6. try
7. {
8. result = a / b; // generate an exception
9. }
10. catch (DivideByZeroException exc)
11. {
12. Console.Error.WriteLine(exc.Message);
13. }
14. Console.ReadLine();
15. }
a) This will generate an exception
b) 0
c) Compile time error
d) This will generate an exception
Attempted to Divide by Zero
View Answer
Answer :d
Explanation : None.
11. Choose the methods provided by Console.Out and Console.Error?
a) Write
b) WriteLine
c) WriteKey
d) All of the mentioned
View Answer
Answer: a, b
Explanation : None.
12. Choose the output for following set of code?
1. static void Main(string[] args)
2. {
3. Console.WriteLine("This is a Console Application:");
4. Console.Write("Please enter your lucky number:");
5. string val1 = Console.ReadLine();
6. int val2 = System.Convert.ToInt32(val1, 10);
7. val2 = val2 * val2;
8. Console.WriteLine("square of number is:" +val2);
9. Console.Read();
10. }
a) Compile time error
b) Run successfully donot prints anything
c) Run successfully ask for input and hence display the results
d) Syntax Error
View Answer
Answer :c
Explanation :None.
Output : This is a Console Application:
Please enter your lucky number: 3
Square of number is : 9

1. Name the exception thrown by read() on failure.


a) InterruptedException
b) SystemException
c) SystemInputException
d) I/O Exception
View Answer
Answer :d
Explanation : read() throws I/O exception on failure.
2. Which of these method used to read single character from the console?
a) get()
b) getline()
c) read()
d) readLine()
View Answer
Answer :c
Explanation : None.
3. Which of these method used to read string from the console?
a) get()
b) getline()
c) read()
d) readLine()
View Answer
Answer :d
Explanation : None.
4. Which among the following methods used writes characters to a string?
a) StreamWriter
b) StreamReader
c) StringWriter
d) None of the mentioned
View Answer
Answer :c
Explanation :The stream class method writes characters to the string.
5. Which method in Console enables to read individual inputs directly from the
keyboard in a non line buffered manner?
a) Read()
b) ReadKey()
c) ReadLine()
d) All of the mentioned
View Answer
Answer :b
Explanation : The .NET Framework includes a method in Console that enables you to read individual
keystrokes directly from the keyboard, in a non-line-buffered manner. This method is called
ReadKey().When it is called, it waits until a key is pressed. When a key is pressed, ReadKey( )
returns the keystroke immediately.
6. What is output returned by Console if ReadLine() stores I/O error?
a) 1
b) 0
c) False
d) I/O EXCEPTION ERROR
View Answer
Answer :d
Explanation : None.
7. What would be the output for following input from the console as a character?
1. static void Main(string[] args)
2. {
3. Console.WriteLine("what is your name?");
4. char s;
5. s = Convert.ToChar(Console.ReadLine());
6. Console.WriteLine("how are you: "+s);
7. Console.Read();
8. }
a) Compile time error
b) Code run successfully prints nothing on console
c) Code run successfully prints input on console
d) Run time error
View Answer
Answer :d
Explanation : Since only a single character is required being to be entered on console when a string
is entered hence a run time exception is being generated as we had not used Read() which reads
single character but used readLine() which reads string and converted it into the char using
convert.tochar().
8. Name the method/methods used to read byte streams from the file?
a) ReadByte()
b) Read()
c) Readkey()
d) None of the mentioned
View Answer
Answer :a, b
Explanation : None.
9. Which of these classes are used by Byte streams for input and output
operation?
a) InputStream
b) InputOutputStream
c) Reader
d) All of the mentioned
View Answer
Answer :b
Explanation :Byte stream uses InputStream and OutputStream classes for input and output
operation.
10. Which of these method/methods used to read block or array of bytes from the
file?
a) Read()
b) ReadByte()
c) ReadLine()
d) Readkey()
View Answer
Answer :a
Explanation :To read a block of bytes, use Read( ), which has this general form:
int Read(byte[ ] array, int offset, int count)

1. Select the namespace on which the stream classes are defined?


a) System.IO
b) System.Input
c) System.Output
d) All of the mentioned
View Answer
Answer: a
Explanation: The core stream classes are defined within the System.IO namespace. To use these
classes, you will usually include the following statement near the top of your program: using
System.IO;
2. Choose the class on which all stream classes are defined?
a) System.IO.stream
b) Sytem.Input.stream
c) System.Output.stream
d) All of the mentioned
View Answer
Answer: a
Explanation: The core stream class is System.IO.Stream. Stream represents a byte stream and is a
base class for all other stream classes. It is also abstract, which means that you cannot instantiate a
Stream object. Stream defines a set of standard stream operations.
3. Choose the stream class method which is used to close the connection:
a) close()
b) static close()
c) void close()
d) none of the mentioned
View Answer
Answer: c
Explanation: void close() closes the stream.
4. A method used to write a single byte to an output stream?
a) void WriteByte(byte value)
b) int Write(byte[] buffer ,int offset ,int count)
c) write()
d) None of the mentioned
View Answer
Answer: a
Explanation: Writes a single byte to an output stream.
5. Select the method which writes the contents of the stream to the physical
device.
a) fflush()
b) void fflush()
c) void Flush()
d) flush()
View Answer
Answer: c
Explanation: The method used to write the contents of the stream to the physical device.
6. Select the method which returns the number of bytes from the array buffer:
a) void WriteByte(byte value)
b) int Write(byte[] buffer ,int offset ,int count)
c) write()
d) None of the mentioned
View Answer
Answer: b
Explanation: Writes a subrange of count bytes from the array buffer,beginning at buffer[offset],
returning the number of bytes written.
7. Name the method which returns integer as -1 when the end of file is
encountered.
a) int read()
b) int ReadByte()
c) void readbyte()
d) None of the mentioned
View Answer
Answer: b
Explanation : Returns an integer representation of the next available byte of input. Returns 1 when
the end of the file is encountered.
8. Select the statements which defines the stream.
a) A stream is an abstraction that produces or consumes information
b) A stream is linked to a physical device by the I/0 system
c) C# programs perform I/O through streams
d) All of the mentioned
View Answer
Answer: d
Explanation : None.
9. Select the action of the method long seek()?
a) Attempts to readup to count bytes into buffer starting at buffer[offset]
b) Writes a single byte to an output stream
c) Sets the current position in the stream to the specified offset from specified
origin and hence returns the new position
d) None of the mentioned
View Answer
Answer: c
Explanation : long Seek(long offset, SeekOrigin origin)
Sets the current position in the stream to the specified offset from the specified origin. It returns the
new position.
10. Attempts to read up to count bytes into buffer starting at buffer[offset],
returning the number of bytes successfully read?
a) int ReadByte()
b) int Read(byte[] buffer ,int offset ,int count)
c) Void WriteByte(byte value)
d) None of the mentioned
View Answer
Answer: b
Explanation : None.

1.Which of these class is used to read and write bytes in a file?


a) FileReader
b) FileWriter
c) FileInputStream
d) InputStreamReader
View Answer
Answer: c
Explanation: None.
2. Which of these data type is returned by every method of OutputStream?
a) int
b) float
c) byte
d) None of the mentioned
View Answer
Answer: d
Explanation:Every method of OutputStream returns void and throws an IOExeption in case of errors.
3. Which of these classes is used for input and output operation when working
with bytes?
a) InputStream
b) Reader
c) Writer
d) All of the mentioned
View Answer
Answer: a
Explanation: InputStream & OutputStream are designed for byte stream. Reader and writer are
designed for character stream.
4. Which among is used for storage of memory aspects?
a) BufferedStream
b) FileStream
c) MemoryStream
d) None of the mentioned
View Answer
Answer: c
Explanation : A byte stream that uses memory for storage.
5. Which among is used for storage of unmanaged memory aspects?
a) BufferedStream
b) FileStream
c) MemoryStream
d) UnmanagedMemoryStream
View Answer
Answer: d
Explanation : A byte stream that uses unmanaged memory for storage.
6. Name the property among the following which represents the current position
of the stream.
a) long Length
b) long Position
c) int Length
d) All of the mentioned
View Answer
Answer: a
Explanation : This property contains the length of the stream. This property is read-only.
7. Choose the filemode method which is used to create a new output file with
condition that file with same name must not existed:
a) FileMode.CreateNew
b) FileMode.Create
c) FileMode.OpenOrCreate
d) FileMode.Truncate
View Answer
Answer: a
Explanation : Creates a new output file. The file must not already exist.
8. Choose the filemode method which is used to create a new output file with
condition that file with same name if existed it destroyes the old file:
a) FileMode.CreateNew
b) FileMode.Create
c) FileMode.OpenOrCreate
d) FileMode.Truncate
View Answer
Answer: b
Explanation : Creates a new output file. Any preexisting file by the same name will be destroyed.
9. Which of these is a method to clear all the data present in output buffers?
a) clear()
b) flush()
c) fflush()
d) close()
View Answer
Answer: b
Explanation : None.
10. Which of these is method is used for reading bytes from the file?
a) Read()
b) ReadByte()
c) put()
d) write()
View Answer
Answer: a ,b
Explanation :FileStream defines two methods that read bytes from a file: ReadByte() and Read().
1. From Which of these classes the character based output stream class Stream
Writer is derived?
a) TextWriter
b) TextReader
c) Character Stream
d) All of the mentioned
View Answer
Answer: a
Explanation: StreamWriter is derived from TextWriter.To create a character-based output stream,
wrap a Stream object (such as a FileStream) inside a StreamWriter
2. The advantages of using character stream based file handling are?
a) they operate directly on unicode characters
b) they operate directly on bits
c) If desired to store unicode text
d) all of the mentioned
View Answer
Answer: a, c
Explanation: Although byte-oriented file handling is quite common, it is possible to use character-
based streams for this purpose. The advantage to the character streams is that they operate directly
on Unicode characters. Thus, if you want to store Unicode text, the character streams are certainly
your best option.
3. To perform the character based file operations select the classes among the
following?
a) StreamReader
b) StreamWriter
c) InputStream
d) OutputStream
View Answer
Answer: a, b
Explanation: In general, to perform character-based file operations, wrap a FileStream inside either a
StreamReader or a StreamWriter. These classes automatically convert a byte stream into a
character stream, and vice versa.
4. Which of these is a method to clear all the data present in output buffers?
a) clear()
b) flush()
c) fflush()
d) close()
View Answer
Answer: b
Explanation: None.
5. Which method of character stream class returns the numbers of characters
successfully read starting at index?
a) int Read()
b) int Read(char[] buffer, int index, int count)
c) int ReadBlock(char[ ] buffer, int index, int count)
d) None of the mentioned
View Answer
Answer: c
Explanation: Attempts to read up to count characters into buffer starting at buffer[index], returning
the number of characters successfully read.
6. Which method of character stream class returns the numbers of characters
successfully read starting at count?
a) int Read()
b) int Read(char[] buffer, int index, int count)
c) int ReadBlock(char[ ] buffer, int index, int count)
d) None of the mentioned
View Answer
Answer: b
Explanation: Attempts to read up to count characters into buffer starting at buffer[count], returning
the number of characters successfully read.
7. Which method among the given returns the integer if no character is available?
a) int peek()
b) int read()
c) string ReadLine()
d) None of the mentioned
View Answer
Answer: a
Explanation: Obtains the next character from the input stream, but does not remove that character.
Returns 1 if no character is available.
8. Which of these is used to perform all input & output operations in C#?
a) streams
b) Variables
c) classes
d) Methods
View Answer
Answer: a
Explanation: streams are used for input and output operations in any programming language.
9. Which of these is a type of stream in C#?
a) Integer stream
b) character stream
c) Byte stream
d) Long stream
View Answer
Answer: b, c
Explanation: Two types of streams Byte stream and character stream are defined in C# sharp.
10. In the given constructor decleration for character based file operation what
does path and bool specifies?
StreamWriter(string path, bool append)
a) the name of the file to open
b) specifies the full path of file
c) if append is true, so the file is appended to the end of the existing file
d) None of the mentioned
View Answer
Answer: a, b, c
Explanation: StreamWriter(string path, bool append) .Here, path specifies the name of the file to
open, which can include a full path specifier. In the second form, if append is true, then output is
appended to the end of an existing file Otherwise, output overwrites the specified file.

1. Among from the following ref keyword can be used with?


a) static function/subroutine
b) static data
c) Instance function/subroutine
d) instance data
View Answer
Answer: a, c
Explanation: None.
2. To implement delegates the necessary condition for implementation is?
a) class decleration
b) inheritance
c) run time polymorphism
d) exceptions
View Answer
Answer: a
Explanation: None.
3. Suppose a Generic class called as SortObjects is to made capable of sorting
objects of any type(integer, single, byte etc).Hence, which following programming
construct is able to implement the comparision function?
a) interface
b) encapsulation
c) delegate
d) attribute
View Answer
Answer: c
Explanation: None.
4. To generate a simple notification for an object on runtime the programming
construct to be used for implementation this idea?
a) namespace
b) interface
c) delegate
d) attribute
View Answer
Answer: c
Explanation: None.
5. Choose the incorrect statement about the delegate?
a) delegate are of reference types
b) delegates are object oriented
c) delegates are type safe
d) none of the mentioned
View Answer
Answer: d
Explanation: None.
6. Correct statement about delegate declaration given below is ?
delegate void del(int i);
a) On declaring the delegate a class called del is created
b) the del class is derived from the MulticastDelegate class
c) the del class will contain a one arguement constructor and an invoke() method
d) none of the mentioned
View Answer
Answer: a, b, e
Explanation: None.
7. Which is the incorrect statement about delegate?
a) A single delegate can invoke more than one method
b) delegates could be shared
c) delegates are type safe wrappers for funtion pointers
d) delegate is a value type
View Answer
Answer: c
Explanation: None.
8. Choose statements which differentiate delegate in C#.NET than a
conventional function pointer in other languages?
a) delegate in C#.NET represent a new type in the Comman Type System
b) delegate allow static as well as instance methods to be invoked
c) delegate are type safe and secure
d) none of the mentioned
View Answer
Answer: d
Explanation: None.
9. Choose incorrect statement about the delegates?
a) delegates are not type safe
b) delegates cannot be used to implement callback notification
c) delegates is a user defined type
d) delegates permits execution of a method on in an asynchronous manner
View Answer
Answer: a, b
Explanation: None.
10. Which statement is correct about a delegate?
a) inheritance is a prerequisite for using delegates
b) delegates are type safe
c) delegates provides wrappers for function pointers
d) none of thee mentioned
View Answer
Answer: b, c
Explanation: None.

1. Choose the correct way to call subroutine fun() of the sample class?
1. class a
2. {
3. public void x(int p, double k)
4. {
5. Console.WriteLine("k : csharp!");
6. }
7. }
a) delegate void del(int i);
x s = new x();
del d = new del(ref s.x);
d(8, 2.2f);
b) delegate void del(int p, double k);
del d;
x s = new x();
d = new del(ref s.x);
d(8, 2.2f);
c) x s = new x();
delegate void d = new del(ref x);
d(8, 2.2f);
d) all of the mentioned
View Answer
Answer: b
Explanation: None.
2. Which is the correct way to call the function abc() of the given class csharp
given below?
1. class csharp
2. {
3. public int abc(int a)
4. {
5. Console.WriteLine("A:Just do it!");
6. return 0;
7. }
8. }
a) delegate void del(int a);
csharp s = new csharp();
del d = new del(ref s.abc);
d(10);
b) csharp s = new csharp();
delegate void d = new del(ref abc);
d(10);
c) delegate int del(int a);
del d;
csharp s = new csharp();
d = new del(ref s.fun);
d(10);
d) none of the mentioned
View Answer
Answer: c
Explanation: None.
3. Which is the correct way to call the subroutine function abc() of the given class
csharp given below?
1. class csharp
2. {
3. void abc()
4. {
5. console.writeline("A:Just do it!");
6. }
7. }
a) csharp c = new csharp();
delegate void d = new del(ref abc);
d();
b) delegate void del();
del d;
csharp s = new csharp();
d = new del(ref s.abc);
d();
c) delegate void del();
abc s = new abc();
del d = new del(ref s.abc);
d();
d) csharp s = new csharp();
delegate void del = new delegate(ref abc);
del();
View Answer
Answer: b, c
Explanation: None.
4. What will be the output of the given code snippet below?
1. {
2. delegate void A(ref string str);
3. class sample
4. {
5. public static void fun( ref string a)
6. {
7. a = a.Substring( 7, a.Length - 7);
8. }
9. }
10. class Program
11. {
12. static void Main(string[] args)
13. {
14. A str1;
15. string str = "Test Your C#.net skills";
16. str1 = sample.fun;
17. str1(ref str);
18. Console.WriteLine(str);
19. }
20. }
21. }
a) Test Your
b) ur C#.NET
c) ur C#.NET Skills
d) None of the mentioned
View Answer
Answer: c
Explanation: None.
5. What will be the output of the given code snippet below?
1. {
2. delegate string F(string str);
3. class sample
4. {
5. public static string fun(string a)
6. {
7. return a.Replace(',''-');
8. }
9. }
10. class Program
11. {
12. static void Main(string[] args)
13. {
14. F str1 = new F(sample.fun);
15. string str = str1("Test Your c#.NET skills");
16. Console.WriteLine(str);
17. }
18. }
19. }
a) Test Your
b) Test-Your-C#.NET-Skills
c) ur C#.NET Skills
d) None of the mentioned
View Answer
Answer: b
Explanation: None.
Output: Test-Your-C#.NET-Skills
6. Choose the statements which makes delegate in C#.NET different than a
normal class?
a) Delegates in C#.NET is a base class for all delegates type
b) From Delegates created in C#.NET further not allowed to derive from the
delegate types that are created
c) Only system and compilers can derive explicitly from the Delegate or
MulticasteDelegate class
d) All of the mentioned
View Answer
Answer: d
Explanation: None.
7. Which are the correct statement about delegates?
a) Delegates can be used to implement callback notification
b) Delegates permit execution of a method on a secondary thread in an
asynchronous manner
d) Delegate is a user defined type
e) None of the mentioned
View Answer
Answer: a, b, c
Explanation: None.
8. What will be the output of given set of code?
1. {
2. delegate string f(string str);
3. class sample
4. {
5. public static string fun(string a)
6. {
7. return a.Replace('k', 'o');
8. }
9. }
10. class Program
11. {
12. static void Main(string[] args)
13. {
14. f str1 = new f(sample.fun);
15. string str = str1("Test Ykur C#.NET Skills");
16. Console.WriteLine(str);
17. Console.ReadLine();
18. }
19. }
20. }
a) Test Ykur C#.NET Skills
b) Test Ykour C#.NET Skills
c) Test Your C#.NET Skills
d) Test ur C#.NET Skills
View Answer
Answer: c
Explanation: None.
Output: Test Your C#.NET Skills
9. Incorrect statement about delegates are?
a) Delegates are reference types
b) Delegates are object oriented
c) Delegates are type safe
d) Only one method can be called using a delegate
View Answer
Answer: d
Explanation: None.
10. Select the modifiers which controls the accessibility of the delegate:
a) new
b) protected
c) public
d) internal
View Answer
Answer: a, b, c, d
Explanation: By definition

1. What is meant by the term generics?


a) parameterized types
b) class
c) structure
d) interface
View Answer
Answer: a
Explanation: The term generics means parameterized types. Parameterized types are important
because they enable us to create classes, structures, interfaces, methods, and delegates in which
the type of data upon which they operate is specified as a parameter.
2. Are generics in C# are same as the generics in java and templates in C++?
a) Yes
b) No
c) May be
d) None of the mentioned
View Answer
Answer: b
Explanation: Although C# generics are similar to templates in C++ and generics in Java, they are not
the same as either. In fact, there are some fundamental differences among these three approaches
to generics
3. Choose the advantages of using generics?
a) Generics facilitate type safety
b) Generics facilitate improved performance and reduced code
c) Generics promote the usage of parameterized types
d) All of the mentioned
View Answer
Answer: d
Explanation: By definition of generics.
4. What does the following code block defines?
1. class Gen<T> {
2. T ob;
3. }
a) Generics class decleration
b) Decleration of variable
c) a simple class decleration
d) All of the mentioned
View Answer
Answer: a, b
Explanation: class Gen This defines the generics decleration where T is the name of type
parameter. This parameter is used as a placeholder for the actual type that will be specified when a
Gen object is created. Gen is a generic class. T is used to declare a variable called ob.

5. What does the following code set defines?


1. public Gen(T o) {
2. ob = o;
3. }
a) Generics class decleration
b) Decleration of variable
c) Generic constructor decleration
d) All of the mentioned
View Answer
Answer: c
Explanation: None.
6. Select the type arguement of open constructed type?
a) Gen
b) Gen
c) Gen<>
d) None of the mentioned
View Answer
Answer: c
Explanation: A generic type, such as Gen, is an abstraction.In C# terminology, a construct such as
Gen is called an open constructed type, because the type parameter T (rather than an actual type,
such as int) is specified.

7. Which among the given classes present in


System.Collection.Generic.namespace?
a) Stack
b) Tree
c) Sorted Array
d) All of the mentioned
View Answer
Answer: a
Explanation: None.
8. Which of these is an correct way of defining generic method?
a) name(T1, T2, , Tn) { /* */ }
b) public name { /* */ }
c) class name[T1, T2, ..., Tn] { /* */ }
d) name{T1, T2, , Tn} { /* */ }
View Answer
Answer: b
Explanation: The syntax for a generic method includes a type parameter, inside angle brackets, and
appears before the methods return type. For static generic methods, the type parameter section
must appear before the methods return type.
9. Which of these type parameters is used for a generic methods to return and
accept any type of object?
a) K
b) N
c) T
d) V
View Answer
Answer: c
Explanation: T is used for type, A type variable can be any non-primitive type you specify: any class
type, any interface type, any array type, or even another type variable.
10. Choose the correct way to call subroutine fun() of the sample class?
1. class a
2. {
3. public void x(int p, double k)
4. {
5. Console.WriteLine("k : csharp!");
6. }
7. }
a) delegate void del(int i);
x s = new x();
del d = new del(ref s.x);
d(8, 2.2f);
b) delegate void del(int p, double k);
del d;
x s = new x();
d = new del(ref s.x);
d(8, 2.2f);
c) x s = new x();
delegate void d = new del(ref x);
d(8, 2.2f);
d) all of the mentioned
View Answer
Answer: b
Explanation: None.
11. What will be the output of given code snippet?
1. public class Generic<T>
2. {
3. Stack<T> stk = new Stack<T>();
4. public void push(T obj)
5. {
6. stk.Push(obj);
7. }
8. public T pop()
9. {
10. T obj = stk.Pop();
11. return obj;
12. }
13. }
14. class Program
15. {
16. static void Main(string[] args)
17. {
18. Generic<string> g = new Generic<string>();
19. g.push(40);
20. Console.WriteLine(g.pop());
21. Console.ReadLine();
22. }
23. }
a) 0
b) Runtime Error
c) 40
d) Compile time Error
View Answer
Answer: c
Explanation: None.
Output : 40.
10. What will be the output of given code snippet?
1. public class Generic<T>
2. {
3. Stack<T> stk = new Stack<T>();
4. public void push(T obj)
5. {
6. stk.Push(obj);
7. }
8. public T pop()
9. {
10. T obj = stk.Pop();
11. return obj;
12. }
13. }
14. class Program
15. {
16. static void Main(string[] args)
17. {
18. Generic<int> g = new Generic<int>();
19. g.push("Csharp");
20. Console.WriteLine(g.pop());
21. Console.ReadLine();
22. }
23. }
a) Compile time error
b) Csharp
c) 0
d) Run time error
View Answer
Answer: b
Explanation: None.
Output : Csharp

1. For the code set given below,which of the following statements are perfectly
valid?
1. public class MyContainer<T> where T: class, IComparable
2. {
3. /* insert code here */
4. }
a) Class MyConatiner requires that its type arguement must implement
Icomparable interface
b) There are multiple constraints on type arguement to MyConatiner class
c) Compiler will report an error
d) None of the mentioned
View Answer
Answer: b
Explanation: None.
2. For the code given below which statements are perfectly valid?
1. public class Csharp
2. {
3. public void subject<S>(S arg)
4. {
5. Console.WriteLine(arg);
6. }
7. }
8. class Program
9. {
10. static Void Main(string[] args)
11. {
12. Csharp c = new Csharp();
13. c.subject("hi");
14. c.subject(20);
15. }
16. }
a) Run time exception error
b) Compile time error
c) Code run successfully and print required output
d) None of the mentioned
View Answer
Answer: c
Output : hi
20
3. Which of given statements are valid about generics in .NET Framework?
a) generics are useful in collection classes in .NET framework
b) generics delegates are not allowed in C#.NET
c) generics is a language feature
d) All of the mentioned
View Answer
Answer: c, a
Explanation: None.
4. Which statement are valid for the given snippet of code:
1. public class Generic<T>
2. {
3. public T Field;
4. }
5. class Program
6. {
7. static void Main(string[] args)
8. {
9. Generic<String> g = new Generic<String>();
10. g.Field = "Hi";
11. Console.WriteLine(g.Field);
12. }
13. }
a) Compile time error
b) Generic being a keyword cannot be used as a class name
c) run time error
d) Code runs successfully
View Answer
Answer: d
Output : Hello
5. Choose the output for given set of code:
1. public class Generic<T>
2. {
3. public T Field;
4. }
5. class Program
6. {
7. static void Main(string[] args)
8. {
9. Generic<int> g2 = new Generic<int>();
10. Generic<int> g3 = new Generic<int>();
11. g2.Field = 8;
12. g3.Field = 4;
13. if (g2.Field % g3.Field == 0)
14. {
15. Console.WriteLine("A");
16. }
17. else
18. Console.WriteLine("Prints nothing:");
19. Console.ReadLine();
20. }
21. }
a) Compile time error
b) A
c) run time error
d) Code runs successfully but prints nothing
View Answer
Answer: b
Output : A
6. Correct statement valid about generic procedures in C#.NET are?
a) All procedures in a Generic class are generic
b) Generic procedures should take at least one type parameter
c) Only those procedures labeled as Generic are Generic
d) None of the mentioned
View Answer
Answer: b
Explanation: None.
7. For the code set given below,which of the following statements are perfectly
valid?
1. public class MyContainer<T> where T: IComparable
2. {
3. /* insert code here */
4. }
a) Class MyConatiner requires that its type arguement must implement
Icomparable interface
b) There are multiple constraints on type arguement to MyContainer class
c) Type arguement of class MyContainer should be Icomparable
d) None of the mentioned
View Answer
Answer: a
Explanation: None.
8. Choose the statements which are valid for given code snippet:
1. public class Generic<T>
2. {
3. public T Field;
4. public void testSub()
5. {
6. T i = Field + 1;
7. }
8. }
9. class Program
10. {
11. static void Main(string[] args)
12. {
13. Generic<int>g = new Generic<int>();
14. g.testSub();
15. }
16. }
a) code run successfully print nothing
b) code run successfully print 1
c) Program will give run time error
d) Compile time error
View Answer
Answer: d
Explanation: compiler will give error as operator + is not defined for types T and int
9. Which among the given class represents System.Collections.Generic
namespace?
a) SortedDictionary
b) Sorted Array
c) Stack
d) Tree
View Answer
Answer: a, c
Explanation: None.
10. What will be the output of given code snippet?
1. public class Generic<T>
2. {
3. Stack<T> stk = new Stack<T>();
4. public void push(T obj)
5. {
6. stk.Push(obj);
7. }
8. public T pop()
9. {
10. T obj = stk.Pop();
11. return obj;
12. }
13. }
14. class Program
15. {
16. static void Main(string[] args)
17. {
18. Generic<int> g = new Generic<int>();
19. g.push("Csharp");
20. Console.WriteLine(g.pop());
21. Console.ReadLine();
22. }
23. }
a) Compile time error
b) Csharp
c) 0
d) Run time error
View Answer
Answer: b
Output : Csharp
11. What will be the output of given code snippet?
1. public class Generic<T>
2. {
3. Stack<T> stk = new Stack<T>();
4. public void push(T obj)
5. {
6. stk.Push(obj);
7. }
8. public T pop()
9. {
10. T obj = stk.Pop();
11. return obj;
12. }
13. }
14. class Program
15. {
16. static void Main(string[] args)
17. {
18. Generic<string> g = new Generic<string>();
19. g.push(30);
20. Console.WriteLine(g.pop());
21. Console.ReadLine();
22. }
23. }
a) 0
b) 30
c) Runtime Error
d) Compile time Error
View Answer
Answer: b
Explanation: None.
Output : 30.
12. What will be the output of given code snippet?
1. public class Generic<T>
2. {
3. Stack<T> stk = new Stack<T>();
4. public void push(T obj)
5. {
6. stk.Push(obj);
7. }
8. public T pop()
9. {
10. T obj = stk.Pop();
11. return obj;
12. }
13. }
14. class Program
15. {
16. static void Main(string[] args)
17. {
18. Generic<string> g = new Generic<string>();
19. g.push("C++");
20. Console.WriteLine(g.pop() + " ");
21. Generic<int> g1 = new Generic<int>();
22. g1.push(20);
23. Console.WriteLine(g1.pop());
24. Console.ReadLine();
25. }
26. }
a) C++
b) 20
c) C++
20
d) 0
View Answer
Answer: c
Explanation: None.
Output : C++
20
1. Assume 2 columns named as Product and Category how can be both sorted
out based on first by category and then by product name?
a) var sortedProds = _db.Products.Orderby(c => c.Category)
b) var sortedProds = _db.Products.Orderby(c => c.Category) + ThenBy(n =>
n.Name)
c) var sortedProds = _db.Products.Orderby(c => c.Category) . ThenBy(n =>
n.Name)
d) All of the mentioned
View Answer
Answer: c
Explanation: var sortedProds = _db.Products.Orderby(c => c.Category) . ThenBy(n => n.Name).
2. Choose the correct statements about the LINQ?
a) The main concept behind the linq is query
b) linq make use of foreach loop to execute the query
c) It is not required that linq should make use of IEnumerable interface
d) None of the mentioned
View Answer
Answer: a, b
Explanation: LINQ at core is the query.A query specifies what data will be obtained from a data
source.Query in linq is executed using foreach loop.In order for a source of data to be used by LINQ,
it must implement the IEnumerable interface.
3. Choose the namespace in which the interface IEnumerable is declared?
a) System.Collections
b) System.Collections.Generic
c) Both a & b
d) None of the mentioned
View Answer
Answer: b
Explanation: By definition.
4. Can we use linq to query against a DataTable?
a) Yes
b) No
c) Either a or b
d) None of the mentioned
View Answer
Answer: b
Explanation: We, cannot query against the DataTables Rows collection, since DataRowCollection
doesnt implement IEnumerable. We need to use the AsEnumerable() extension for DataTable. As
an example:
var results = from myRow in myDataTable.AsEnumerable()
where myRow.Field(RowNo) == 1
select myRow;

5. What will be the output of given code snippet?


1. class Program
2. {
3. static void Main(string[] args)
4. {
5. int[] nums = { 1, -2, 3, 0, -4, 5};
6. var posNums = from n in nums
7. where n >= 0
8. select n;
9. foreach (int i in posNums)
10. Console.Write(i + " ");
11. Console.WriteLine();
12. Console.ReadLine();
13. }
14. }
a) 0, 1, -2, -4, 5
b) 1, 3, 0, 5
c) 1, 3, 5
d) Run time error
View Answer
Answer: b
Explanation: A simple linq query generated program to show a query is implemented using linq.
Output : 1, 3, 0, 5
6. Select the namespace which should be included while making use of LINQ
operations:
a) System.Text
b) System.Collections.Generic
c) System.Linq
d) None of the mentioned
View Answer
Answer: c
Explanation: By definition.
7. Select the output for given code snippet:
1. class Program
2. {
3. static void Main(string[] args)
4. {
5. int[] nums = { 1, -2, 3, 0, -4, 5 };
6. var posNums = from n in nums
7. where n % 2 ==0
8. select n;
9. Console.Write("The positive values in nums: ");
10. foreach (int i in posNums) Console.Write(i + " ");
11. Console.WriteLine();
12. Console.ReadLine();
13. }
14. }
a) code run successfully prints nothing
b) run time error
c) code run successfully and execute output
d) compile time error
View Answer
Answer: c
Explanation: -2, 0, -4
8. Select the output for given code snippet:
1. class Program
2. {
3. static void Main(string[] args)
4. {
5. int[] nums = { 1, -2, 3, 0, -4, 5 };
6. var posNums = from n in nums
7. where n > -5 && n < 6
8. orderby n descending
9. select n;
10. Console.Write("The positive values in nums: ");
11. foreach (int i in posNums) Console.Write(i + " ");
12. Console.WriteLine();
13. Console.ReadLine();
14. }
15. }
a) Print nothing code run successfully
b) Run time error
c) Arranged in descending order code run successfully
d) Compile time error
View Answer
Answer: c
Explanation: None.
Output :5, 3, 1, 0, -2, -4
9. Select the output for given code snippet:
1. class Program
2. {
3. static void Main(string[] args)
4. {
5. int[] nums = { 16, 9, 25};
6. var posNums = from n in nums
7. where n > 0
8. select Math.Sqrt(n);
9.
10. Console.Write("The positive values in nums: ");
11. foreach (int i in posNums) Console.Write(i + " ");
12. Console.WriteLine();
13. Console.ReadLine();
14. }
15. }
a) code run successfully print nothing
b) code run successfully print required output
c) Run time error
d) Compile time error
View Answer
Answer: b
Explanation: None.
Output : 4, 3, 5
10. Select the output for given code snippet:
1. class Program
2. {
3. static void Main(string[] args)
4. {
5. int[] nums = {1};
6. var posNums = from n in nums
7. wheres n > 0
8. select Math.Max(78, 9);
9. Console.Write("The largest values in nums: ");
10. foreach (int i in posNums) Console.Write(i + " ");
11. Console.WriteLine();
12. Console.ReadLine();
13. }
14. }
a) code run successfully print nothing
b) Run time error
c) code run successfully print required output
d) Compile time error
View Answer
Answer: c
Explanation: None.
Output : The largest values in nums: 78

1. What will be the output of given code snippet?


1. class Program
2. {
3. static void Main(string[] args)
4. {
5. string[] strs = {"alpha", "beta", "gamma"};
6. var chrs = from str in strs
7. let chrArray = str.ToCharArray()
8. from ch in chrArray
9. orderby ch
10. select ch;
11. Console.WriteLine("The individual characters in sorted order:");
12. foreach (char c in chrs)
13. Console.Write(c + " ");
14. Console.WriteLine();
15. Console.ReadLine();
16. }
17. }
a) a a l h a b g m m a p e t a
b) a a a a a b e g h l m m p t
c) a g h l m m p t a a a a b e
d) Run time error
View Answer
Answer: b
Explanation: None.
Output: a a a a a b e g h l m m p t
2.What will be the output of given code snippet?
1. class Program
2. {
3. static void Main(string[] args)
4. {
5. int[] nums = { 1, -2, 3, 0, -4, 5 };
6. var posNums = nums.Where(n => n > 0).Select(r => r*2).OrderByDescending(r=>
r);
7. Console.Write("The positive values in nums: ");
8. foreach(int i in posNums)
9. Console.Write(i + " ");
10. Console.WriteLine();
11. Console.ReadLine();
12. }
13. }
a) code run successfully prints nothing
b) run time error
c) code run successfully prints multiple of 2
d) compile time error
View Answer
Answer: c
Explanation: We had created the queries by using query method such as Where() and Select().This
creates a query called posNums that creates a sequence of the positive values in nums in
descending order using method OrderByDescending().
Output: 10 6 2
3. What will be the output of given code snippet?
1. class Program
2. {
3. static void Main(string[] args)
4. {
5. int[] nums = {3, 1, 2, 5, 4};
6. var ltAvg = from n in nums
7. let x = nums.Average()
8. where n < x
9. select n;
10. Console.WriteLine("The average is " + nums.Average());
11. Console.ReadLine();
12. }
13. }
a) Run time error
b) 3
c) 5
d) Compile time error
View Answer
Answer: b
Explanation: Built in method Avg() id used
Output: 3
4. What will be the output of given code snippet?
1. class Program
2. {
3. static void Main(string[] args)
4. {
5. Expression<Func<int, int, bool>>
6. IsFactorExp = (n, d) => (d != 0) ? (n % d) == 0 : false;
7. Func<int, int, bool> IsFactor = IsFactorExp.Compile();
8. if (IsFactor(10, 5))
9. Console.WriteLine("5 is a factor of 10.");
10. if (!IsFactor(343, 7))
11. Console.WriteLine("7 is not a factor of 10.");
12. Console.ReadLine();
13. }
14. }
a) Compile time error
b) Run time error
c) 5 is a factor of 10
7 is not a factor of 10
d) 5 is a factor of 10
View Answer
Answer: d
Explanation: The current program have introduced how to use the concept of expression tree.An
expression tree is a representation
of a lambda expression as data.The program illustrates the two key steps in using an expression
tree. First, it creates an
expression tree by using this statement:
Expression<func>
IsFactorExp = (n, d) => (d != 0) ? (n % d) == 0 : false;
This constructs a representation of a lambda expression in memory.
Output: 5 is a factor of 10
</func
5. Choose the namespace in which Expression trees are encapsulated:
a) System.Linq
b) System.Linq.Expressions
c) System.Text
d) System.Collections.Generic
View Answer
Answer: b
Explanation: By definition.
6. For the given set of code which query will work according to the set of code?
1. class Program
2. {
3. static void Main(string[] args)
4. {
5. int[] nums = { 1, -2, 3, 0, -4, 5 };
6. int len = /*_________________ */
7. Console.WriteLine("The number of positive values in nums: " + len);
8. Console.ReadLine();
9. }
10. }
a) from n in nums where n > 0
select n
b) from n in nums where n > 0
select n.Count()
c) (from n in nums where n > 0
select n).Count();
d) Both b & c
View Answer
Answer: c
Explanation: None.
Output: int len = (from n in nums where n > 0
select n).Count();
7. For the given set of code what is output representing?
1. class Program
2. {
3. static void Main(string[] args)
4. {
5. int[] nums = { 1, -2, 3, 0, -4, 5 };
6. var posNums = from n in nums
7. where n > 0
8. select n;
9. int len = posNums.Count();
10. Console.WriteLine(len);
11. Console.ReadLine();
12. }
13. }
a) Execution of code with nothing being printed
b) Execution of code with printing all numbers
c) Execution of code with counting total numbers greater than zero
d) Run time error
View Answer
Answer: c
Explanation: None.
Output: 3
8. For the given set of code what is output?
1. class Program
2. {
3. static void Main(string[] args)
4. {
5. int[] nums = { 1, -2, 3, 0, -4, 5 };
6. var posNums = nums.Where(n => n < 10).Select(r => r%3);
7. Console.Write("The values in nums: ");
8. foreach (int i in posNums) Console.Write(i + " ");
9. Console.WriteLine();
10. Console.ReadLine();
11. }
12. }
a) Compile time error
b) Run time error
c) 1 -2 0 0 -1 2
d) 2 -1 0 0 -2 1
View Answer
Answer: c
Explanation: Query solved using lambda expression .The code var posNums = nums.Where(n => n
< 10).Select(r => r%3) creates a query called posNums that creates a sequence of the values less
than 10 in nums.
Output: 1 -2 0 0 -1 2
9. For the given set of code what is output?
1. class Program
2. {
3. static void Main(string[] args)
4. {
5. string[] strs = { ".com", ".net", "facebook.com", "google.net", "test", "net
flix.net", "hsNameD.com" };
6. var netAddrs = from addr in strs
7. where addr.Length > 4 && addr.EndsWith(".net",
8. StringComparison.Ordinal)
9. select addr;
10. foreach (var str in netAddrs) Console.WriteLine(str);
11. Console.ReadLine();
12. }
13. }
a) Compile time error
b) Run time error
c) facebook.com
netflix.net
google.net
d) google.net
netflix.net
View Answer
Answer: d
Explanation: Searches for the string which ends with .net.
Output: google.net
netflix.net
10. For the given set of code what is output?
1. class Program
2. {
3. static void Main(string[] args)
4. {
5.
6. int[] nums = { 1, -2, -3, 5 };
7. var posNums = from n in nums
8. orderby n descending
9. select n*4 / 2;
10. Console.Write("The values in nums: ");
11. foreach (int i in posNums) Console.Write(i + " ");
12. Console.WriteLine();
13. Console.ReadLine();
14. }
15. }
a) 10 2 -4 -6
b) 5 1 -2 -3
c) 1 5 -2 -3
d) Run time error
View Answer
Answer: a
Explanation: None.
Output: 10 2 -4 -6

1. What will be the output of given code snippet?


1. class Program
2. {
3. static void Main(string[] args)
4. {
5. string[] strs = {"alpha", "beta", "gamma"};
6. var chrs = from str in strs
7. let chrArray = str.ToCharArray()
8. from ch in chrArray
9. orderby ch
10. select ch;
11. Console.WriteLine("The individual characters in sorted order:");
12. foreach (char c in chrs)
13. Console.Write(c + " ");
14. Console.WriteLine();
15. Console.ReadLine();
16. }
17. }
a) a a l h a b g m m a p e t a
b) a a a a a b e g h l m m p t
c) a g h l m m p t a a a a b e
d) Run time error
View Answer
Answer: b
Explanation: None.
Output: a a a a a b e g h l m m p t
2.What will be the output of given code snippet?
1. class Program
2. {
3. static void Main(string[] args)
4. {
5. int[] nums = { 1, -2, 3, 0, -4, 5 };
6. var posNums = nums.Where(n => n > 0).Select(r => r*2).OrderByDescending(r=>
r);
7. Console.Write("The positive values in nums: ");
8. foreach(int i in posNums)
9. Console.Write(i + " ");
10. Console.WriteLine();
11. Console.ReadLine();
12. }
13. }
a) code run successfully prints nothing
b) run time error
c) code run successfully prints multiple of 2
d) compile time error
View Answer
Answer: c
Explanation: We had created the queries by using query method such as Where() and Select().This
creates a query called posNums that creates a sequence of the positive values in nums in
descending order using method OrderByDescending().
Output: 10 6 2
3. What will be the output of given code snippet?
1. class Program
2. {
3. static void Main(string[] args)
4. {
5. int[] nums = {3, 1, 2, 5, 4};
6. var ltAvg = from n in nums
7. let x = nums.Average()
8. where n < x
9. select n;
10. Console.WriteLine("The average is " + nums.Average());
11. Console.ReadLine();
12. }
13. }
a) Run time error
b) 3
c) 5
d) Compile time error
View Answer
Answer: b
Explanation: Built in method Avg() id used
Output: 3
4. What will be the output of given code snippet?
1. class Program
2. {
3. static void Main(string[] args)
4. {
5. Expression<Func<int, int, bool>>
6. IsFactorExp = (n, d) => (d != 0) ? (n % d) == 0 : false;
7. Func<int, int, bool> IsFactor = IsFactorExp.Compile();
8. if (IsFactor(10, 5))
9. Console.WriteLine("5 is a factor of 10.");
10. if (!IsFactor(343, 7))
11. Console.WriteLine("7 is not a factor of 10.");
12. Console.ReadLine();
13. }
14. }
a) Compile time error
b) Run time error
c) 5 is a factor of 10
7 is not a factor of 10
d) 5 is a factor of 10
View Answer
Answer: d
Explanation: The current program have introduced how to use the concept of expression tree.An
expression tree is a representation
of a lambda expression as data.The program illustrates the two key steps in using an expression
tree. First, it creates an
expression tree by using this statement:
Expression<func>
IsFactorExp = (n, d) => (d != 0) ? (n % d) == 0 : false;
This constructs a representation of a lambda expression in memory.
Output: 5 is a factor of 10
</func
5. Choose the namespace in which Expression trees are encapsulated:
a) System.Linq
b) System.Linq.Expressions
c) System.Text
d) System.Collections.Generic
View Answer
Answer: b
Explanation: By definition.
6. For the given set of code which query will work according to the set of code?
1. class Program
2. {
3. static void Main(string[] args)
4. {
5. int[] nums = { 1, -2, 3, 0, -4, 5 };
6. int len = /*_________________ */
7. Console.WriteLine("The number of positive values in nums: " + len);
8. Console.ReadLine();
9. }
10. }
a) from n in nums where n > 0
select n
b) from n in nums where n > 0
select n.Count()
c) (from n in nums where n > 0
select n).Count();
d) Both b & c
View Answer
Answer: c
Explanation: None.
Output: int len = (from n in nums where n > 0
select n).Count();
7. For the given set of code what is output representing?
1. class Program
2. {
3. static void Main(string[] args)
4. {
5. int[] nums = { 1, -2, 3, 0, -4, 5 };
6. var posNums = from n in nums
7. where n > 0
8. select n;
9. int len = posNums.Count();
10. Console.WriteLine(len);
11. Console.ReadLine();
12. }
13. }
a) Execution of code with nothing being printed
b) Execution of code with printing all numbers
c) Execution of code with counting total numbers greater than zero
d) Run time error
View Answer
Answer: c
Explanation: None.
Output: 3
8. For the given set of code what is output?
1. class Program
2. {
3. static void Main(string[] args)
4. {
5. int[] nums = { 1, -2, 3, 0, -4, 5 };
6. var posNums = nums.Where(n => n < 10).Select(r => r%3);
7. Console.Write("The values in nums: ");
8. foreach (int i in posNums) Console.Write(i + " ");
9. Console.WriteLine();
10. Console.ReadLine();
11. }
12. }
a) Compile time error
b) Run time error
c) 1 -2 0 0 -1 2
d) 2 -1 0 0 -2 1
View Answer
Answer: c
Explanation: Query solved using lambda expression .The code var posNums = nums.Where(n => n
< 10).Select(r => r%3) creates a query called posNums that creates a sequence of the values less
than 10 in nums.
Output: 1 -2 0 0 -1 2
9. For the given set of code what is output?
1. class Program
2. {
3. static void Main(string[] args)
4. {
5. string[] strs = { ".com", ".net", "facebook.com", "google.net", "test", "net
flix.net", "hsNameD.com" };
6. var netAddrs = from addr in strs
7. where addr.Length > 4 && addr.EndsWith(".net",
8. StringComparison.Ordinal)
9. select addr;
10. foreach (var str in netAddrs) Console.WriteLine(str);
11. Console.ReadLine();
12. }
13. }
a) Compile time error
b) Run time error
c) facebook.com
netflix.net
google.net
d) google.net
netflix.net
View Answer
Answer: d
Explanation: Searches for the string which ends with .net.
Output: google.net
netflix.net
10. For the given set of code what is output?
1. class Program
2. {
3. static void Main(string[] args)
4. {
5.
6. int[] nums = { 1, -2, -3, 5 };
7. var posNums = from n in nums
8. orderby n descending
9. select n*4 / 2;
10. Console.Write("The values in nums: ");
11. foreach (int i in posNums) Console.Write(i + " ");
12. Console.WriteLine();
13. Console.ReadLine();
14. }
15. }
a) 10 2 -4 -6
b) 5 1 -2 -3
c) 1 5 -2 -3
d) Run time error
View Answer
Answer: a
Explanation: None.
Output: 10 2 -4 -6

1. Which feature enables to obtain information about use and capabilities of


types at runtime?
a) Runtime type ID
b) Reflection
c) Attributes
d) None of the mentioned
View Answer
Answer: b
Explanation: Reflection is the feature that enables you to obtain information about a type. The term
reflection comes from the way the process works: A Type object mirrors the underlying type that it
represents. Reflection is a powerful mechanism because it allows us to learn and use the
capabilities of types that are known
only at runtime.
2. 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
View Answer
Answer: c
Explanation: Many of the classes that support reflection are part of the .NET Reflection API, which is
in the System.Reflection namespace.
eg : using System.Reflection;
3. Choose the correct statement about System.Type namespace:
a) Core of the reflection subsystem as it encapsulates a type
b) Consists of many methods and properties that can be used to obtain
information about a type at runtime
c) Both a & b
d) Only b
View Answer
Answer: c
Explanation: System.Type is at the core of the reflection subsystem because it encapsulates a type.
It contains many properties and methods that you will use to obtain information about a type at
runtime.
4. Choose the class from which the namespace System.Type is derived:
a) System.Reflection
b) System.Reflection.MemberInfo
c) Both a & b
d) None of the mentioned
View Answer
Answer: b
Explanation: Type is derived from an abstract class called System.Reflection.MemberInfo
5. What does the following property signifies?
MemberTypes MemberType
a) Helps in distinguishing kind of members
b) Property helps in determining if member is a field, method, property or event
c) Both a & b
d) None of the mentioned
View Answer
Answer: c
Explanation: This property obtains the kind of the member. This value indicates if the member is a
field, method, property, event, or constructor among others.
6. The property signifies Obtains a Module object that represents the module (an
executable file) in which the reflected type resides. Choose the property which
specifies the following statement:
a) Type DeclaringType
b) int MetadataToken
c) Module Module
d) Type ReflectedType
View Answer
Answer: c
Explanation: By definition.
7. Choose the method defined by MemberInfo:
a) GetCustomAttributes()
b) IsDefined()
c) GetCustomeAttributesData()
d) All of the mentioned
View Answer
Answer: d
Explanation: MemberInfo includes two abstract methods: GetCustomAttributes( ) and IsDefined( ).
These both relate to attributes. The first obtains a list of the custom attributes associated with the
invoking object. The second determines if an attribute is defined for the invoking object. The .NET
Framework Version 4.0 adds a method called GetCustomAttributesData(), which returns information
about custom attributes
8. What does the following deceleration specifies?
MethodInfo[] GetMethods()
a) Returns an array of MethodInfo objects
b) Returns a list of the public methods supported by the type by using
GetMethods()
c) Both a & b
d) None of the mentioned
View Answer
Answer: a & b
Explanation: A list of the public methods supported by the type can be obtained by using
GetMethods(). It returns an array of MethodInfo objects that describe the methods supported by the
invoking type. MethodInfo is in the System.Reflection namespace.
9. What does the following code specifies?
object Invoke(object obj, object[] parameters)
a) Calling a type using invoke()
b) Any arguments that need to be passed to the method are specified in the array
parameters
c) The value returned by the invoked method is returned by Invoke()
d) None of the mentioned
View Answer
Answer: a, b, c
Explanation: Here, obj is a reference to the object on which the method is invoked. (For static
methods, you can pass null to obj.) Any arguments that need to be passed to the method are
specified in the array parameters. If no arguments are needed, parameters must be null. Also,
parameters must contain exactly the same number of elements as there are arguments.
10. What does the following method specifies?
Type[] GetGenericArguments()
a) a property defined by MemberInfo
b) Obtains a list of the type arguments bound to a closed constructed generic
type
c) the list may contain both type arguments and type parameters
d) Only b & c
View Answer
Answer: a, b, c
Explanation: The following method Obtains a list of the type arguments bound to a closed
constructed generic type or the type parameters if the specified type is a generic type definition. For
an open constructed type, the list may contain both type arguments and type parameters.

1. Which among is the ordered collection class?


a) BitArray
b) Queue
c) HashTable
d) Stack
View Answer
Answer: d, b
Explanation: None.
2. Which among is not an interface declared in System.Collection namespace?
a) IDictionaryComparer
b) IEnumerable
c) IEnumerator
d) Icomparer
View Answer
Answer: a
Explanation: None.
3. Which among the following is correct way to find out the number of elements
currently present in an ArrayListCollection called arr?
a) arr.Capacity
b) arr.Count
c) arr.MaxIndex
d) arr.UpperBound
View Answer
Answer: b
Explanation: None.
4. 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) 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
View Answer
Answer: c
Explanation: None.
5. Which is the correct statement about an ArrayList collection that implements
the IEnumerable interface?
a) To access members of ArrayList from the inner class, it is necessary to pass
ArrayList classs reference to it
b) The inner class of ArrayList can access ArrayList classs members
c) The ArrayList class consist of inner class that implements the IEnumerator
interface
d) All of the mentioned
View Answer
Answer: d
Explanation: None.
6. Which among 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);
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
View Answer
Answer: b
Explanation: None.
7. The correct code to access all the elements of the queue collection created
using the C#.NET code snippets given below?
1. Queue q = new Queue();
2. q.Enqueue("Harsh");
3. q.Enqueue('a');
4. q.Enqueue(false);
5. q.Enqueue(70);
6. q.Enqueue(8.5);
a) IEnumerator e;
e = q.GetEnumerator();
while(e.MoveNext())
Console.WriteLine(e.Current);
b) IEnumerable e;
e = q.GetEnumerator();
while(e.MoveNext())
c) IEnumerable e
e = q.GetEnumerable();
while(e.MoveNext())
Console.WriteLine(e.Current);
d) All of the mentioned
View Answer
Answer: a
Explanation: None.
8. Which statements among are correct about the Collection Classes available in
Framework Class Liberary?
a) Elements of a collection cannot be transmitted over a network
b) Elements stored in a collection can be modified only if all elements are of
similar types
c) Elements stored in a Collection can be retrieved but cannot be modified
d) Collection classes make use of efficient algorithms to manage the
collection,hence improving performance of the program
View Answer
Answer: d
Explanation: None.
9. Among the given collections which is the I/O index based?
a) ArrayList
b) BitArray
c) Stack
d) Queue
View Answer
Answer: a, b
Explanation: None.
10. Among the given correct statements about the Stack collection?
a) It can be used for evaluation of expressions
b) It is used to maintain a FIFO list
c) All elements in the Stack collection can be accessed using an enumerator
d) Top most element of the Stack collection can be accessed using the Peek()
View Answer
Answer: a, b, d
Explanation: None.
11. A HashTable t maintains a collection of names of states and capital city of
each state.Which among the given to find 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);
View Answer
Answer: b
Explanation: None.
12. In which of the following collections do the I/O based on a key?
a) BitArray
b) SortedList
c) HashTable
d) Stack
View Answer
Answer: b, c
Explanation: None.
13. The correct about a HashTable collection is?
a) It is a keyed collection
b) It is a ordered collection
c) It is an indexed collection
d) It implements a IDictionaryEnumerator interface in its inner class
View Answer
Answer: a, d
Explanation: None.
\

1. Which of these class contains only floating point functions?


a) Math
b) Process
c) System
d) Object
View Answer
Answer: a
Explanation: Math class contains all the floating point functions that are used for geometry,
trignometry, as well as several general purpose methods. Example : sin(), cos(), exp(), sqrt() etc.
2. what will be the output of given code snippet?
1. class Program
2. {
3. static void Main(string[] args)
4. {
5. double x = 2.0;
6. double y = 3.0;
7. double z = Math.Pow( x, y );
8. Console.WriteLine(z);
9. Console.ReadLine();
10. }
11. }
a) 2.0
b) 4.0
c) 8
d) 8.0
View Answer
Answer: c
Explanation: None.
Output :8
3. What will be the output of given code snippet?
1. class Program
2. {
3. static void Main(string[] args)
4. {
5. double x = 4.772;
6. double y = 4.76;
7. double z = Math.Max(x, y);
8. Console.WriteLine(z);
9. Console.ReadLine();
10. }
11. }
a) true
b) flase
c) 4.772
d) 4.76
View Answer
Answer: c
Explanation: None.
Output :4.772
4. What is the value of double constant E defined in Math class?
a) approximately 3
b) approximately 3.14
c) approximately 2.72
d) approximately 0
View Answer
Answer: c
Explanation: None.
5. What will be the output of given code snippet?
1. public class A
2. {
3. public int x;
4. public int y;
5. public void display()
6. {
7. Console.WriteLine(x + " " + y);
8. }
9. }
10. class Program
11. {
12. static void Main(string[] args)
13. {
14. A obj1 = new A();
15. A obj2 = new A();
16. obj1.x = 1;
17. obj1.y = 2;
18. obj2 = obj1;
19. obj1.display();
20. obj2.display();
21. }
22. }
a) 1 2 0 0
b) 1 2 1 2
c) 0 0 0 0
d) Run time exception
View Answer
Answer: b
Explanation: None.
Output : 1 2 1 2
6. What will be the output of given code snippet?
1. class Program
2. {
3. static void Main(string[] args)
4. {
5. int[] nums = { 1 };
6. var posNums = from n in nums
7. select Math.Pow(4 ,3);
8. Console.Write("The values in nums: ");
9. foreach (int i in posNums)
10. Console.Write(i + " ");
11. Console.WriteLine();
12. Console.ReadLine();
13. }
14. }
a) Run time error
b) 64
c) Compile time error
d) 81
View Answer
Answer: b
Explanation: None.
Output :64
7. What will be the output of given code snippet?
1. class Program
2. {
3. static void Main(string[] args)
4. {
5. float x = 3.14F;
6. int y = (int)Math.Abs(x);
7. Console.WriteLine(y);
8. Console.ReadLine();
9. }
10. }
a) Compile time error
b) 3.14
c) 3
d) 4
View Answer
Answer: c
Explanation: None.
Output :3
8. What will be the output of given code snippet?
1. class Program
2. {
3. static void Main(string[] args)
4. {
5. int x = 5;
6. int y = (int)Math.Pow(x,2);
7. int z = (int)Math.Pow(y, 2);
8. Console.WriteLine(z);
9. Console.ReadLine();
10. }
11. }
a) 25
b) 625
c) Compile time error
d) Run time error
View Answer
Answer :b
Explanation: y = 25 , z = 25*25 = 625
Output :625
9. What will be the output of given code snippet?
1. class Program
2. {
3. static void Main(string[] args)
4. {
5. int[] nums = {3 ,1 ,2 ,5 ,4};
6. var ltAvg = from n in nums
7. let x = nums.Average()
8. where n < x
9. select n;
10. Console.WriteLine("The average is " + nums.Average());
11. Console.ReadLine();
12. }
13. }
a) Run time error
b) 3
c) 5
d) Compile time error
View Answer
Answer :b
Explanation :Built in method of maths class Avg() id used
Output :3
10. What will be the output of given code snippet?
1. class Program
2. {
3. static void Main(string[] args)
4. {
5. int y = (int)Math.Max(4,2);
6. int z = (int)Math.Pow(y, 2);
7. Console.WriteLine(z);
8. Console.ReadLine();
9. }
10. }
a) 4
b) Compile time error
c) 16
d) 89
View Answer
Answer :c
Explanation :Built in method of maths class Max() is used to select maximum out of 4 and 2 and then
y is squared using Pow() of math class stored value in z.
Output :16

1. Which among the given class provides types of rounding functions?


a) Math
b) Process
c) System
d) Object
View Answer
Answer: a
Explanation: None.
2. Which of these method is a rounding function of Math class?
a) Max()
b) Min()
c) Abs()
d) Round()
View Answer
Answer: d
Explanation: Round() rounds up a variable to nearest integer
3. Which of these class contains only floating point functions?
a) Math
b) Process
c) System
d) Object
View Answer
Answer: a
Explanation: Math class contains all the floating point functions that are used for general purpose
mathematics methods. Example : sin(), cos(), exp(), sqrt() etc.
4. Which of these method return a smallest whole number greater than or equal
to variable X?
a) double Ciel(double X)
b) double Floor(double X)
c) double Max(double X)
d) double Min(double X)
View Answer
Answer: a
Explanation: Ciel(double X) returns the smallest whole number greater than or equal to variable X.
5. Which of these method return a largest whole number less than or equal to
variable X?
a) double Ciel(double X)
b) double Floor(double X)
c) double Max(double X)
d) double Min(double X)
View Answer
Answer: b
Explanation: double Floor(double X) returns a largest whole number less than or equal to variable X.
6. Which of function return absolute value of a variable?
a) Abs()
b) Absolute()
c) absolutevariable()
d) None of the mentioned
View Answer
Answer: a
Explanation: Abs() returns the absolute value of a variable
7. What will be the output of given code snippet?
1. public class A
2. {
3. public int x;
4. public int y;
5. public void display()
6. {
7. Console.WriteLine(x + " " + y);
8. }
9. }
10. class Program
11. {
12. static void Main(string[] args)
13. {
14. A obj1 = new A();
15. A obj2 = new A();
16. obj1.x = 1;
17. obj1.y = 2;
18. obj2 = obj1;
19. obj1.display();
20. obj2.display();
21. }
22. }
a) 1 2 0 0
b) 1 2 1 2
c) 0 0 0 0
d) Run time exception
View Answer
Answer: b
Explanation: None.
Output: 1 2 1 2
8. What will be the output of given code snippet?
1. class Program
2. {
3. static void Main(string[] args)
4. {
5. double x = 3.14;
6. int y = (int) Math.Abs(x);
7. Console.WriteLine(y);
8. }
9. }
a) 0
b) 3
c) 3.0
d) 3.1
View Answer
Answer: b
Explanation: None.
Output: 3
9. What will be the output of given code snippet?
1. class Program
2. {
3. static void Main(string[] args)
4. {
5. double x = 3.14;
6. int y = (int) Math.Ceiling(x);
7. Console.WriteLine(y);
8. }
9. }
a) 0
b) 3
c) 3.0
d) 4
View Answer
Answer: d
Explanation: Ceiling(double x) returns the smallest whole number greater than or equal to variable x.
Output: 4
10. What will be the output of given code snippet?
1. class Program
2. {
3. static void Main(string[] args)
4. {
5. double x = 3.14;
6. int y = (int) Math.Floor(x);
7. Console.WriteLine(y);
8. }
9. }
a) 0
b) 3
c) 3.0
d) 4
View Answer
Answer: b
Explanation: double Floor(double X) returns a largest whole number less than or equal to variable X.
Here ,the smallest whole number less than 3.14 is 3.
Output: 3

1. Select the type of multitasking methods exists really:


a) process based
b) thread based
c) only a
d) Both a & b
View Answer
Answer: d
Explanation: There are two distinct types of multitasking: process-based and thread-based.
2. Choose the correct statement about process-based multitasking:
a) feature that allows our computer to run two or more programs concurrently
b) program acts as a small unit of code that can be dispatched by the scheduler
c) Only b
d) Both a & b
View Answer
Answer: d
Explanation: The process-based multitasking is the feature that allows your computer to run two or
more programs concurrently. For example, process-based multitasking allows you to run a word
processor at the same time you are using a spreadsheet or browsing the Internet.In process-based
multitasking, a program is the smallest unit of code that can be dispatched by the scheduler.
3. Choose the statements which differs the thread based multitasking and
process based multitasking from each other:
a) Process-based multitasking handles the concurrent execution of programs
b) Process-based multitasking handles the concurrent execution of pieces of the
same program
c) Thread-based multitasking handles the concurrent execution of programs
d) Thread-based multitasking deals with the concurrent execution of pieces of the
same program
View Answer
Answer: a, d
Explanation: The differences between process-based and thread-based multitasking can be
summarized like this:Process-based multitasking handles the concurrent execution of programs.
Thread-based multitasking deals with the concurrent execution of pieces of the same program.
4. What is the advantage of the multithreading programs?
a) Enables to utilize the idle and executing time present in most programs
b) Enables to utilize the idle time presnt in most programs
c) Both a & b
d) Only b
View Answer
Answer: d
Explanation: The principal advantage of multithreading is that it enables us to write very efficient
programs because it lets us utilize the idle time that is present in most programs.
5. Select the two type of threads mentioned in the concept of multithreading:
a) foreground
b) background
c) only a
d) Both a & b
View Answer
Answer: d
Explanation: None.
6. Number of threads exists there for each of the processes that occures in the
program:
a) atmost 1
b) atleast 1
c) only 1
d) Both b & c
View Answer
Answer: a, c
Explanation: All processes have at least one thread of execution, which is usually called the main
thread because its the primary thread that is executed when our program begins.From the main
thread, we can create other threads.
7. Choose the namespace which supports the multithreading programming:
a) System.net
b) System.Linq
c) System.Threading
d) All of the mentioned
View Answer
Answer: c
Explanation: The classes that support multithreaded programming are defined in the
System.Threading namespace. Thus, you will usually include this statement at the start of any
multithreaded program.
8. What does the given code snippet specifies?
1. public Thread(ThreadStart start)
a) Defines a thread
b) Deceleration of thread constructor
c) Only a
d) Only a & b
View Answer
Answer: d
Explanation: To create a thread, instantiate an object of type Thread, which is a class defined in
System.Threading. The simplest Thread constructor is shown here:
public Thread(ThreadStart start)
Here, start specifies the method that will be called to begin execution of the thread.In other words, it
specifies the threads entry point.
9. Which of these class is used to make a thread?
a) String
b) System
c) Thread
d) Runnable
View Answer
Answer: c
Explanation: The multithreading system is built upon the Thread class, which encapsulates a thread
of execution. The Thread class is sealed, which means that it cannot be inherited. Thread defines
several methods and properties that help manage threads.
10. On call of which type of method the new created thread will not start
executing?
a) Begin()
b) Start()
c) New()
d) All of the mentioned
View Answer
Answer: b
Explanation: Once created, the new thread will not start running until you call its Start()
method,which is defined by Thread.
11. Which of these method of Thread class is used to Suspend a thread for a
period of time?
a) sleep()
b) terminate()
c) suspend()
d) stop()
View Answer
Answer: a
Explanation: None.

1. Which of these keywords are used to implement synchronization?


a) synchronize
b) syn
c) synch
d) synchronized
View Answer
Answer: d
Explanation: None.
2. Which keyword is used for using the synchronization features defined by the
Monitor class?
a) lock
b) synchronized
c) Monitor
d) locked
View Answer
Answer: a
Explanation: The C# keyword lock is really just shorthand for using the synchronization features
defined by the Monitor class, which is defined in the System.Threading namespace.
3. What is synchronization in reference to a thread?
a) Its a process of handling situations when two or more threads need access to
a shared resource
b) Its a process by which many thread are able to access same shared resource
simultaneously
c) Its a process by which a method is able to access many different threads
simultaneously
d) Its a method that allow to many threads to access any information the require
View Answer
Answer: a
Explanation: When two or more threads need to access the same shared resource, they need some
way to ensure that the resource will be used by only one thread at a time, the process by which this
is achieved is called synchronization.
4. Which method is called when a thread is blocked from running temporarily?
a) Pulse()
b) PulseAll()
c) Wait()
d) Both b & c
View Answer
Answer: c
Explanation: When a thread is temporarily blocked from running, it calls Wait( ). This causes the
thread to go to sleep and the lock for that object to be released, allowing another thread to acquire
the lock.
5. What kind of exception is being thrown if Wait(),Pulse() or PulseAll() iscalled
from code that is not within synchronized code?
a) System I/O Exception
b) DivideByZero Exception
c) SynchronizationLockException
d) All of the mentioned
View Answer
Answer: c
Explanation: A SynchronizationLockException will be thrown if Wait(), Pulse(), or PulseAll() is called
from code that is not within synchronized code, such as a lock block.
6. What is mutex?
a) a mutually exclusive synchronization object
b) can be acquired by more than one thread at a time
c) helps in sharing of resource which can be used by one thread at only one a
time
d) All of the mentioned
View Answer
Answer: a, c
Explanation: A mutex is a mutually exclusive synchronization object. This means it can be acquired
by one and only one thread at a time. The mutex is designed for those situations in which a shared
resource can be used by only one thread at a time
7. What is Semaphore?
a) Grant more than one thread access to a shared resource at the same time.
b) Useful when a collection of resources is being synchronized
c) Make use of a counter to control access to a shared resource
d) Only b & c
View Answer
Answer: a, b, c
Explanation: A semaphore is similar to a mutex except that it can grant more than one thread access
to a shared resource at the same time. Thus, the semaphore is useful when a collection of resources
is being synchronized. A semaphore controls access to a shared resource through the use of a
counter. If the counter is greater than zero, then access is allowed. If it is zero, access is denied
8. Which method is used to abort thread prior to its normal execution?
a) sleep()
b) terminate()
c) suspend()
d) Abort()
View Answer
Answer: d
Explanation: To terminate a thread prior to its normal conclusion, use Thread.Abort( ). Its simplest
form is shown here:
public void Abort()
Abort() causes a ThreadAbortException to be thrown to the thread on which Abort() is called. This
exception causes the thread to terminate.
9. Which of these statements is incorrect?
a) By multithreading CPUs idle time is minimized, and we can take maximum
use of it
b) By multitasking CPUs idle time is minimized, and we can take maximum use
of it
c) Two thread in Csharp can have same priority
d) A thread can exist only in two states, running and blocked
View Answer
Answer: d
Explanation: Thread exist in several states, a thread can be running, suspended, blocked,
terminated & ready to run.
10. What is multithreaded programming?
a) Its a process in which two different processes run simultaneously
b) Its a process in which two or more parts of same process run simultaneously
c) Its a process in which many different process are able to access same
information
d) Its a process in which a single process can access information from many
sources
View Answer
Answer: b
Explanation: multithreaded programming a process in which two or more parts of same process run
simultaneously.

1. What is an iterator?
a) a method
b) an operator
c) accessor
d) Both a & b
View Answer
Answer: a, b, c
Explanation: An iterator is a method, operator, or accessor that returns the members of a set of
objects, one member at a time, from start to finish.
2. What will be the output of given code snippet?
1. class MyClass
2. {
3. char[] chrs = { 'A', 'B', 'C', 'D' };
4. public System.Collections.IEnumerator GetEnumerator()
5. {
6. foreach (char ch in chrs)
7. yield return ch;
8. }
9. }
10. class Program
11. {
12. static void Main(string[] args)
13. {
14. MyClass mc = new MyClass();
15. foreach (char ch in mc)
16. Console.Write(ch + " ");
17. Console.WriteLine();
18. Console.ReadLine();
19. }
20. }
a) Run time error
b) Compile time error
c) Code run successfully prints nothing
d) Code run successfully prints A, B, C, D
View Answer
Answer: d
Explanation: None.
Output: A, B, C, D
3. Choose the correct statements about part of given code part of the code
defined above?
1. public System.Collections.IEnumerator GetEnumerator()
2. {
3. foreach (char ch in chrs)
4. yield return ch;
5. }
a) Definition of iterator for MyClass
b) Implements the GetEnumerator() method defined by IEnumerable
c) The yield return statement returns the next object in the collection, which in
this case is the next character in chrs
d) Both b & c
View Answer
Answer: a, b, c
Explanation: This is the definition of the iterator for MyClass. The code implicitly implements the
GetEnumerator() method defined by IEnumerable. At the body of the method. It contains a foreach
loop that returns the elements in chrs. It does this through the use of a yield return statement. The
yield return statement returns the next object in the collection, which in this case is the next
character in chrs.
4. What does the yield return statement specifies in above code snippet?
a) returns the output
b) returns the next object in the collection
c) Both a & b
d) None of the mentioned
View Answer
Answer: b
Explanation: The yield return statement returns the next object in the collection, which in this case is
the next character in chrs in above code.
5. What will be the given code snippet specifies?
1. class MyClass
2. {
3. char chrs = 'A' ;
4. public IEnumerator GetEnumerator()
5. {
6. for (int i = 20; i >=0; --i)
7. yield return (char)((chrs + i));
8. }
9. }
10. class Program
11. {
12. static void Main(string[] args)
13. {
14. MyClass mc = new MyClass();
15. foreach (char ch in mc)
16. Console.Write(ch + " ");
17. Console.WriteLine();
18. Console.ReadLine();
19. }
20. }
a) A B C D E F G H I J K L M N O P Q R S T U V
b) Run time error
c) U T S R Q P O N M L K J I H G F E D C B A
d) Compile successfully prints nothing
View Answer
Answer: c
Explanation: None.
Output: U T S R Q P O N M L K J I H G F E D C B A
6. What will be the given code snippet specifies?
1. class MyClass
2. {
3. char chrs = 'A' ;
4. public IEnumerator GetEnumerator()
5. {
6. for (int i = 20; i >=0; --i)
7. if (i == 10) yield break;
8. yield return (char)((chrs + i));
9. }
10. }
11. class Program
12. {
13. static void Main(string[] args)
14. {
15. MyClass mc = new MyClass();
16. foreach (char ch in mc)
17. Console.Write(ch + " ");
18. Console.WriteLine();
19. Console.ReadLine();
20. }
21. }
a) Code run successfully prints nothing
b) A B C D E F G H I J K L M N O P Q R S T U V
c) U T S R Q P O N M L
d) Compile time error
View Answer
Answer: c
Explanation: The code to specify stoppage of the iterator using yield break statement When this
statement executes, the iterator signals that the end of the collection has been reached, which
effectively stops the iterator.
Output: U T S R Q P O N M L
7. What will be the output of code snippet?
1. class MyClass
2. {
3. int[] a = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 2
0};
4. public IEnumerator GetEnumerator()
5. {
6. for (int i = 0; i < 20; i++)
7. {
8. if (a[i] % 2 == 0)
9. yield return (int)(a[i]);
10. }
11. }
12. }
13. class Program
14. {
15. static void Main(string[] args)
16. {
17. MyClass mc = new MyClass();
18. foreach (int i in mc)
19. Console.Write(i + " ");
20. Console.WriteLine();
21. Console.ReadLine();
22. }
23. }
a) print nothing code run successfully
b) run time error
c) code run successfully prints even number between 1 to 20
d) Compile time error
View Answer
Answer: c
Explanation: None.
Output: 2, 4, 6, 8, 10, 12, 14, 16, 18, 20
8. What will be the output of code snippet?
1. class MyClass
2. {
3. char ch = 'A';
4. public IEnumerable MyItr(int end)
5. {
6. for (int i = 0 ;i < end ;i++)
7. yield return (char)(ch + i);
8. }
9. public IEnumerable MyItr(int begin, int end)
10. {
11. for (int i = begin ;i < end ;i++)
12. yield return (char)(ch + i);
13. }
14. }
15. class Program
16. {
17. static void Main(string[] args)
18. {
19. MyClass mc = new MyClass();
20. Console.WriteLine("Iterate the first 7 letters:");
21. foreach (char ch in mc.MyItr(7))
22. Console.Write(ch + " ");
23. Console.WriteLine("n");
24. Console.WriteLine("Iterate letters from F to L:");
25. foreach (char ch in mc.MyItr(7, 12))
26. Console.Write(ch + " ");
27. Console.WriteLine();
28. Console.ReadLine();
29. }
30. }
a) Iterate the first 7 letters:
ABCDEFG
Iterate letters from F to L:
GHIJKL
b) Iterate the first 7 letters:
ABCDEFG
Iterate letters from F to L:
HIJKL
c) Run time error
d) Compile time error
View Answer
Answer: b
Explanation: None.
Output: Iterate the first 7 letters:
ABCDEFG
Iterate letters from F to L:
HIJKL
9. What will be the output of code snippet?
1. class MyClass
2. {
3. char ch = 'A';
4. int e = 4;
5. int k = 9;
6. int z = 6;
7. public IEnumerator GetEnumerator()
8. {
9. for (int i = 0; i < 26; i++)
10. {
11. if (i == e*k /z) yield break;
12. yield return (int)(ch + i);
13. }
14. }
15. }
16. class Program
17. {
18. static void Main(string[] args)
19. {
20. MyClass mc = new MyClass();
21. foreach(int ch in mc)
22. Console.Write(ch + " ");
23. Console.WriteLine();
24. Console.ReadLine();
25. }
26. }
a) Compile time error
b) Run time error
c) 65 66 67 68 69 70
d) Code run successfully prints nothing
View Answer
Answer: c
Explanation: None.
Output: 65 66 67 68 69 70
10. What are the advantages of the named iterator?
a) They allow to pass arguments to the iterator that control what elements are
obtained
b) This form of iterators can be overloaded
c) Both a & b
d) None of the mentioned
View Answer
Answer: a, b
Explanation: By definition.

1. Which is the not a namespace in the .NET Framework Class Liberary?


a) System.Process
b) System.Security
c) System.Threading
d) System.xml
View Answer
Answer: a
Explanation: None.
2. Which is correct statement about the namespaces in C#.NET?
a) Nesting of namespaces is permitted, provided all the inner namespaces are
declared in the same file
b) A namespace cannot be tested
c) There is no limit on the number of levels while nesting namespaces
d) All of the mentioned
View Answer
Answer: c
Explanation: None.
3. Which among the following donot belongs to the C#.NET namespace?
a) class
b) struct
c) enum
d) Data
View Answer
Answer: d
Explanation: None.
4. Which among the following are not correct statement about namespace used
in C#.NET?
a) Classes must belong to a namespace, whereas structures need not
b) All elements of the namespace have to belong to one file
c) If not mentioned, a namespace takes the name of the current project
d) All of the mentioned
View Answer
Answer: a, b
Explanation: None.
5. Which among the given is correct way to call the method Issue() defined in the
code snippet given below?
1. class Book
2. {
3. public void issue()
4. {
5. /* code */
6. }
7. }
8. class Journel
9. {
10. public void issue()
11. {
12. /* code */
13. }
14. }
a) College.Lib.Book b = new College.Lib.Book();
b.issue();
b) Book b = new Book();
b.issue();
c) using College.Lib;
Book b = new Book();
b.issue();
d) All of the mentioned
View Answer
Answer: a, c
Explanation: None.
6. Which among the following statements are correct about a namespace used in
C#.NET?
a) Nested namespaces are not allowed
b) Importing outer namespaces imports inner namespace
c) Nested namespaces are allowed
d) Importing outer namespace does not import inner namespace
View Answer
Answer: c, d
Explanation: None.
7. Which anong the following is NOT a .NET namespace?
a) System.Web
b) System.Process
c) System.Drawing2D
d) System.Drawing3D
View Answer
Answer: b, d, e
Explanation: None.
8. If a class named as csharp is present in namespace n1 as well as in
namespace n2,so which is correct way to use csharp class?
a) class Program
{
static void Main(string[] args)
{
import n1;
csharp x = new csharp();
x.fun();
import n2;
csharp y = new csharp();
y.fun();
}
}
b) import n1;
import n2;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{

n1.csharp x = new n1.csharp();


x.fun();
import n2;
n2.csharp y = new n2.csharp();
y.fun();
}
}
}
c) class Program
{
static void Main(string[] args)
{
using n1;
csharp x = new csharp();
x.fun();
using n2;
csharp y = new csharp();
y.fun();
}
}
d) using n1;
using n2;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{

n1.csharp x = new n1.csharp();


x.fun();
import n2;
n2.csharp y = new n2.csharp();
y.fun();
}
}
}
View Answer
Answer: e
Explanation: None.
9. If ListBox is class of System.Windows.Forms namespace.So,correct way to
create an object of ListBox class is?
a) using System.Windows.Forms;
ListBox I = new ListBox();
b) System.Windows.Forms.ListBox I = new System.Windows.Forms.ListBox();
c) using LBControl I = new System.Windows.Forms.ListBox;
d) None of the mentioned
View Answer
Answer: a, b, c
Explanation: None.
10. Which among the following is correct statement about the using statement
used in C#.NET?
a) A C#.NET source code file consists of any number of using statement
b) By using using statement its possible to create an alias for the namespace
but not for the namespace element
c) It is permitted to define a member at namespace level as a using alias
d) using statement can be placed anywhere in the C#.NET source code file
View Answer
Answer: c
Explanation: None.

1. Choose the symbol which begins a preprocessor directive in C#.NET?


a) #
b) **
c) *
d) &
View Answer
Answer: a
Explanation: #define, #elif, #else etc.
2. What is meant by preprocessor directive in C#.NET?
a) a form of command which are interpreted by the compiler
b) a form of macros like in c and c++ not exactly same to them seperately
designed for C#.NET
c) always begins with a # character occupies seperate line of source of code
d) All of the mentioned
View Answer
Answer: d
Explanation: Preprocessor directives are commands that are interpreted by the compiler and affect
the output or behavior of the build process. The C# compiler does not have a separate preprocessor,
like C and C++ we cannot use these directives to create macros. Preprocessing directives are top
lines in our program that start with #. The # is followed by an identifier that is the directive name.
3. What is meant by preprocessor directive #define?
a) defines a character sequence
b) helps in determining existence and non existence of a symbol
c) can be used to create function like macros as in C/C++
d) All of the mentioned
View Answer
Answer: a, b
Explanation: The #define directive defines a character sequence called a symbol. The existence or
nonexistence of a symbol can be determined by #if or #elif and is used to control compilation.
#define which supports creation of function like macros in c/c++ does not support the same in C#.
4. Select the defined preprocessor in C#.NET?
a) #define
b) #elif
c) #else
d) #endif
View Answer
Answer: a, b, c, d
Explanation: None.
5. What does preprocessor directive #if and #endif explains?
a) Enables compilation of sequence of code on condition basis
b) Express results into true or false on evaluation of condition
c) if expression following #if is true then code that is between #if and #endif is
compiled otherwise skipped
d) All of the mentioned
View Answer
Answer: d
Explanation: The #if and #endif directives enable conditional compilation of a sequence of code
based upon whether an expression involving one or more symbols evaluates to true. A symbol is
true if it has been defined. It is false otherwise.If the expression following #if is true, the code that is
between it and #endif is compiled.Otherwise, the intervening code is skipped. The #endif directive
marks the end of an #if block.
6. What will be the output of following code snippet?
1. #define pi
2. using System;
3. using System.Collections.Generic;
4. using System.Linq;
5. using System.Text;
6. using System.Threading.Tasks;
7.
8. namespace ConsoleApplication13
9. {
10. class Program
11. {
12. static void Main(string[] args)
13. {
14. #if (!pi)
15. Console.WriteLine("i");
16. #else
17. Console.WriteLine("pi not define");
18. #endif
19. Console.WriteLine("ok");
20. Console.ReadLine();
21. }
22. }
23. }
a) i
pi not define
b) pi not define
ok
c) i
ok
d) ok
View Answer
Answer: b
Explanation: The defined symbol pi when compared as per if condition hence the outcome is false
which results in skip of statement and hence executes statement after #else and finally the end
statement after #endif.
Output: pi not define
ok
7. What will be the output of following code snippet?
1. #define DEBUG
2. #define MYTEST
3. using System;
4. using System.Collections.Generic;
5. using System.Linq;
6. using System.Text;
7. using System.Threading.Tasks;
8.
9. namespace ConsoleApplication13
10. {
11. class Program
12. {
13. static void Main(string[] args)
14. {
15. #if (DEBUG && !MYTEST)
16. Console.WriteLine("DEBUG is defined");
17. #elif (!DEBUG && MYTEST)
18. Console.WriteLine("MYTEST is defined");
19. #elif (DEBUG && MYTEST)
20. Console.WriteLine("DEBUG and MYTEST are defined");
21. #else
22. Console.WriteLine("DEBUG and MYTEST are not defined");
23. #endif
24. Console.ReadLine();
25. }
26. }
27. }
a) DEBUG is defined
MYTEST is defined
b) MYTEST is defined
DEBUG and MYTEST are defined
c) DEBUG and MYTEST are not defined
MYTEST is defined
d) DEBUG and MYTEST are defined
View Answer
Answer: d
Explanation: None.
8. What will be the output of following code snippet?
1. #define DEBUG
2. #undef DEBUG
3. using System;
4. using System.Collections.Generic;
5. using System.Linq;
6. using System.Text;
7. using System.Threading.Tasks;
8.
9. namespace ConsoleApplication13
10. {
11. class Program
12. {
13. static void Main(string[] args)
14. {
15. #if (DEBUG)
16. Console.WriteLine("DEBUG is defined");
17. #elif (!DEBUG && MYTEST)
18. Console.WriteLine("MYTEST is defined");
19. #elif (DEBUG && MYTEST)
20. Console.WriteLine("DEBUG and MYTEST are defined");
21. #else
22. Console.WriteLine("DEBUG and MYTEST are not defined");
23. #endif
24. Console.ReadLine();
25. }
26. }
27. }
a) DEBUG is defined
DEBUG and MYTEST are not defined
b) DEBUG and MYTEST are not defined
c) MYTEST is defined
DEBUG and MYTEST are not defined
d) DEBUG is defined
View Answer
Answer: b
Explanation: #undef lets to undefine a symbol such that by using the symbol as the expression in a
#if directive, the expression will evaluate to false i.e the symbol will be undefined in nature.
Output: DEBUG and MYTEST are not defined
9. Which preprocessor directive among the following forces the compiler to stop
the compilation?
a) #warning
b) #endregion
c) #undef
d) #error
View Answer
Answer: d
Explanation: The #error directive forces the compiler to stop compilation. It is used for debugging.
The general form of the #error directive is #error error-message. When the #error directive is
encountered, the error message is displayed
10. Which among the following is not a preprocessor directive?
a) #ifdef
b) #pragma
c) #Or
d) #undef
View Answer
Answer: c
Explanation: None.

1. Which of these data tupel can be used for a method having a return statement
in it?
a) void
b) int
c) float
d) All of the mentioned
View Answer
Answer: d
Explanation: None.
2. What is the process of defining more than one method in a class differentiated
by parameters?
a) Function overriding
b) Function overloading
c) Function doubling
d) None of the mentioned
View Answer
Answer: b
Explanation: Function overloading is a process of defining more than one method in a class with
same name differentiated by function signature i:e return type or parameters type and number.
Example int volume(int length, int width) & int volume(int length, int width, int height) can be used
to calculate volume.
3. Which of these is the method which is executed first before execution of any
other thing takes place in a program?
a) main method
b) finalize method
c) static method
d) private method
View Answer
Answer: c
Explanation: If a static method is present in the program then it will be executed first, then main will
be executed.
4. Which of these can be used to diffrentiate two or more methods having same
name?
a) Parameters data type
b) Number of parameters
c) Return type of method
d) All of the mentioned
View Answer
Answer: d
Explanation: None.
5. Which of these data type can be used for a method having a return statement
in it?
a) void
b) int
c) float
d) All of the mentioned
View Answer
Answer: d
Explanation: None.
6. What will be the output of program?
1. class box
2. {
3. int width;
4. int height;
5. int length;
6. int volume;
7. void volume(int height, int length, int width)
8. {
9. volume = width * height * length;
10. }
11. }
12. class Prameterized_method
13. {
14. public static void main(String args[])
15. {
16. box obj = new box();
17. obj.height = 1;
18. obj.length = 5;
19. obj.width = 5;
20. obj.volume(3, 2, 1);
21. Console.WriteLine(obj.volume);
22. Console.ReadLine();
23. }
24. }
a) 0
b) 1
c) 6
d) 25
View Answer
Answer: c
Explanation: None.
Output :6
7. What will be the output of given code snippet?
1. class equality
2. {
3. int x;
4. int y;
5. boolean isequal()
6. {
7. return(x == y);
8. }
9. }
10. class Output
11. {
12. public static void main(String args[])
13. {
14. equality obj = new equality();
15. obj.x = 5;
16. obj.y = 5;
17. Console.WriteLine(obj.isequal());
18. }
19. }
a) false
b) true
c) 0
d) 1
View Answer
Answer: b
Explanation: None.
Output :true
8. What will be the output of given code snippet?
1. class equality
2. {
3. public int x;
4. public int y;
5. public Boolean isequal()
6. {
7. return (x == y);
8. }
9. }
10. class Program
11. {
12. static void Main(string[] args)
13. {
14. equality obj = new equality();
15. obj.x = 5;
16. obj.y = 5;
17. Console.WriteLine(obj.isequal());
18. Console.ReadLine();
19. }
20. }
a) false
b) true
c) 0
d) 1
View Answer
Answer: b
Explanation: None.
Output :true
9. What will be the output of given code snippet?
1. class box
2. {
3. public int width;
4. public int height;
5. public int length;
6. public int volume1;
7. public void volume()
8. {
9. volume1 = width * height * length;
10. }
11. public void volume(int x)
12. {
13. volume1 = x;
14. }
15. }
16. class Program
17. {
18. static void Main(string[] args)
19. {
20. box obj = new box();
21. obj.height = 1;
22. obj.length = 5;
23. obj.width = 5;
24. obj.volume(5);
25. Console.WriteLine(obj.volume1);
26. Console.ReadLine();
27. }
28. }
a) 0
b) 5
c) 25
d) 26
View Answer
Answer: b
Explanation: None.
Output : 5
10. What will be the output of given code snippet?
1. class Program
2. {
3. static void Main(string[] args)
4. {
5. int x, y = 1;
6. x = 10;
7. if(x != 10 && x / Convert.ToInt32(0) == 0)
8. Console.WriteLine(y);
9. else
10. Console.WriteLine(++y);
11. Console.ReadLine();
12. }
13. }
a) 1
b) 2
c) Run time error
d) Compile time error
View Answer
Answer: b
Explanation: Both conditions for if statements are failed and hence statement after else is executed.
Output : 2

1. Which namespace mostly preferred for the operation of networking in C#?


a) System.Web
b) System.Net
c) System.Net.Mail
d) All of the mentioned
View Answer
Answer: b, c
Explanation: Networking support is contained in several namespaces defined by the .NET
Framework.The primary namespace for networking is System.Net. It defines a large number of
highlevel, easy-to-use classes that support the various types of operations common to the
Internet.Several namespaces nested under System.Net are also provided for example
:System.Net.Mail.
2. Select the classes defined by the namespace System.Net:
a) Cookie
b) CookieContainer
c) FileWebRequest
d) All of the mentioned
View Answer
Answer: d
Explanation: None.
3. Select the interfaces defined by the namespace System.Net:
a) IAuthenticationModule
b) WebRequestCreate
c) WebProxy
d) HttpResponseHeader
View Answer
Answer: a, b
Explanation: c and d are namespaces and enumerations.
4. Select the classes that support the standard HTTP protocol
a) HttpWebRequest
b) HttpWebResponse
c) HttpRequestHeader
d) HttpStatusCode
View Answer
Answer: a, b
Explanation: The derived classes that support the standard HTTP protocol are HttpWebRequest and
HttpWebResponse
5. Select the classes/class that support the task of uploading and downloading
the file:
a) WebRequest
b) WebResponse
c) WebClient
d) All of the mentioned
View Answer
Answer: c
Explanation: If we only need to upload or download a file, then WebClient is often the best way to
accomplish it.
6. How many ports of TCP/IP are reserved for specific protocols?
a) 10
b) 1024
c) 2048
d) 512
View Answer
Answer: b
Explanation: None.
7. How many bits are in a single IP address?
a) 8
b) 16
c) 32
d) 64
View Answer
Answer: c
Explanation: None.
8. Which of these is a full form of DNS?
a) Data Network Service
b) Data Name Service
c) Domain Network Service
d) Domian Name Service
View Answer
Answer: d
Explanation: None.
9. Which of these class is used to encapsulate IP address and DNS?
a) DatagramPacket
b) URL
c) InetAddress
d) ContentHandler
View Answer
Answer: c
Explanation: InetAddress class encapsulate both IP address and DNS, we can interact with this
class by using name of an IP host.
10. Select the protocols defined by the .NET runtime:
a) HTTP
b) HTTPS
c) file
d) FTP
View Answer
Answer: a, b, c, d
Explanation: The .NET runtime defines the HTTP, HTTPS, file, and FTP protocols. Thus, if we
specify a URI that uses the HTTP prefix, we will automatically receive the HTTP-compatible class
that supports it. If we specify a URI that uses the FTP prefix, we will automatically receive the FTP-
compatible class that supports it.

1. What does URL stands for?


a) Uniform Resource Locator
b) Uniform Resource Latch
c) Universal Resource Locator
d) Universal Resource Latch
View Answer
Answer: a
Explanation: None.
2. Which of these exception is thrown by URL classs constructors?
a) URLNotFound
b) URLSourceNotFound
c) MalformedURLException
d) URLNotFoundException
View Answer
Answer: c
Explanation: None.
3. What does the following form defines?
Protocol://HostName/FilePath?Query
a) Protocol specifies the protocol being used, such as HTTP
b) HostName identifies a specific server, such as mhprofessional.com or
www.google.com
c) FilePath specifies the path to a specific file
d) Query specifies information that will be sent to the server
View Answer
Answer: a, b, c, d
Explanation: By definition.
4. Which of these class is used to encapsulate IP address and DNS?
a) DatagramPacket
b) URL
c) InetAddress
d) ContentHandler
View Answer
Answer: c
Explanation: InetAddress class encapsulate both IP address and DNS, we can interact with this
class by using name of an IP host.
5. Which of these is a standard for communicating multimedia content over
email?
a) http
b) https
c) Mime
d) httpd
View Answer
Answer: c
Explanation: MIME is an internet standard for communicating multimedia content over email. The
HTTP protocol uses and extends the notion of MIME headers to pass attribute pairs between HTTP
client and server.
6. What does the following method specifies?
public static WebRequest Create(string requestUriString)
a) Creates a WebRequest object for the URI specified by the string passed by
requestUriString
b) The object returned will implement the protocol specified by the prefix of the
URI
c) The object will be an instance of a class that inherits WebRequest
d) All of the mentioned
View Answer
Answer: d
Explanation: Creates a WebRequest object for the URI specified by the string passed by
requestUriString. The object returned will
implement the protocol specified by the prefix of the URI.Thus, the object will be an instance of a
class that inherits WebRequest. A NotSupportedException is thrown if the requested protocol is not
available. A UriFormatException is thrown if the URI format is invalid.
7. What does the following code displays while execution?
1. class Program
2. {
3. static void Main(string[] args)
4. {
5. int ch;
6. HttpWebRequest req = (HttpWebRequest) WebRequest.Create("http://www.McGraw
-Hill.com");
7. HttpWebResponse resp = (HttpWebResponse) req.GetResponse();
8. Stream istrm = resp.GetResponseStream();
9. for (int i = 1 ; ;i++)
10. {
11. ch = istrm.ReadByte();
12. if (ch == -1)
13. break;
14. Console.Write((char)ch);
15. if ((i % 400) == 0)
16. {
17. Console.Write("\nPress Enter.");
18. Console.ReadLine();
19. }
20. }
21. resp.Close();
22. }
23. }
a) html
b) text
c) html/text
d) text/html
View Answer
Answer: d
Explanation: The following program performs obtains the hypertext contained at a specific
website.The program displays the hypertext on the screen.
8. What does the following code displays while execution?
1. class Program
2. {
3. static void Main(string[] args)
4. {
5. Uri obj = new Uri("http://www.sanfoundry.com/csharpmcq");
6. Console.WriteLine(obj.AbsoluteUri);
7. Console.ReadLine();
8. }
9. }
a) sanfoundry
b) sanfoundry.com
c) www.sanfoundry.com
d) http://www.sanfoundry.com/csharpmcq
View Answer
Answer: d
Explanation: AbsoluteUri is used to know the full URL of an URL object.
Output :http://www.sanfoundry.com/csharpmcq
9. Which of these data member of HttpResponse class is used to store the
response from a http server?
a) status
b) address
c) statusResponse
d) statusCode
View Answer
Answer: d
Explanation: When we send a request to a http server it respond with a status code this status code
is stored in statusCode and a textual equivalent which is stored in reasonPhrase.
10. Which of these class is used to access actual bits or content information of a
URL?
a) URL
b) URLDecoder
c) URLConnection
d) All of the mentioned
View Answer
Answer: d
Explanation: URL, URLDecoder and URLConnection all there are used to access information stored
in a URL.

1. Which exception is being thrown if the URI format is invalid?


a) URLNotFound
b) URLSourceNotFound
c) MalformedURLException
d) UriFormatException
View Answer
Answer: d
Explanation: None.
2. Which exception is being thrown if the protocol supported by URI prefix is
invalid?
a) URLNotFound
b) URLSourceNotFound
c) UriFormatException
d) NotSupportedException
View Answer
Answer :d
Explanation: None.
3. Which exception is being thrown if the user does not have proper
authorization?
a) URLNotFound
b) URLSourceNotFound
c) System.Security.SecurityException
d) All of the mentioned
View Answer
Answer: c
Explanation: None.
4. Choose the exceptions generated by the Create() method defined by
WebRequest:
a) NotSupportedException
b) UriFormatException
c) System.Security.SecurityException
d) ArgumentNullException
View Answer
Answer: a, b, c, d
Explanation: None.
5. Choose the exceptions generated by the GetReponse() method defined by
WebRequest:
a) InvalidOperationException
b) ProtocolViolationException
c) WebException
d) UriFormatException
View Answer
Answer: a, b, c
Explanation: By definition.
6. Select the two properties related to the network errors generated by
WebException:
a) Response
b) get
c) Status
d) set
View Answer
Answer: a, c
Explanation: WebException has two properties that relate to network errors:
Response and Status.
We can obtain a reference to the WebResponse object inside an exception handler through the
Response property. For the HTTP protocol, this object describes the error. It is defined like this:
public WebResponse Response { get; }
When an error occurs, we can use the Status property of WebException to find out whatwent wrong.
It is defined like this:
public WebExceptionStatus Status {get; }
7. Which of these class is used for operating on request from the client to the
server?
a) http
b) httpDecoder
c) httpConnection
d) httpd
View Answer
Answer: d
Explanation: None.
8. Choose the exceptions generated by the GetResponseStream() method
defined by WebRequest:
a) ProtocolViolationException
b) ObjectDisposedException
c) UriFormatException
d) IOException
View Answer
Answer: a, b, d
Explanation: None.
9. Which of these class is used to create servers that listen for either local or
remote client programs?
a) httpServer
b) ServerSockets
c) MimeHeader
d) HttpResponse
View Answer
Answer: b
Explanation: None.
10. Which of these methods is used to know the full URL of an URL object?
a) fullHost()
b) getHost()
c) AbsoluteUri
d) toExternalForm()
View Answer
Answer: c
Explanation: None.

1. Why are generics used?


a) Generics make code more fast
b) Generics make code more optimised and readable
c) Generics add stability to your code by making more of your bugs detectable at
compile time
d) Generics add stability to your code by making more of your bugs detectable at
run time
View Answer
Answer: c
Explanation: Generics add stability to your code by making more of your bugs detectable at compile
time.
2. Which of these type parameters is used for a generic methods to return and
accept any type of object?
a) K
b) N
c) T
d) V
View Answer
Answer: c
Explanation: T is used for type, A type variable can be any non-primitive type you specify: any class
type, any interface type, any array type, or even another type variable.
3. Which of these is an correct way of defining generic method?
a) name(T1, T2, , Tn) { /* */ }
b) public name { /* */ }
c) class name[T1, T2, ..., Tn] { /* */ }
d) name{T1, T2, , Tn} { /* */ }
View Answer
Answer: b
Explanation: The syntax for a generic method includes a type parameter, inside angle brackets, and
appears before the methods return type. For static generic methods, the type parameter section
must appear before the methods return type.
4. What will be the output of given code snippet?
1. public class Generic<T>
2. {
3. Stack<T> stk = new Stack<T>();
4. public void push(T obj)
5. {
6. stk.Push(obj);
7. }
8. public T pop()
9. {
10. T obj = stk.Pop();
11. return obj;
12. }
13. }
14. class Program
15. {
16. static void Main(string[] args)
17. {
18. Generic<int> g = new Generic<int>();
19. g.push("Csharp");
20. Console.WriteLine(g.pop());
21. Console.ReadLine();
22. }
23. }
a) Compile time error
b) Csharp
c) 0
d) Run time error
View Answer
Answer: b
Output : Csharp
5. What will be the output of given code snippet?
1. public class Generic<T>
2. {
3. Stack<T> stk = new Stack<T>();
4. public void push(T obj)
5. {
6. stk.Push(obj);
7. }
8. public T pop()
9. {
10. T obj = stk.Pop();
11. return obj;
12. }
13. }
14. class Program
15. {
16. static void Main(string[] args)
17. {
18. Generic<string> g = new Generic<string>();
19. g.push(30);
20. Console.WriteLine(g.pop());
21. Console.ReadLine();
22. }
23. }
a) 0
b) 30
c) Runtime Error
d) Compile time Error
View Answer
Answer: b
Output : 30
6. What does the following code block defines?
1. class Gen<T> {
2. T ob;
3. }
a) Generics class decleration
b) Decleration of variable
c) a simple class decleration
d) All of the mentioned
View Answer
Answer: a, b
Explanation: class Gen This defines the generics decleration where T is the name of type
parameter.This parameter is used as a placeholder for the actual type that will be specified when a
Gen object is created.Gen is a generic class . T is used to declare a variable called ob.

7. What will be the output of given code snippet?


1. public class Generic<T>
2. {
3. Stack<T> stk = new Stack<T>();
4. public void push(T obj)
5. {
6. stk.Push(obj);
7. }
8. public T pop()
9. {
10. T obj = stk.Pop();
11. return obj;
12. }
13. }
14. class Program
15. {
16. static void Main(string[] args)
17. {
18. Generic<string> g = new Generic<string>();
19. g.push("C++");
20. Console.WriteLine(g.pop() + " ");
21. Generic<int> g1 = new Generic<int>();
22. g1.push(20);
23. Console.WriteLine(g1.pop());
24. Console.ReadLine();
25. }
26. }
a) C++
b) 20
c) C++
20
d) 0
View Answer
Answer: c
Output : C++
20
8. Select the type arguement of open constructed type?
a) Gen
b) Gen
c) Gen<>
d) None of the mentioned
View Answer
Answer: c
Explanation: A generic type, such as Gen, is an abstraction.In C# terminology, a construct such as
Gen is called an open constructed type, because the type parameter T (rather than an actual type,
such as int) is specified.

9. Choose the correct way to call subroutine fun() of the sample class?
1. class a
2. {
3. public void x(int p, double k)
4. {
5. Console.WriteLine("k : csharp!");
6. }
7. }
a) delegate void del(int i);
x s = new x();
del d = new del(ref s.x);
d(8, 2.2f);
b) delegate void del(int p, double k);
del d;
x s = new x();
d = new del(ref s.x);
d(8, 2.2f);
c) x s = new x();
delegate void d = new del(ref x);
d(8, 2.2f);
d) all of the mentioned
View Answer
Answer: b
Explanation: None.
10. What does the following code set defines?
1. public Gen(T o) {
2. ob = o;
3. }
a) Generics class decleration
b) Decleration of variable
c) Generic constructor decleration
d) All of the mentioned
View Answer
Answer: c
Explanation: None.

1. Fill up the blank :


Pointer variable is used to hold the _________ of the variable
a) Value
b) Address
c) Value and Address
d) Name of the variable
View Answer
Answer: b
Explanation: By definition.
2. Which among the given operators is referred as address of operator?
a) *
b) ^
c) &
d) ~
View Answer
Answer: c
Explanation: The & is a unary operator that returns the memory address of its operand.
For example, int* ip;
int num = 10;
ip = # puts into ip the memory address of the variable num. This address is the location of the
variable in the computers internal memory.
3. Choose the correct statement among the given statements?
a) Use of return statement is necessary in every function
b) return statement may not be followed by a parenthesis
c) A program may contain more than one return statement
d) return statement may not return a value
View Answer
Answer: a
Explanation: None.
4. What is size of a char pointer?
a) 1 byte
b) 2 byte
c) 3 byte
d) 4 byte
View Answer
Answer: b
Explanation: class UnsafeCode
{
unsafe static void Main()
{
char ch;
Console.WriteLine(sizeof(char));
Console.ReadLine();
}
}
The sizeof() method helps in calculating size of char pointer .
5. After incrementing a float pointer ptr by 1 it would be incremented by
__________
a) 1 byte
b) 2 bytes
c) 3 bytes
d) 4 bytes
View Answer
Answer: d
Explanation: None.
6. Which of the following job is done by the instruction ++*p for an integer pointer
p?
a) increment value contained at address p
b) increment address contained in p
c) Both a and b
d) Neither a nor b
View Answer
Answer: a
Explanation: class UnsafeCode
{
unsafe static void Main()
{
int n = 10;
int* p = &n;
Console.WriteLine(*p);
}
}
Output : 10 + 1 = 11.
7. What will be the output of given code?
1. class UnsafeCode
2. {
3. unsafe static void Main()
4. {
5. int a = 2;
6. int b = 4;
7. int *a1 = &a;
8. int *b1 = &b;
9. Console.WriteLine(*a1 + *b1);
10. }
11. }
a) 6
b) print garbage value
c) print -6
d) print address of b + a
View Answer
Answer: a
Explanation: The (*) operator prints the value stored at address (&) of a.
Output : 4 + 2 = 6
8. What will be the output of given code segment?
1. class UnsafeCode
2. {
3. unsafe static void Main()
4. {
5. int n = 10;
6. void* p = &n;
7. Console.WriteLine(*p);
8. Console.ReadLine();
9. }
10. }
a) The program will print 10
b) Run time error
c) Compile time error
d) output is address contained in p
View Answer
Answer: c
Explanation: The program will result in compile time error because void pointer cannot point
anywhere.
9. Which among the following is referred as an array of pointers?
a) int *p;
b) int (*)p;
c) int p[4];
d) int*[4] p;
View Answer
Answer: d
Explanation: None.
10. Among the given pointer which of following cannot be incremented?
a) int
b) char
c) float
d) void
View Answer
Answer: d
Explanation: None.
11. How many values can be returned from a function simultaneously using
pointers?
a) 1
b) 2
c) 3
d) as many as user wants
View Answer
Answer: d
Explanation: None.
12. Consider an integer pointer *a.++*a will increment ___________ while *a++
will increment __________
a) value at a, address contained in a
b) value at a,value at a
c) address contained in a, address contained in a
d) address contained in a, value at a
View Answer
Answer: a
Explanation: None.
13. What will be the ouput of given code snippet?
1. class UnsafeCode
2. {
3. unsafe static void Main()
4. {
5. int* a;
6. int a1 = 10;
7. int b1;
8. b1 = *&a1;
9. a = &b1;
10. {
11. Console.WriteLine(*a);
12. Console.ReadLine();
13. }
14. }
15. }
a) program will print garbage value
b) program will print address of a
c) program will print value of a1
d) program will print address of a1
View Answer
Answer: c
Explanation: The address of variable a1 is stored in variable b1 by making a1 as a pointer to variable
b1 later on variable b1 address is stored in pointer a and hence using pointer operation value of a1
is displayed in a.
Output : 10
14. What will be the output of code snippet?
1. class UnsafeCode
2. {
3. unsafe static void Main()
4. {
5. int n = 10;
6. int* p = &n;
7. int** p1 = &p;
8. int*** p2 = &p1;
9. Console.WriteLine(*p * **p1 * ***p2);
10. Console.ReadLine();
11. }
12. }
a) Compile time error
b) garbage value is printed
c) program will print 1000
d) program will print 100
View Answer
Answer: c
Explanation: None.
Output :1000
15. What will be the output of following code snippet?
1. class UnsafeCode
2. {
3. unsafe static void Main()
4. {
5. int* p;
6. p = (int*)(65535);
7. Console.WriteLine((uint)p);
8. Console.ReadLine();
9. }
10. }
a) Compile time error
b) garbage value
c) program print value at address 65535
d) program print 65535
View Answer
Answer: d
Explanation: None.
Output :65535

1. What will be the output of given code?


1. class UnsafeCode
2. {
3. unsafe static void Main()
4. {
5. int m = 10;
6. int *mptr = &m;
7. int **ptr = &mptr;
8. int n = 20;
9. int *nptr = &n;
10. int **prt = &nptr;
11. m = **prt + *nptr;
12. n = *mptr* **prt;
13. Console.WriteLine(n + " " + m);
14. Console.ReadLine();
15. }
16. }
a) 20 200
b) 40 200
c) 800 40
d) 40 800
View Answer
Answer: c
Explanation: None.
Output: 800 40
2. What will be the output of code snippet?
1. unsafe static void Main()
2. {
3. int a = 5;
4. int b = 5;
5. int c = 5;
6. int*[] ptr = new int* [3];
7. ptr[0] = &a;
8. ptr[1] = &b;
9. ptr[2] = &c;
10. for (a = 0; a < 3; a++)
11. {
12. c += *ptr[a];
13. Console.WriteLine(c);
14. }
15. Console.ReadLine();
16. }
a) 5 10
b) 10 20
c) Compile time error
d) 5 10 20
View Answer
Answer: d
Explanation: None.
Output:5 10 20
3. What will be the output of code snippet?
1. class UnsafeCode
2. {
3. unsafe static void Main()
4. {
5. int* ptrs = stackalloc int[3];
6. ptrs[0] = 1;
7. ptrs[1] = 2;
8. ptrs[2] = 3;
9. for (int i = 2; i >= 0; --i)
10. {
11. ptrs[i] = ptrs[i]* 3;
12. ptrs[i] = ptrs[i] + 4;
13. Console.WriteLine(ptrs[i]);
14. }
15. Console.ReadLine();
16. }
17. }
a) 20, 10, 7
b) 13, 10, 7
c) 6, 9, 3
d) Compile time error
View Answer
Answer: b
Explanation: None.
Output: 13, 10, 7
4. Among the given pointer which of following cannot be incremented?
a) int
b) char
c) float
d) void
View Answer
Answer: d
Explanation: None.
5. A structure pointer points to __________
a) first member of structure
b) first two members of structure
c) whole structure
d) only to the last member of structure
View Answer
Answer: c
Explanation: None.
6. How will be declared the variable ptr as the pointer to array of 6 floats?
a) float *ptr[6]
b) float [6]*ptr
c) float(*ptr)[6]
d) float(*ptr)(6)
View Answer
Answer: c
Explanation: None.
7. what will be the output of code snippet?
1. class UnsafeCode
2. {
3. unsafe static void Main()
4. {
5. char[] arr = { 'A', 'B', 'C', 'D', 'E' };
6. fixed (char* P = arr)
7. {
8. int i;
9. for (i = 0 ;i < 5 ;i++)
10. if (*P % 2 == 0)
11. ++*P;
12. else
13. (*P)++;
14. Console.WriteLine(arr);
15. }
16. Console.ReadLine();
17. }
18. }
a) ACCEE
b) FBCDE
c) BBDDF
d) BBCEE
View Answer
Answer: b
Explanation: None.
Output:FBCDE
8. What will be the output of given code snippet?
1. class UnsafeCode
2. {
3. unsafe static void Main()
4. {
5. int[] nums = new int[10];
6. Console.WriteLine("Index pointer like array.");
7. fixed (int* p = nums)
8. {
9. for (int i = 0 ;i <10 ;i++)
10. p[i] = i;
11. for (int i = 10 ;i >0 ;i--)
12. Console.WriteLine("p[{0}]: {1} ", i, p[i]);
13. Console.ReadLine();
14. }
15. }
16. }
a) p[10] :0, p[9] :9, p[8] :8..p[1]:1
b) p[10] : 1, p[9] :2, p[8] :3..p[1] :0
c) p[1] : 1, p[2] :2, p[3] :3..p[10] :0
d) Compile time error
View Answer
Answer: a
Explanation: None.
Output:Index pointer like array:
p[10] :0, p[9] :9, p[8] :8p[1]:1
9. What will be the output of given code snippet?
1. class UnsafeCode
2. {
3. unsafe static void Main()
4. {
5. string str = "this is a test";
6.
7. fixed (char* p = str)
8. {
9. for (int i = str.Length-1 ;p[i] != 0 ;i--)
10. Console.Write(p[i]);
11. }
12. Console.ReadLine();
13. }
14. }
a) test a is this
b) compile time error
c) tset a si siht
d) Run time error
View Answer
Answer: c
Explanation: Reversal of string using pointers.
Output:tset a si siht
10. What will be the output of given code snippet?
1. class UnsafeCode
2. {
3. unsafe static void Main()
4. {
5. int* p ;
6. int ch = 13*5;
7. p = &(ch);
8. Console.WriteLine(Convert.ToChar(*p));
9. if (*p == 'A')
10. Console.WriteLine(Convert.ToBoolean(1));
11. else
12. Console.WriteLine(Convert.ToBoolean(0));
13. Console.ReadLine();
14. }
15. }
a) 65 False
b) 65 1
c) A True
d) A 1
View Answer
Answer: c
Explanation: Convert.Tochar(*p) = A
Convert.ToBoolean(1) = True
Output: A
True

1. What will be the output of given code snippet?


1. class UnsafeCode
2. {
3. struct MyStruct
4. {
5. public int a;
6. public int b;
7. public int Sum()
8. {
9. return a * b;
10. }
11. }
12. unsafe static void Main()
13. {
14. MyStruct o = new MyStruct();
15. MyStruct* p;
16. p = &o;
17. p->a = 10;
18. p->b = 20;
19. Console.WriteLine("Value is " + p->Sum());
20. Console.ReadLine();
21. }
22. }
a) Compile time error
b) Run time error
c) 200
d) 30
View Answer
Answer: c
Explanation: A pointer can point to an object of a structure type as long as the structure does not
contain reference types. When we access a member of a structure through a pointer, WE must use
the arrow operator, which is >, rather than the dot (.) operator.
Output : 200
2. What will be the output of given code snippet?
1. class UnsafeCode
2. {
3. struct MyStruct
4. {
5. public int a;
6. public int b;
7. public int Sum()
8. {
9. return a / b;
10. }
11. }
12. unsafe static void Main()
13. {
14. MyStruct o = new MyStruct();
15. MyStruct* p;
16. p = &o;
17. p->a = 60;
18. p->b = 15;
19. int c = 30;
20. Console.WriteLine("Value is : " + p->Sum()*c);
21. Console.ReadLine();
22. }
23. }
a) Compile time error
b) 120
c) Run time error
d) 4
View Answer
Answer: b
Explanation: None.
Output :120
3. What will be the output of given code snippet?
1. class UnsafeCode
2. {
3. unsafe static void Main()
4. {
5. int[] nums = new int[10];
6. fixed (int* p = &nums[0], p2 = nums)
7. {
8. if (p == p2)
9. Console.WriteLine("p and p2 point to same address.");
10. Console.ReadLine();
11. }
12. }
13. }
a) Run time error
b) Compile time error
c) p and p2 point to same address
d) Only b
View Answer
Answer: c
Explanation: None.
Output: p and p2 point to same address
4. What will be the output of given code snippet?
1. class UnsafeCode
2. {
3. static void Main()
4. {
5. int? count = null;
6. int? result = null;
7. int incr = 10;
8. result = count + incr;
9. if (result.HasValue)
10. Console.WriteLine("result has this value: " + result.Value);
11. else
12. Console.WriteLine("result has no value");
13. Console.ReadLine();
14. }
15. }
a) Run time error
b) 0
c) result has no value
d) Compile time error
View Answer
Answer: c
Explanation: A nullable object can be used in expressions that are valid for its underlying type.When
non-nullable and nullable types are mixed in an operation, the outcome is a nullable value.
Output: result has no value
5. What will be the output of given code snippet?
1. class UnsafeCode
2. {
3. static void Main()
4. {
5. int count = 100;
6. int? result = null;
7. int incr = 10;
8. result = count + incr;
9. if (result.HasValue)
10. Console.WriteLine("result has this value: " + result.Value);
11. else
12. Console.WriteLine("result has no value");
13. Console.ReadLine();
14. }
15. }
a) Run time error
b) 110
c) result has no value
d) Compile time error
View Answer
Answer: b
Explanation: None.
Output: result has this value : 110
6. Choose the statement which defines the Nullable type Correctly:
a) a special version of a value type that is represented by a structure
b) a nullable type can also store the value null
c) Nullable types are objects of System.Nullable, where T must be a non nullable
value type
d) None of the mentioned
View Answer
Answer: a, b, c
Explanation: A nullable type is a special version of a value type that is represented by a structure. In
addition to the values defined by the underlying type, a nullable type can also store the value null.
Thus, a nullable type has the same range and characteristics as its underlying type. It simply adds
the ability to represent a value that indicates that a variable of that type
is unassigned. Nullable types are objects of System.Nullable, where T must be a nonnullable value
type.

7. What does the following code depicts?


1. System.Nullable count;
2. bool? done;
a) code 1 declares the objects of nullable of type Nullable defined in the System
namespace
b) code 2 declares a nullable type in much shorter and in more commonly used
way using ?
c) Both a & b
d) None of the mentioned
View Answer
Answer: c
Explanation: None.
8. Which operator is commanly used to find the size of the type of C#?
a) size()
b) sizeof(type)
c) Both a & b
d) None of the mentioned
View Answer
Answer: b
Explanation: None.
9. What will be the output of given code snippet?
1. unsafe struct FixedBankRecord
2. {
3. public fixed byte Name[80];
4. public double Balance;
5. public long ID;
6. }
7. class UnsafeCode
8. {
9. unsafe static void Main()
10. {
11. Console.WriteLine("Size of FixedBankRecord is " + sizeof(FixedBankRecord));
12. Console.ReadLine();
13. }
14. }
a) Run time error
b) 80
c) 96
d) Compile time error
View Answer
Answer: c
Explanation: The purpose of a fixed-size buffer is to allow the creation of a struct in which the array
elements that make up the buffer are contained within the struct.By using a fixed-size buffer, we let
the entire array to be contained within the struct.The overall size of FixedBankRecord is 96, which is
the sum of its members.
Output : 96
10. What will be the output of given code snippet?
1. class UnsafeCode
2. {
3. unsafe static void Main()
4. {
5. int* ptrs = stackalloc int[3];
6. ptrs[0] = 1;
7. ptrs[1] = 2;
8. ptrs[2] = 3;
9. for (int i = 2; i >=0; i--)
10. Console.WriteLine(ptrs[i]);
11. Console.ReadLine();
12. }
13. }
a) 3 2 1
b) 1 2 3
c) None of the mentioned
d) run time error
View Answer
Answer: a
Explanation: Allocate memory from the stack by using stackalloc.Here, ptrs is a pointer that receives
the address of the memory that is large enough to hold size of number of objects of type int.Here,
type int is a non reference type.Finally, stackalloc can be used only in an unsafe context.
Output : 3 2 1

1. Which among these access specifiers should be used for main() method?
a) private
b) public
c) protected
d) None of the mentioned
View Answer
Answer: b
Explanation: main() method must be specified public as it called by Csharp run time system outside
of the program,by default main is private in nature if no access specifier is used.
2. Which of these is used as default for a member of a class if no access
specifier is used for it?
a) private
b) public
c) protected internal
d) protected
View Answer
Answer: a
Explanation: None.
3. What is the process by which we can control what parts of a program can
access the members of a class?
a) Polymorphism
b) Abstraction
c) Encapsulation
d) Recursion
View Answer
Answer: c
Explanation: None.
4. Which of these base class are accessible to the derived class members?
a) static
b) protected
c) private
d) Shared
View Answer
Answer: b
Explanation: None.
5. What will be the output of given code snippet?
1. class access
2. {
3. public int x;
4. private int y;
5. public void cal(int a, int b)
6. {
7. x = a + 1;
8. y = b;
9. }
10. }
11. class Program
12. {
13. static void Main(string[] args)
14. {
15. access obj = new access();
16. obj.cal(2, 3);
17. Console.WriteLine(obj.x + " " + obj.y);
18. }
19. }
a) 3 3
b) 2 3
c) Run time error
d) Compile time error
View Answer
Answer: d
Explanation: y is defined privately which cannot be accessed outside its scope.
6. What will be the output of given code snippet?
1. class access
2. {
3. public int x;
4. private int y;
5. public void cal(int a, int b)
6. {
7. x = a + 1;
8. y = b;
9. }
10. public void print()
11. {
12. Console.WriteLine(" " + y);
13. }
14. }
15. class Program
16. {
17. static void Main(string[] args)
18. {
19. access obj = new access();
20. obj.cal(2, 3);
21. Console.WriteLine(obj.x);
22. obj.print();
23. Console.ReadLine();
24. }
25. }
a) 2 3
b) 3 3
c) Run time error
d) Compile time error
View Answer
Answer: b
Explanation: None.
7. What will be the output of following set of code?
1. class sum
2. {
3. public int x;
4. public int y;
5. public int add (int a, int b)
6. {
7. x = a + b;
8. y = x + b;
9. return 0;
10. }
11. }
12. class Program
13. {
14. static void Main(string[] args)
15. {
16. sum obj1 = new sum();
17. sum obj2 = new sum();
18. int a = 2;
19. obj1.add(a, a + 1);
20. obj2.add(5, a);
21. Console.WriteLine(obj1.x + " " + obj2.y);
22. Console.ReadLine();
23. }
24. }
a) 6, 9
b) 5, 9
c) 9, 10
d) 3, 2
View Answer
Answer: b
Explanation: Here, a = 2, a + 1 = 2 + 1 = 3.
So, a = 2, b = 3.
x = 2 + 3 = 5.
y = 5 + 3 = 8.
Similarly, a = 5, b = a + 1 = 4.
y = 5 + 4 = 9.
Output : 5, 9.
8. What will be the output of following set of code?
1. class static_out
2. {
3. public static int x;
4. public static int y;
5. public int add(int a, int b)
6. {
7. x = a + b;
8. y = x + b;
9. return 0;
10. }
11. }
12. class Program
13. {
14. static void Main(string[] args)
15. {
16. static_out obj1 = new static_out();
17. static_out obj2 = new static_out();
18. int a = 2;
19. obj1.add(a, a + 1);
20. obj2.add(5, a);
21. Console.WriteLine(static_out.x + " " + static_out.y );
22. Console.ReadLine();
23. }
24. }
a) 7 7
b) 6 6
c) 7 9
d) 9 7
View Answer
Answer: c
Explanation: None.
Output : 7, 9
9. Which of these access specifier must be used for class so that it can be
inherited by another sub class?
a) public
b) private
c) both a & b
d) None of the mentioned
View Answer
Answer: a
Explanation: None.
10. Which of the following statements are incorrect?
a) public members of class can be accessed by any code in the program
b) private members of class can only be accessed by other members of the class
c) private members of class can be inherited by a sub class, and become
protected members in sub class
d) protected members of a class can be inherited by a sub class, and become
private members of the sub class
View Answer
Answer: c
Explanation: private members of a class can not be inherited by a sub class.
11. What will be the output of code snippet?
1. class test
2. {
3. public int a;
4. public int b;
5. public test(int i, int j)
6. {
7. a = i;
8. b = j;
9. }
10. public void meth(test o)
11. {
12. o.a *= 2;
13. o.b /= 2;
14. }
15. }
16. class Program
17. {
18. static void Main(string[] args)
19. {
20. test obj = new test(10, 20);
21. obj.meth(obj);
22. Console.WriteLine(obj.a + " " + obj.b);
23. Console.ReadLine();
24. }
25. }
a) 20, 40
b) 40, 20
c) 20, 10
d) 10, 20
View Answer
Answer: c
Explanation: None.
Output :20, 10
12. Accessibility modifier defined in a class are?
a) public, private, protected
b) public, internal, protected internal.
c) public, private, internal, protected internal.
d) public, private, protected, internal, protected internal
View Answer
Answer: d
Explanation: None.

1. What are strings in C#?


a) a sequence of characters
b) array of characters
c) objects of built in data type
d) a reference type
View Answer
Answer: c, d
Explanation: Generally, a string is defined as a sequence of characters but its different in C# for c++
string is array of characters.In case of C# strings are objects of the built-in string data type. Thus,
string is a reference type
2. Select the namespace in which string class is built?
a) System.Text
b) System.Net
c) System.IO
d) None of the mentioned
View Answer
Answer: a
Explanation: None.
3. Select the interfaces defined by the string class?
a) IComparable
b) IComparable
c) ICloneable
d) IEnumerable
View Answer
Answer: a, b, c, d
Explanation: None.
4. Choose the constructor type used to built strings from character array:
a) public String(char[ ] value)
b) public String(char[ ] value, int startIndex, int length)
c) public String(char[ ])
d) All of the mentioned
View Answer
Answer: a, b
Explanation: public String(char[ ] value) This form of constructor constructs a string that contains
characters in value
public String(char[ ] value, int startIndex, int length) -The second form uses length characters from
value, beginning at the index specified by startIndex
5. Select the operators used for checking the equality in strings:
a) !=
b) ==
c) <
d) >=
View Answer
Answer: a, b
Explanation: None.
6. What does the given code set specifies?
1. public static int Compare(string strA, string strB)
a) Comparison is case and culture sensitive
b) Two strings A and B are compared with each other
c) Output is : >0 for (A > B), <0 for (A < B) else '0' for(A=B)
d) All of the mentioned
View Answer
Answer: d
Explanation: Compares the string referred to by strA with strB. Returns greater than zero if strA is
greater than strB, less than zero if strA is less than strB, and zero if strA and strB are equal. The
comparison is case- and culture-sensitive
7. Select the output for given set of code:
1. static void Main(string[] args)
2. {
3. string s1 = "Hello" + "c" + "Sharp";
4. Console.WriteLine(s1);
5. Console.ReadLine();
6. }
a) Hello c Sharp
b) HellocSharp
c) Compile time error
d) Hello
View Answer
Answer: a
Explanation: Here + defined operator works as concatenation for strings.
Output : Hello c Sharp
8. Which of these operators can be used to concatenate two or more String
objects?
a) +
b) +=
c) &
d) ||
View Answer
Answer: a
Explanation: string s1 = Hello+ I + Love + ComputerScience ;
Console.WriteLine(s1);
Output :Hello I Love ComputerScience.
9. What does the given code set specifies?
1. public static int Compare(string strA, int indexA, string strB, int indexB, int leng
th, bool ignoreCase)
a) Comparison begins at strA[indexA] and strB[indexB] and runs for length of
characters
b) Returns output > 0 for for strA > strB else < 0 for strA < strB else if strA = str B
output is 0
c) Comparison is culture sensitive and if ignore case is true, comparison ignores
case differences
d) All of the mentioned
View Answer
Answer: d
Explanation: Compares portions of the strings referred to by strA and strB. The comparison begins
at strA[indexA] and strB[indexB] and runs for length characters. Returns greater than zero if strA is
greater than strB, less than zero if strA is less than strB, and zero if strA and strB are equal. If
ignoreCase is true, the comparison ignores case differences. Otherwise, case differences matter.
The comparison is culture-sensitive.
10. Which string operation does the below mentioned method defines?
1. public static string Concat(string str0, string str1)
a) method returns a string
b) string str1 is concatenated to the end of str0
c) can be used to concatenate any number of strings
d) None of the mentioned
View Answer
Answer: a, b, c
Explanation: This method returns a string that contains str1 concatenated to the end of str0. Another
form of Concat(), shown here, concatenates three strings:
public static string Concat(string str0, string str1, string str2). Hence, any number of strings can be
concatenated using this method.
11. Choose the base class for string() method :
a) System.Array
b) System.char
c) System.String
d) None of the mentioned
View Answer
Answer: c
Explanation: String is an alias for the predefined System.string class from which most of the string()
methods are derived.
12. Method use to remove white space from string?
a) Split()
b) Substring()
c) Trim()
d) TrimStart()
View Answer
Answer: c
Explanation: Perfectly removes a whitespace from string whereas TrimStart() removes a string of
characters from the end of the string.

1. What will be the output of given code snippet?


1. static void Main(string[] args)
2. {
3. string s1 = "olleH";
4. string s2 = "olleh";
5. if (s1 == s2)
6. Console.WriteLine("Equal");
7. else
8. Console.WriteLine("Unequal");
9. if (s1.Equals(s2))
10. Console.WriteLine("Equal");
11. else
12. Console.WriteLine("Unequal");
13. Console.ReadLine();
14. }
a) Equal
Unequal
b) Unequal
Equal
c) Equal
Equal
d) Unequal
Unequal
View Answer
Answer: d
Explanation: In first comparison it is being checked either two strings are equal or not but in second
comparison it is checked whether two string references are equal or not also length of string and
characters match is tested for checking the equality of strings.
Output : Unequal
Unequal
2. What will be the output of given code snippet?
1. static void Main(string[] args)
2. {
3. string s1 = " Ixg";
4. string s2 = s1.Insert(3,"i");
5. string s3 = s2.Insert(5, "o");
6. for (int i = 0; i < s3.Length; i++)
7. Console.WriteLine(s3[i]);
8. Console.ReadLine();
9. }
a) Ixgo
b) Ixig
c) Ixigo
d) Ixg
View Answer
Answer: c
Explanation: Insert() the built in method insert characters at specified position mentioned with index
positions.
Output :Ixigo
3. What will be the output of given code snippet?
1. class Program
2. {
3. static void Main(string[] args)
4. {
5. char []chars = {'a', 'b', 'c'};
6. String s = new String(chars);
7. Console.WriteLine(s);
8. Console.ReadLine();
9. }
10. }
a) a
b) b
c) c
d) abc
View Answer
Answer: d
Explanation: String(chars) is a constructor of class string, it initializes string s with the values stored
in character array chars,So s contains abc.
Output :abc
4. What will be the output of given code snippet?
1. class Program
2. {
3. static void Main(string[] args)
4. {
5. char []chars = {'a', 'b', 'c'};
6. String s = new String(chars);
7. String s1 = "abcd";
8. int len1 = s1.Length;
9. int len2 = s.Length;
10. Console.WriteLine(len1 + " " + len2);
11. Console.ReadLine();
12. }
13. }
a) 4 0
b) 3 0
c) 3 4
d) 4 3
View Answer
Answer: d
Explanation: None.
Output : 4 3
5. What will be the output of given code snippet?
1. class A
2. {
3. int i;
4. int j;
5. public A()
6. {
7. i = 1;
8. j = 2;
9. }
10. }
11. class Program
12. {
13. static void Main(string[] args)
14. {
15. A obj1 = new A();
16. Console.WriteLine(obj1.ToString());
17. Console.ReadLine();
18. }
19. }
a) true
b) false
c) String associated with obj1
d) Compile time error
View Answer
Answer: c
Explanation: ToString() is method of class Object, since it is superclass of every class, every object
has this method. ToString() returns the string associated with the calling object.
Output : ConsoleApplication19.A
6. Which of these constructors is used to create an empty String object?
a) String()
b) String(void)
c) String(0)
d) None of the mentioned
View Answer
Answer: a
Explanation: None.
7. Which of these method of class String is used to obtain length of String object?
a) get()
b) Sizeof()
c) Lengthof()
d) Length()
View Answer
Answer: d
Explanation: Method Length() of string class is used to get the length of the object which invoked
method Length().
8. Choose the base class for string() method :
a) System.Array
b) System.char
c) System.String
d) None of the mentioned
View Answer
Answer: c
Explanation: String is an alias for the predefined System.string class from which most of the string()
methods are derived.
9. What will be the output of given code snippet?
1. class Program
2. {
3. static void Main(string[] args)
4. {
5. String c = "Hello i love Csharp";
6. Boolean var;
7. var = c.StartsWith("hello");
8. Console.WriteLine(var);
9. Console.ReadLine();
10. }
11. }
a) True
b) False
c) 1
d) Run time error
View Answer
Answer: b
Explanation: StartsWith() method is case sensitive hello and Hello are treated differently, hence
false is stored in var.
10. What is the value returned by function CompareTo() if the invoking string is
less than the string compared?
a) zero
b) value less than zero
c) value greater than zero
d) None of the mentioned
View Answer
Answer: b
Explanation: CompareTo() function returns zero when both the strings are equal, it returns a value
less than zero if the invoking string is less than the other string being compared and value greater
than zero when invoking string is greater than the string compared to.
11. What will be the output of give code snippet?
1. class Program
2. {
3. static void Main(string[] args)
4. {
5. String s1 = "Hello i love Csharp";
6. StringBuilder s2 = new StringBuilder(s1);
7. Console.WriteLine(s1.Equals(s2));
8. Console.ReadLine();
9. }
10. }
a) True
b) False
c) 0
d) Compile time error
View Answer
Answer: b
Explanation: Equals() compares the content of two strings. StringBuilder class supports many
methods which are useful for manipulating dynamic strings.
Output :False
12. Which of these method of class String is used to check whether a given string
starts with a particular substring or not?
a) StartsWith()
b) EndsWith()
c) Starts()
d) Ends()
View Answer
Answer: a
Explanation: The StartsWith() determines whether a substring exists at the beginning of the string.

1. Which of these method of class String is used to extract a substring from a


String object?
a) substring()
b) Substring()
c) SubString()
d) None of the mentioned
View Answer
Answer: b
Explanation: None.
2. Write the output for given code snippet?
1. class Program
2. {
3. static void Main(string[] args)
4. {
5. String s1 = "one";
6. String s2 = string.Concat(s1 + " " + "two");
7. Console.WriteLine(s2);
8. Console.ReadLine();
9. }
10. }
a) one
b) two
c) one two
d) two one
View Answer
Answer: c
Explanation: Two strings can be concatenated by using Concat() method.
Output: one two
3. Which of these method of class String is used to remove leading and trailing
whitespaces?
a) startsWith()
b) TrimEnd()
c) Trim()
d) TrimStart()
View Answer
Answer: c
Explanation: Removes white space from the string
4. What will be the output of given code snippet?
1. class Program
2. {
3. static void Main(string[] args)
4. {
5. String c = " Hello World ";
6. String s = c.Trim();
7. Console.WriteLine("""+s+""");
8. Console.ReadLine();
9. }
10. }
a) Hello World
b) HelloWorld
c) Hello World
d) Hello
View Answer
Answer: c
Explanation: Trim() method is used to remove leading and trailing whitespaces in a string.
Output: Hello World
5. What will be the output of code snippet?
1. class Program
2. {
3. static void Main(string[] args)
4. {
5. String s1 = "CSHARP";
6. String s2 = s1.Replace('H','L');
7. Console.WriteLine(s2);
8. Console.ReadLine();
9. }
10. }
a) CSHAP
b) CSHP
c) CSHALP
d) CSHP
View Answer
Answer: c
Explanation: Replace() method replaces all occurrences of one character in invoking string with
another character. s1.Replace(H,'L) replaces every occurrence of H in CSHARP by L, giving
CSHALP.
Output: CSHALP
6. What will be the output of code snippet?
1. class Program
2. {
3. static void Main(string[] args)
4. {
5. String s1 = "Hello World";
6. String s2 = s1.Substring(0, 4);
7. Console.WriteLine(s2);
8. Console.ReadLine();
9. }
10. }
a) Hello
b) Hell
c) H
d) Hello World
View Answer
Answer: b
Explanation: None.
Output: Hell
7. What will be the output of given code snippet?
1. class Program
2. {
3. static void Main(string[] args)
4. {
5. String s = "Hello World";
6. int i = s.IndexOf('o');
7. int j = s.LastIndexOf('l');
8. Console.WriteLine(i + " " + j);
9. Console.ReadLine();
10. }
11. }
a) 9 5
b) 4 9
c) 9 0
d) 9 4
View Answer
Answer: b
Explanation: None.
Output: 4 9
8. What will be the output of given code snippet?
1. class Program
2. {
3. static void Main(string[] args)
4. {
5. String c = "i love Csharp";
6. bool a;
7. a = c.StartsWith("I");
8. Console.WriteLine(a);
9. Console.ReadLine();
10. }
11. }
a) true
b) false
c) 0
d) 1
View Answer
Answer: b
Explanation: StartsWith() method is case sensitive i and I are treated differently, hence false is
stored in a.
Output: false
9. What will be the output of code snippet?
1. class Program
2. {
3. static void Main(string[] args)
4. {
5. String []chars = {"z", "x", "y", "z", "y"};
6. for (int i = 0; i < chars.Length; ++i)
7. for (int j = i + 1; j < chars.Length; ++j)
8. if(chars[i].CompareTo(chars[j]) == 0)
9. Console.WriteLine(chars[j]);
10. Console.ReadLine();
11. }
12. }
a) zx
b) xy
c) zy
d) yz
View Answer
Answer: c
Explanation: compareTo() function returns zero when both the strings are equal, it returns a value
less than zero if the invoking string is less than the other string being compared and value greater
than zero when invoking string is greater than the string compared To 4
Output: z
y
10. What will be the output of code snippet?
1. static void main(String args[])
2. {
3. char chars[] = {'a', 'b', 'c'};
4. String s = new String(chars);
5. Console.WriteLine(s);
6. }
a) a
b) b
c) ab
d) abc
View Answer
Answer = d
Explanation: None.
Output: abc
11. What will be the output of given code snippet?
1. static void Main(string[] args)
2. {
3. string s = " i love you";
4. Console.WriteLine(s.IndexOf('l') + " " + s.lastIndexOf('o') + " " + s.IndexOf
('e'));
5. Console.ReadLine();
6. }
a) 3 5 7
b) 4 5 6
c) 3 9 6
d) 2 4 6
View Answer
Answer: c
Explanation: indexof(l) and lastIndexof(o) are pre defined function which are used to get the index
of first and last occurrence of the character pointed by l and c respectively in the given array.
Output: 3, 9, 6

Vous aimerez peut-être aussi