Académique Documents
Professionnel Documents
Culture Documents
////////////////////////////////////////////////////////////////////////////////////////////////////////
1) What is the significance of document type definition(DTD)? please select all relevant options?
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
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
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
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
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?
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:
Ans b
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
Select one:
a. 3&4
b. 1&5
c. 1&4&5
d. 2&3&5
e. 1&3&5
Ans c
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?
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?
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?
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
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?
2 enum is a keyword.
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?
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.
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?
2.The metadata information is presented in a format that is independent of any catalog table
implementation
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
--------------------------------------------------------
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
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
-------------------------------------------------------
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.
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
select one:
a.1&3
b.1&2&4
c.1&3&4
d.2&4
ans-- b
--------------------------------------------------------------------------------
24
select one:
b.it denotes that the language is English & Country is United States
c.it denotes that the language is English & Country is United Kingdom
ans--c
-----------------------------------------------------------------------------
25:
Select One:
a:2&4
b:3&4
c:2&3
d:1&2&3
ANS:a
===============================================
26:
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
Select one:
a: 1&3&4
b: 2&4
c: 2&3
d: 1&4
ANS:c
=================================================
27:
2:All the user interface related code is written in a .cs or .vb file
select one:
a:3&4
b:1&2
c:2&3&4
d:1&3
ANS: d
==============================================
28:
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?
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
3.It allows applications to be written against conceptual models and not directly against the
database.
select one
a 2&3&4
b.1&3
c.2&3-ANS
d.1&4
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
1.Tagprefix
2.TagName
3.Cntrl
4.Src
a 3&4
b.1&2&4-ANS
c.1&2
d.2&3&4
33
ANS....4
34
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 .
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
1. c#
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?
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)
--------------------------------------------------------------------------------
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?
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?
a. 1&4
b. 3&4
c. 1&2(CORRECT)
d. 2&3
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
<asp:TextBox
SkinID="DashedTextBox"
BorderStyle="Dashed"
BorderWidth="5px"
Runat="Server"/>
Select one:
c. Usage of a stylesheet
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
Select one:
select one:
a. 2&3
b. 1&4
c. 1&3&4
d. 2&3&4
ans- a. 2&3
<div style="color:#00FF00">
</div>
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
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
2. It indicates that the relationship between tables have been correctly maintained
Select one:
a. 1&3&4
b. 3&4
c. 1&2
d. 2&3&4
ans- c. 1&2
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
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?
type.Val=5;
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
3. Lack of security
Select one:
a. 1&4
b. 2&4
c. 1&2&3
d. 1&3
ans- b. 2&4
console.writeline(day);
select one:
Ans : C
1. CROSS APPLY operator is a mechanism that allow a developer to correlate a table valued
function to another table
3.specifies that only the last set of rows will be returned from query result
a. 1&4
b.1&2
c.2&3&4
d.only 1
Ans:D
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
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.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
3.control properties are loaded with information recovered from view state and control state
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
2.the where clause of the outer query tests whether data exists in the subquerry for each row of
the outer qurery
select one
a.1&2&4
b.1&2
c.3&4
d.1&3&4
constraint?
NULL values
column
set of columns
Select one:
a. 1&2&3
b. 2&3
c. 1&4
d. 3&4
Answer: a. 1&2&3
3.With Properties even if the implementation of private state changes, the implementation is not
broken
Select one:
a. 1&2&3
b. 1&3
c. 1&4
d. 2&4
Answer: a. 1&2&3
a ASP.NET application?
1.C#
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
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
2. When working on large projects,spreading a class over separate files allows multiple
prgrammers to work on it simultaneously
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
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
Answer-2&3
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?
Answer-2&3& 4
body{background-color:#b0c4de}
2..The background-color property specifies the background color of all elements of the website
17
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?
2.The function body defined in BEGIN...END block contains a series of T-SQL statements
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
<select>
<option value="volkeswagon">VolkesWagon</option>
<option value="mercedes">Mercedes</option>
<option value="BMW">BMW</option>
<option value="audi">Audi</option>
</select>
3.The<select>tag inside the select element define the available options in the list
Select one:
a.2&3
b.3&4
c.1&3
d.1&2&3
ans---1&2&3
20
<html>
<head>
<script language="JavaScript">
function showMsg(msg){
</SCRIPT>
</head>
</body>
<form>
</form>
</body>
</html>
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)
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,>,>=,<,<=
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?
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
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
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
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.
1.Specifies thet the DML trigger is execute instead of the triggering SQL statement
select one:
a.3&4
b.1&2&3
c.1&2&4
d.1&4
ANS-b.1&2&4
int iEmpNo=10;
arrlstValues.Add(iEmpNo);
arrlstValues.Add(strEmpName);
select one:
b.You cannot assign two different data types to the same ArrayList
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
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
1 Public
2 Private
3 Protected
4 Internal
ANS: 1&2&3
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
1 Allows access only to external assemblies with minimal with access to internal computation.
3 Allows access to external system resource such as files,network & environment variables.
36. which control manages client script for AJAX- enabled ASP.NET web pages
select one
a. update control
answer: b
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
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
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?
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?
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
<configuration>
<system.web>
<pages theme="Website"/>
</system.web>
</configuration>
Select one:
43. Which of the following statements is correct about an interface used in C# .NET?
Select one:
c. In a program if one class implements an interface then no other class in the same program can
implement this interface.
Q 44
get
select one:
Q 45
What does the redirect url parameterof Authentication service.login method do?
select one
where o.onlineorderflag=true
select new{o.salesorderid,o.orderdate,o.salesordernumber};
select one
a) 1&4
b) 3&1
c) 2&3
d) 2&4
ans d) 2&4
Q 47
1 Transact-sql
2 Events handling
a) 2&3&4
b) 3&4
c) 1&3
d) 1&4
ans c) 1&3
1. Allows SQL server to support Web-based applicatins where users create their own identities.
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.
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?
Select one:
a. 2&4
b. 1&3
c. 1&3&4
d. 1&2&3
ANS d
52)
2. The WHERE clause of the outer query tests wheter data exists in the subquery for each row of
the outer query
select one
a.1,2,4
b.1,3
c.2,3,4
d.2,4
ANS A
53)
<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
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)
select one
a.2,3,4
b.1,3
c.1,2
d.1,3,4
ANS B
56)
select one
a.System.Base
a.System.Parent
a.System.Type
a.System.Object
ANS D
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
int index = 6;
try
a[index] = val;
catch (IndexOutOfRangeException e)
Console.Write("Remaining Program");
}
ANS - 1 & 3
ARRAYS
1. Which of the following statements are correct about the C#.NET code snippet given below?
A. 1, 2
B. 2, 3
C. 2, 5
D. 1, 4
E. 3, 4
Answer: Option A
Explanation:
2. Which of the following statements are correct about the C#.NET code snippet given below?
A. 1, 2
B. 2, 3, 4
C. 2, 3, 5
D. 4, 5
E. None of these
Answer: Option B
Explanation:
Answer: Option D
Explanation:
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 = int[5];
B. int[] a = int[10];
int[] a = new int[5];
C. a.Length = 10 ;
Answer: Option D
Explanation:
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?
D. foreach (int j in i)
Explanation:
6. Which of the following is the correct output of the C#.NET code snippet given below?
A. 20 B. 4
C. 18 D. 10
E. 5
Answer: Option C
Explanation:
7. Which of the following statements are correct about arrays used in C#.NET?
A. 1, 2
B. 1, 3, 5
C. 3, 4
D. 1, 2, 5
E. 4, 5
Answer: Option D
Explanation:
8. Which of the following statements are correct about the C#.NET code snippet given below?
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.
Answer: Option C
Explanation:
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: Option B
Explanation:
10. Which of the following statements is correct about the array declaration given below?
D. intMyArr refers to a 3-D jagged array containing three 2-D jagged arrays.
Answer: Option C
Explanation:
No answer description available for this question. Let us discuss.
11. Which of the following statements is correct about the C#.NET code snippet given below?
Answer: Option B
Explanation:
12. Which of the following is the correct way to define and initialise an array of 4 integers?
A. 1, 2
B. 3, 4
C. 1, 4, 5
D. 2, 4, 5
E. 5, 5
Answer: Option C
Explanation:
13. Which of the following is the correct output of the C#.NET code snippet given below?
A. 3 B. 4
C. 7 D. 9
E. 2
Answer: Option E
Explanation:
14. Which of the following is the correct way to obtain the number of elements present in the array
given below?
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: Option B
Explanation:
using System;
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: Option A
Explanation:
A. Compile-time
B. Run-time
C. Design-time
D. Linking-time
Answer: Option B
Explanation:
2. Which of the following are correct ways to specify the targets for a custom attribute?
Answer: Option D
Explanation:
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
Answer: Option C
Explanation:
4. Which of the following statements are correct about inspecting an attribute in C#.NET?
A. 1, 2
B. 3, 4
C. 1, 3, 4
Explanation:
Answer: Option A
Explanation:
123 Next
6. Which of the following statements are correct about Attributes used in C#.NET?
The CLR can change the behaviour of the code depending upon the
E.
attributes applied to it.
Answer: Option E
Explanation:
Answer: Option C
Explanation:
A. 1 and 2 only
B. 2 and 4 only
C. 1, 4 and 5 only
Answer: Option C
Explanation:
Answer: Option C
Explanation:
10. It possible to create a custom attribute that can be applied only to specific
programming element(s) like ____ .
A. Classes
B. Methods
Answer: Option C
Explanation:
A. Enum B. Event
C. Delegate D. Interface
E. Namespace
Answer: Option E
Explanation:
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: Option B
Explanation:
13. Which of the following is the correct way to apply an attribute to an Assembly?
Answer: Option B
Explanation:
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?
A. 1 only
B. 1, 5
C. 2, 3
D. 4, 5
Answer: Option C
Explanation:
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
Answer: Option B
Explanation:
1. Which of the following statements is correct about the C#.NET code snippet given below?
Answer: Option C
Explanation:
class Sample
{
private int i;
public Single j;
private void DisplayData()
{
Console.WriteLine(i + " " + j);
}
public void ShowData()
{
Console.WriteLine(i + " " + j);
}
}
Answer: Option E
Explanation:
A. 1, 3, 5
B. 2, 4
C. 3, 5
D. 2, 4, 5
E. None of these
Answer: Option A
Explanation:
Object Oriented Programming paradigm stresses on dividing the logic into smaller parts
B.
and writing procedures for each part.
Object Oriented Programming paradigm gives equal importance to data and the
D.
procedures that work on the data.
Answer: Option D
Explanation:
5. Which of the following is the correct way to create an object of the class Sample?
A. 1, 3
B. 2, 4
C. 1, 2, 3
D. 4, 5
E. None of these
Answer: Option A
Explanation:
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
Answer: Option A
Explanation:
7. The this reference gets created when a member function (non-shared) of a class is called.
A. True B. False
Answer: Option A
Explanation:
B. 1, 4
C. 2, 4, 5
D. 1, 2, 3
E. None of these
Answer: Option C
Explanation:
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];
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.
D. The call Sample.fun(1, 5) cannot work since fun() is not a shared function.
Answer: Option B
Explanation:
10. Which of the following statements are correct about the C#.NET code snippet given below?
sample c;
c = new sample();
A. 1, 3
B. 2, 4
C. 3, 5
D. 4, 5
E. None of these
Explanation:
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();
C. Since an int is a primitive, we cannot call the method ToString() using it.
Answer: Option A
Explanation:
12. Which of the following statements are correct about the this reference?
A. 1, 4
B. 2, 3, 5
C. 3, 4
D. 2, 5
E. None of these
Answer: Option B
Explanation:
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
Answer: Option B
Explanation:
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
Explanation:
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.
Explanation:
16. Which of the following statements is correct about classes and objects in C#.NET?
B. Since objects are typically big in size, they are created on the stack.
D. Smaller objects that get created on the stack can be given names.
Answer: Option E
Explanation:
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
C. 2 and 5 only
Answer: Option B
Explanation:
2. How many enumerators will exist if four threads are simultaneously working on
anArrayList object?
A. 1
B. 3
C. 2
D. 4
Answer: Option D
Explanation:
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
Answer: Option B
Explanation:
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: Option D
Explanation:
A. True B. False
Answer: Option A
Explanation:
6. Which of the following statements are correct about the C#.NET code snippet given below?
Explanation:
7. Which of the following statements are correct about the Stack collection?
A. 1 and 2 only
B. 3 and 4 only
C. 1, 2 and 5 only
Answer: Option C
Explanation:
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: Option A
Explanation:
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?
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: Option A
Explanation:
A. IComparer
B. IEnumerable
C. IEnumerator
D. IDictionaryComparer
E. IDictionaryEnumerator
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: Option B
Explanation:
1. Map
2. Stack
3. Queue
4. BitArray
5. HashTable
A. 1 only
B. 2 and 3 only
C. 4 and 5 only
Answer: Option B
Explanation:
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: Option A
Explanation:
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
Answer: Option D
Explanation:
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?
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: Option C
Explanation:
View Answer
Which of the following statements are correct about the Collection Classes available in Framework
Class Library?
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.
DATATYPES
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: Option D
Explanation:
A. Char
B. Long
C. Short
D. Byte
E. Integer
Explanation:
A. Char
B. Byte
C. Integer
D. Short
E. Long
Answer: Option A
Explanation:
Answer: Option C
Explanation:
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
Explanation:
1234 Next
A. Short
B. Integer
C. Long
D. Byte
E. Single
Answer: Option D
Explanation:
A. 4 byte
B. 8 byte
C. 16 byte
D. 32 byte
Answer: Option C
Explanation:
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: Option A
Explanation:
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;
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.
An overflow error will be reported since the result of the multiplication exceeds the
E.
range of a Short Integer.
Answer: Option A
Explanation:
A. 8 Bytes
B. 4 Bytes
C. 10 Bytes
D. 16 Bytes
E. None of the above.
Answer: Option D
Explanation:
A. 2, 5
B. 1, 5
C. 3, 4
D. 2, 3
Answer: Option B
Explanation:
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;
E. pi = 3.14F;
Answer: Option C
Explanation:
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: Option A
Explanation:
A. 2, 4
B. 1, 3
C. 3, 5
D. 4, 5
Answer: Option B
Explanation:
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: Option A
Explanation:
16. Which of the following statements are correct about datatypes in C#.NET?
A. 1, 3
B. 2, 5
C. 1, 4
D. 3, 4
Answer: Option C
Explanation:
17. Which of the following is the correct default value of a Boolean type?
A. 0 B. 1
C. True D. False
E. -1
Explanation:
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: Option C
Explanation:
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
}
Answer: Option A
Explanation:
Answer: Option D
Explanation:
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: Option C
Explanation:
5. Which of the following statements are correct about an enum used inC#.NET?
A. 1, 3
B. 2, 4
C. 2, 5
D. 3, 4
Answer: Option C
Explanation:
6. Which of the following will be the correct output for the C#.NET code snippet given below?
A. -3, -2, -1
B. -3, 0, 1
C. 0, 1, 2
Answer: Option A
Explanation:
7. An enum that is declared inside a class, struct, namespace or interface is treated as public.
A. True B. False
Explanation:
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);
The program will report an error since an enum element cannot be assigned a value
D.
outside the enum declaration.
Answer: Option D
Explanation:
9. Which of the following is the correct output for the C#.NET code snippet given below?
A. 2, 11
B. 1, 11
C. 2, 6
D. 1, 5
Answer: Option B
Explanation:
A. True B. False
Answer: Option A
Explanation:
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: Option C
Explanation:
12. Which of the following statements are correct about enum used in C#.NET?
A. 1, 2, 5
B. 1, 4
C. 3, 5
D. 2, 3, 4
Answer: Option A
Explanation:
13. Which of the following statements is correct about the C#.NET code snippet given below?
C. Since 500, 1000, 1500 exceed the valid range of byte compiler will report an error.
Answer: Option C
Explanation:
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?
Whether it a value type or a reference type depends upon a Project Setting made in
D.
Visual Stiiclio.NET.
Answer: Option B
Explanation:
17. Which of the following statements are correct about an enum used in C#.NET?
A. 1, 3, 4
B. 2, 5
C. 3, 4
D. 2, 4, 5
Answer: Option A
EXCEPTION HANDLING
A. Exception
B. StackMemoryException
C. DivideByZeroException
D. OutOfMemoryException
E. InvalidOperationException
Answer: Option B
Explanation:
C. It occurs at run-time.
Answer: Option C
Explanation:
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: Option B
Explanation:
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");
}
}
}
Answer: Option E
Explanation:
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: 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
Answer: Option B
Explanation:
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
A. 1 only
B. 1 and 2 only
C. 3, 4 and 5 only
Answer: Option C
Explanation:
8. Which of the following is the Object Oriented way of handling run-time errors?
A. OnError
B. HERESULT
C. Exceptions
D. Error codes
Answer: Option C
Explanation:
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");
}
}
}
Answer: Option A
Explanation:
No answer description available for this question. Let us discuss.
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
A. 1 only
B. 1, 2 and 3 only
C. 2 and 5 only
D. 1, 3 and 4 only
Answer: Option D
Explanation:
No answer descrip
1. Which of the following statements are correct about exception handling in C#.NET?
A. 1 only
B. 1 and 2 only
C. 3 only
D. 4 and 5 only
Answer: Option D
Explanation:
12. Exceptions can be thrown even from a constructor, whereas error codes cannot be returned
from a constructor.
A. True B. False
Answer: Option A
Explanation:
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 ");
}
}
}
Answer: Option C
Explanation:
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 ");
}
}
}
Answer: Option D
Explanation:
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: Option A
Explanation:
No answer
6. Which of the following is NOT an Exception?
A. StackOverflow
B. Division By Zero
C. Insufficient Memory
Answer: Option D
Explanation:
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");
}
}
}
Answer: Option D
Explanation:
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: Option B
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,
Answer: Option B
Explanation:
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
E. 6 12 18 24 30
Answer: Option C
Explanation:
A. 1, 2
B. 2, 3
C. 3, 4
D. 4, 5
E. None of these
Answer: Option C
Explanation:
A. True B. False
Answer: Option A
Explanation:
5. Which of the following statements are correct about functions and subroutines used in C#.NET?
A. 1, 2, 4
B. 2, 3, 5
C. 3, 5
D. 4, 5
E. None of these
Answer: Option B
Explanation:
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: Option D
Explanation:
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: Option D
Explanation:
No answer description available for this question. Let us discuss.
A. 1, 3, 5
B. 3, 4, 5
C. 2, 5
D. 4, 5
E. None of these
Answer: Option C
Explanation:
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?
Answer: Option E
Explanation:
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?
Answer: Option C
Explanation:
11. Which of the following statements are correct about functions used in C#.NET?
A. 1, 2, 5
B. 2, 3, 5
C. 2, 3
D. 4, 5
E. None of these
Answer: Option A
Explanation:
A. 1
B. 0
Answer: Option A
Explanation:
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: Option C
Explanation:
No answer description available for this question. Let us discuss.
D. 0
E. 1
Answer: Option D
Explanation:
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: Option B
Explanation:
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: Option E
Explanation:
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?
Answer: Option A
Explanation:
18. Which of the following statements are correct about subroutines used in C#.NET?
A. 1, 2, 3
B. 2, 3, 5
C. 3, 5
D. 3, 4
E. None of these
Explanation:
A. True B. False
Answer: Option A
Explanation:
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;
}
}
}
A. 1, 3
B. 2, 4
C. 4, 5
D. 1, 5
E. None of these
Answer: Option D
Explanation:
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: Option C
Explanation:
Prev 12345
GENERICS
1. Stack
2. Tree
3. SortedDictionary
4. SortedArray
A. 1 and 2 only
B. 2 and 4 only
C. 1 and 3 only
Answer: Option C
Explanation:
2. For the code snippet shown below, which of the following statements are valid?
D. Compiler will report an error: Operator '+' is not defined for types T and int.
E. None of the above.
Answer: Option D
Explanation:
3. Which of the following statements are valid about generics in .NET Framework?
A. 1 and 2 Only
B. 1, 2 and 3 Only
C. 1 and 4 Only
Answer: Option C
Explanation:
Answer: Option D
Explanation:
5. For the code snippet shown below, which of the following statements are valid?
6. For the code snippet given below, which of the following statements is valid?
Answer: Option A
Explanation:
7. For the code snippet given below, which of the following statements are valid?
A. 1 and 2 Only
B. 1, 2 and 3 Only
C. 1 and 4 Only
Answer: Option C
Explanation:
8. For the code snippet given below, which of the following statements are valid?
B. 3 and 4 Only
C. 2 and 3 Only
Answer: Option B
Explanation:
A. Generics shift the burden of type safety to the programmer rather than compiler.
Answer: Option C
INHERITNCE
A. 1, 2, 3
B. 3, 4
C. 2, 4, 5
D. 3, 5
Answer: Option A
Explanation:
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 ***]
}
}
Answer: Option B
Explanation:
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();
}
}
}
A. 1, 2, 5
B. 2, 3, 4
C. 3, 5
D. 4, 5
E. None of these
Answer: Option B
Explanation:
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: Option A
Explanation:
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: Option A
Explanation:
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
Answer: Option A
Explanation:
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: Option C
Explanation:
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);
}
}
}
Answer: Option B
Explanation:
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: Option B
Explanation:
1. Inheritance
2. Encapsulation
3. Templates
4. Containership
5. Polymorphism
A. 1, 4
B. 1, 3
C. 2, 4
D. 3, 5
Answer: Option A
Explanation:
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: Option E
Explanation:
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.
13. Which of the following statements are correct about Inheritance in C#.NET?
A. 1, 2, 4
B. 2, 4, 5
C. 1, 3, 5
D. 2, 4
Answer: Option C
Explanation:
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.
Answer: Option B
Explanation:
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);
}
}
}
Answer: Option E
Explanation:
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()
{ }
}
Answer: Option E
Explanation:
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
Explanation:
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: Option B
Explanation:
In a program if one class implements an interface then no other class in the same
B.
program can implement this interface.
Answer: Option D
Explanation:
Answer: Option B
Explanation:
Answer: Option A
Explanation:
Answer: Option C
Explanation:
A. 1, 2, 3
B. 2, 4
C. 3, 5
Answer: Option A
Explanation:
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
}
}
Answer: Option D
Explanation:
Answer: Option C
Explanation:
11. Which of the following statements are correct about an interface used in C#.NET?
A. 1, 2
B. 1, 4, 5
C. 3, 4
D. 3 only
Explanation:
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
Explanation:
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
}
}
The compiler will report an error since the interface IMyInterface is only partially
E.
implemented.
Answer: Option D
Explanation:
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();
}
Answer: Option B
Explanation:
15. Which of the following is the correct way to implement the interface given below?
interface IPerson
{
String FirstName
{
get;
set;
}
}
Answer: Option A
Explanation:
Prev 123
POLYMORPHISM
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
Explanation:
A. inherits
B. extends
C. inheritable
D. not inheritable
E. sealed
Explanation:
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: Option A
Explanation:
When used as a modifier, the new keyword explicitly hides a member inherited from a
A.
base class.
C. It is not necessary that all operator overloads are static methods of the class.
Answer: Option A
Explanation:
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: Option C
Explanation:
1234 Next
Answer: Option D
Explanation:
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.
Answer: Option D
Explanation:
B. 2, 4
C. 2, 5
D. 3, 4
Answer: Option C
Explanation:
9. Which of the following statement is correct about the C#.NET code snippet given below?
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.
Explanation:
D. A public or nested public reference type does not overload the equality operator.
Answer: Option A
Explanation:
1. true
2. false
3. new
4. ~
5. sizeof
A. 1, 3
B. 2, 4
C. 3, 5
Answer: Option C
Explanation:
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: Option B
Explanation:
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: Option C
Explanation:
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: Option A
Explanation:
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: Option C
Explanation:
A. 1, 3
B. 1, 2, 5
C. 2, 3, 4
D. 4 only
PROPERTIES
A. True B. False
Answer & Explanation
Answer: Option A
Explanation:
Answer: Option B
Explanation:
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?
Explanation:
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?
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: Option C
Explanation:
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:
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;
4. Console.WriteLine(Sample.Length);
A. 1, 3
B. 2, 4, 5
C. 4 only
D. 3, 5
Answer: Option B
Explanation:
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: Option D
Explanation:
A. True B. False
Answer: Option B
Explanation:
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;
6. Console.WriteLine(Student[3]);
A. 1, 2
B. 2, 3
C. 3, 4
D. 3, 5
Answer: Option B
Explanation:
10. If Sample class has a Length property with set accessor then which of the following statements
will work correctly?
C. Sample.Length = 20;
D. Console.WriteLine (Sample.Length);
Answer: Option E
Explanation:
11. If Sample class has a Length property with get accessor then which of the following statements
will work correctly?
D. Sample.Length = 20;
E. Console.WriteLine(Sample.Length);
Answer: Option C
Explanation:
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);
Answer: Option A
Explanation:
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: Option B
Explanation:
14. Which of the following statements is correct about properties used in C#.NET?
C. Properties of a class are actually methods that work like data members.
Answer: Option C
Explanation:
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: Option A
Explanation:
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: Option A
Explanation:
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?
Answer: Option B
Explanation:
Prev 1234
STRINGS
1. Which of the following statements are true about the C#.NET code snippet given below?
A. 1, 2, 4
B. 2, 3, 5
C. 3, 4
D. 2, 5
Explanation:
2. Which of the following will be the correct output for the C#.NET code snippet given below?
A. ARE B. CRE
C. CR D. REA
E. CREATED
Answer: Option B
Explanation:
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:
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: Option A
Explanation:
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
Explanation:
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: Option E
Explanation:
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: Option E
Explanation:
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: Option B
Explanation:
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: Option B
Explanation:
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: Option D
Explanation:
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.
Explanation:
Answer: Option D
Explanation:
13. Which of the following will be the correct output for the C#.NET code snippet given below?
A. 0 B. 1
C. 2 D. -1
E. -2
Explanation:
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: Option B
Explanation:
15. Which of the following statements are correct about the String Class in C#.NET?
B. 2, 4
C. 1, 3, 4
D. 3, 5
Answer: Option C
Explanation:
STRUCTURES
A. True B. False
Answer: Option A
Explanation:
A. True B. False
Answer: Option B
Explanation:
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
Answer: Option C
Explanation:
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;
}
name = "Amol";
E. age = 25;
sal = 5500;
Answer & Explanation
Answer: Option A
Explanation:
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;
}
A. 1, 3
B. 2, 5
C. 4, 5
D. 1, 2, 4
Answer: Option C
Explanation:
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();
Answer: Option E
Explanation:
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: Option B
Explanation:
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;
Answer: Option A
Explanation:
A. 1, 2
B. 3, 4
C. 1, 2, 4
D. 3, 5
Answer: Option A
Explanation:
A. True B. False
Answer: Option A
Explanation:
Answer: Option C
Explanation:
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();
Answer: Option D
Explanation:
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: Option D
Explanation:
B. All value types in C# inherently derive from ValueType, which inherits fromObject.
Answer: Option B
Explanation:
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();
A. 1, 2
B. 1, 3, 5
C. 2, 4
D. 3, 4, 5
Answer: Option B
Explanation:
16. Which of the following are true about classes and struct?
A. 1, 2, 4
B. 3, 5
C. 2, 4
D. 3, 4, 5
Answer: Option A
Explanation:
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
Explanation:
18. Which of the following statements are correct about Structures used in C#.NET?
A. 1, 2, 4
B. 2, 3, 5
C. 2, 4
D. 1, 3
Answer: Option B
Explanation:
Prev 1234
Errors
It defines a class that inherits all the methods of A but the private members cannot be accessed.
b and c
ANSWER: It defines a class that inherits all the methods of A but the private members cannot be
accessed.
False
ANSWER: True
controls
object
class
graphics
ANSWER: controls
It is allocated at runtime
all of these
Session.Close()
Session.Discard()
Session.kill()
Session.Abandon()
ANSWER: Session.Abandon()
None of these
All of above
No
Yes
ANSWER: Yes
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
3. What is MSIL?
4. An assembly is
properties of c#
events Of c#
ANSWER: A collection of files that appear to the programmer to be a single DLL or EXE.
By memory.
By value.
By reference.
By address.
ANSWER: By value.
7. What is boxing?
Encapsulating an object in a value type.
8. Which property will you use to process different server paths in a page?
Request
Response
Server
Application
ANSWER: Server
1. Which file contains configuration data for each unique URl resource used in project?
global.asax
assemblyinfo.cs
web.config
webapplication.vsdisco
ANSWER: web.config
datareader
dataset
datatabel
all
ANSWER: datatabel
Getvalue
GetNumber
None
ANSWER: None
Session object
Application Object
Server Object
Response 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);
ANSWER: Textbox.databinding.add(Text,dv,EmpNo);
6. The uniqueId that gets generated at the start of the Session is stored in
Server machine
HasErrorConflict
HasError
HasCollision
HasDataError
ANSWER: HasErrorConflict
1. You need to encrypt the SOAP header. What is the correct method to use?
Inherit the web service class from the SoapHeaderEncrypt class
Enable SSL for the XML web service and configure it to encrypt the headers
It cannot be instantiated
It can be instantiated.
DataAdapter
Command object
Connection object
DataReader object
True
False
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
ANSWER: Localization
6. Which of the following automatically detects if windows installer is installed on the target machine?
Assembly
Native image
Bootstrapper application
Globalization
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
1. Inheriting from a base class and providing a new method for one of the base class methods
Overriding
Overloading
Shadowing
Abstracting
ANSWER: Overriding
2. It contains all the information needed to describe the assembly to the common language runtime.
Bootstrapper
Assembly manifest
GAC
Strong Name
Convert.ToInt32 can't handle Null Values ,it will throws ArgumentNullException error
ANSWER: Int.Parse can't handle Null values , It will throw ArgumentNullException Error
Sealed
Abstract
Both
None
ANSWER: Sealed
Yes
StringBuilder is more efficient in cases where there is a large amount of string manipulation
ANSWER: StringBuilder is more efficient in cases where there is a large amount of string manipulation
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.
.Net assemblies
ActiveX control
10. Type of code security that protects system resources from unauthorized calls
Role-based security
Code-based security
Statement 3: The method that will be invoked by a delegate is determined at compile time.
ANSWER: C
B) name_of_delegate(parameter-list);
C) delegate name_of_delegate;
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.
Statement 1: delegate can be used to call only those methods that signature and return type are same
as delegate.
string DemoFunction(string s)
-------
-------
Choose the correct code for delegate declaration to call above function.
Ans. A
ANSWER: A
Explanation:
delegate can call only those methods whose signature and return type are same as 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.
ANSWER: D
Explanation: The given below example shows how multicast delegate can be used.
using System;
class DelegateTest
Console.WriteLine("Function 1 is called");
Console.WriteLine("Function 2 is called");
class Program
// Set up multicast.
delObj += obj.function2;
delObj();
delObj -= obj.function2;
delObj();
Output:
Function 1 is called
Function 2 is called
Function 1 is called
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.
ANSWER: D
A) event event-name;
ANSWER: B
Q.8 Choose the correct option according to the given statements about events and delegates.
A) events can be multicast.
ANSWER: D
Q.9 According to above given code, how will you call function1 by using delegate?
class DelegateTest
Console.WriteLine("Function 1 called");
}
A) DelegateTest obj = new DelegateTest();
delObj();
delObj();
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.
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:
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.
class Program
int num = 1;
num = num * i;
return num;
};
}
Q.1 Trace the output of given below code.
obj.Add("A");
Console.WriteLine("Capacity = "+obj.Capacity);
A) Capacity=1
B) Capacity=2
C) Capacity=3
D) Capacity=4
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.
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:
obj.Add("A");
obj.Add(1);
obj.Add(DateTime.Today.Date);
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
ANSWER: B
Example:
list.AddRange(days);
}
Q.4 Trace the output of given below code.
obj.Add("A");
obj.Add("B");
obj.AddRange(arr);
Console.Write(list+" ");
A) A B 1 2 3 4 5
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
ANSWER: B
ht["EmpId"] = "1";
ht["EmpName"] = "XYZ";
Console.WriteLine(ob);
}
A) EmpId=1
EmpName=XYZ
C) 1, XYZ
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.
Console.WriteLine(ob.Key+" : "+ob.Value);
}
Q.7 What does the Dequeue method of the Queue class do?
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
ANSWER: C
ht["EmpId"] = "1";
ht["EmpId"] = "Pune";
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
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.
A) System.Collections
B) System.Collections.Specialized
C) System
Q.11 Which class is efficient for small collections of items(Less than 10 items)?
A) SmallList
B) HashTable
C) ListDictionary
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
Ans. B
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
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
ANSWER: D
Q.15 Which collection is same as ArryList but can store only string type value?
A) StringDictionary.
B) StringCollection
C) StringArray.
A) Strings
B) Objects
C) Arrays of strings
ANSWER: A
ANSWER: E
Q.18 Read the given below code. What you will write at the place of question marks in line
obj[1] = "CareerRide.com";
obj[2] = "XYZ.com";
obj[3] = "PQR.com";
int id = item.Key;
A. Value
B. KeyValuePair
C. Key
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.
ANSWER: A
A)
B)
C)
ANSWER: A
Example:
using System.IO;
using System.Runtime.Serialization.Formatters.Binary;
class Program
obj.Serialize(fs, data);
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
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
ANSWER: C
A) Binary Serialization
B) SOAP Serialization
C) XML Serialization
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 4: XML serialization does not provides the interoperability to communicate with different
platforms.
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
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
Explanation:
If you want that particular field should not be serialized then use NonSerialized attribute.
[Serializable]
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
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?
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.
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.
B)
- Create an XmlSerializer object by passing it the type of object you plan to serialize.
ANSWER: B
Explanation:
using System;
using System.IO;
using System.Xml.Serialization;
class Program
fs.Close();
[XmlRoot ("CartItem")]
public ShoppingCart()
{
}
A)
<CartItem productId="100">
<price>100.25</price>
<quantity>20</quantity>
</CartItem>
B)
<price>100.25</price>
<quantity>20</quantity>
C)
< productId="100">
<price>100.25</price>
<quantity>20</quantity>
</CartItem>
ANSWER: A
A) Value type
B) Reference type
C) Derived type
ANSWER: A
Q.2 Which of the following are value types?
A. Decimal
B. Integer
C. System.Drawing.Point
ANSWER: D
A) int i = null;
B) Nullable(int) i = null;
C) Nullable<int> i = null;
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 .
B) enum Days : byte {Sat=1, Sun, Mon, Tue, Wed, Thu, Fri};
ANSWER: B
A) Heap
B) Stack
C) Secondry Storage
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
obj1.x = 10;
obj2.x = 20;
}
Q.6 Trace the output of given below code.
using System;
struct Numbers
public Numbers(int n)
val = n;
class MyProgram
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
ANSWER: A
using System;
class Numbers
public Numbers(int n)
val = n;
}
class MyProgram
Numbers n2 = n1;
n1.val += 1;
n2.val += 2;
A) n1 = 3, n2 = 3
B) n1 = 3, n2 = 3
C) n1 = 3, n2 = 3
D) n1 = 3, n2 = 3
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
ANSWER: D
Q.9 According to given below statements, choose the correct option regarding boxing and unboxing.
ANSWER: A
Explanation:
int i = 12;
object o = (object) i;
object o = 12;
int i = (int) o;
Q.10 According to given below statements, choose the correct option regarding boxing and unboxing.
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"
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.
sb.Append("Hello");
sb.Append(" how");
sb.Append(" are");
sb.Append(" you");
Console.WriteLine(s);
Q.11 Which of the following statements are correct about an enum used in C#.NET?
ANSWER: B
Q.12 Trace the correct output for the following given below C#.NET code snippet
using System;
sun = -5,
mon,
tue
class MyProgram
Console.WriteLine();
B) -5, -4, -3
D) -5, -6, -7
Q.13 C#.Net Primitive Type float mapped with which FCL type?
A) System.Triple
B) System.Double
C) System.Single
ANSWER: C
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.
C) only class
ANSWER: A
Explnation:
Within a namespace, you can declare one or more of the following types:
using System;
namespace DemoNamespace
class DemoClass { }
interface DemoInterface { }
struct DemoStruct { }
enum DemoeEnum { a, b }
namespace SampleNamespace.Nested
class SampleClass
Console.WriteLine("Welcome at careerRide.com");
}
Q.1 Trace the output of given below code.
using System;
interface IDemo
int x = 10;
class Program
Console.WriteLine("Welcome at careerRide");
A) Welcome at careerRide
ANSWER: B
Explanation:
If you run the above code you will get the compile time error as follows.
Q. 2
using System;
interface IDemo
void myFunction();
class Program:IDemo
myFunction();
void myFunction()
{
Console.WriteLine("Welcome at careerRide.com");
B) Welcome at careerRide.com.
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
p.myFunction();
Console.WriteLine("Welcome at careerRide.com");
B) Only methods
ANSWER: A
Q.4 Which of the following statements is correct about an interface used in C#.NET?
ANSWER: C
Q.5 According to the given statement, choose the correct option about an interface used in C#.NET.
ANSWER: B
Q.6 Which of the following is the correct implementation of the interface given below used in C#.NET?
interface IDemo
// some code
}
}
// some code
// some code
ANSWER: C
Q.7 Which of the following statements is correct?
ANSWER: B
Q.8 Choose the correct option about the C#.NET code snippet given below?
interface IMyInterface
void function1();
void function2();
{
void function1()
// Some code
B) Console.WriteLine("Welcome at CareerRide.com");
C) It will give compile tile error as: 'MyClass' does not implement interface member
IMyInterface.function2().
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;
String str;
String str;
String str;
ANSWER: A
Q.10 Which of the following statements is correct about the C#.NET code snippet given below?
interface IMYInterface
//---------
//---------
class BaseClass
//---------
//---------
B) It gives the compile time error as: Base class 'MyClass' must come before any interfaces.
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();
void run()
void run()
{
Console.WriteLine("My car is running");
void run()
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();
bike.run();
car.run();
IBike.run();
ICar.run();
ANSWER: B
Threading in .NET - placement questions
ANSWER: B
ANSWER: A
A) Statement 1 is correct.
ANSWER: C
Q.4 What are the two types of thread that .NET Framework supports?
ANSWER: A
A) Thread.Suspend
B) Thread.Resume
C) Thread.Abort
D) Thread.Join
View Answer / Hide Answer
ANSWER: C
A) Normal.
B) Background.
C) Foreground.
ANSWER: C
A) Statement 1 is correct.
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
ANSWER: B
Q.9 Thread class is available in which namespace?
A) System.Thread
B) System.Threading
C) System.ThreadStart
ANSWER: B
A) Normal
B) AboveNormal
C) Highest
D) Lowest
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
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.
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.
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
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
ANSWER: C
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?
C) The compiler throws an error if resources are not disposed in the Finally block.
ANSWER: B
Q.2 All exception classes are derived from which built-in class?
A) Exception
B) Finally
C) SystemException.
ANSWER: A
B) It occurs at run-time.
ANSWER: B
Q.4 Trace the output of given below code.
using System;
class MyProgram
try
a[6] = val;
catch (IndexOutOfRangeException e)
Console.WriteLine("Welcome at careerRide.");
}
A) Index out of bounds.
B) Welcome at careerRide.
Welcome at careerRide.
ANSWER: C
Statement 1: A try block must be associated with at least one catch or finally block.
ANSWER: A
Q.6 Which of the following statements are correct about exception handling in C#.NET?
B) finally clause will always executed, No matter whether an exception occurs or not.
ANSWER: D
Statement 2: All types of exceptions can be caught using the Exception class.
Statement 3: User-defined exceptions cannot be created.
ANSWER: A
Q.8 if your program does not catch an exception, then exception is catches by
A) CTS
B) CLR
C) CLS
ANSWER: B
Q.9 Trace the output of given below code.
using System;
class Program
try
Console.WriteLine("Welcome at careerRide");
catch (Exception e)
Console.WriteLine("Exception catched");
catch (DivideByZeroException e)
finally
{
Console.WriteLine("finally block executed");
B) Welcome at careerRide
C) Exception catched
ANSWER: A
using System;
class MyProgram
{
try
Console.WriteLine("Welcome to careerRide");
A) Welcome to careerRide
ANSWER: B
Q.1 Select the correct query that will give only positive numbers. You can refer the given below array.
where n > 0
select n;
where n is positive
select n;
select n;
ANSWER: A
Q.2 Select the correct query that will give only positive numbers less than 10.
select n;
where n > 0
where n < 10
select n;
select n;
ANSWER: B
Q.3 An integer array is given as follows
orderby n
sortedby n
select n;
orderby n
select n;
ANSWER: C
Q.4 Which namespace is necessary to use LINQ?
A) System.Data
B) System.Linq
C) System.Object
ANSWER: B
A) LINQ to Objects
B) LINQ to ADO.NET
C) LINQ to XML
IEnumerable<int> query = numbers.Where(num => num > 5 && num < 10);
Console.Write(n+" ");
A) 6 7 8 9
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.
ANSWER: C
using System;
class Program
Console.WriteLine(z1);
Console.WriteLine(z2);
Console.WriteLine(z3);
A) 50 15 5
B) 10 5
Statement 1: An extension method is defined as static method but it is called like as an instance method.
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.
ANSWER: A
Q.10 Trace the output of given below code.
Console.WriteLine(data.Sum());
Console.WriteLine(data.Average());
Console.WriteLine(data.Max());
A) 50 30 150
B) 150 30 50
C) 150 50 30
ANSWER: B
Console.WriteLine(data.ElementAt(1));
A) 10
B) 20
C) 30
D) 40
ANSWER: B
A) 10 100
B) Single.
C) 10 0
Q.13 What is the extension of the file, when LINQ to SQL is used?
A) .dbml
B) msdb
C) accdb
ANSWER: A
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
ANSWER: A
int[] num1 = { 1, 2, 3, 4, 5 };
int[] num2 = { 5, 6, 7, 8, 9, 10 };
Console.Write("Union= ");
foreach(var U in union)
Console.Write("{0} ",U);
Console.Write("Intersection= ");
Console.Write("except= ");
ANSWER: 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
Answer: Option D
Answer: Option B
Answer: Option A
Answer: Option C
Answer: Option A
Answer: Option C
9. Which of the following statements are correct about an interface used in C#.NET?
A.1, 2
B. 1, 4, 5
C. 3, 4
D.3 only
Answer: Option B
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
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
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
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
Answer: Option D
17. Which of the following statements are correct about a delegate?
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
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
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
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.
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
1. Stack
2. Queue
3. BitArray
4. ArrayList
5. HashTable
Answer: Option B
27. Which of the following statements are correct about the Stack collection?
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
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.
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
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
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
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?
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
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?
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.
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
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
1. Method
2. Class
3. Assembly
4. Namespace
5. Enum
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?
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
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
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
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?
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
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
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
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?
Answer: Option D
73. Which of the following statements are correct about an enum used inC#.NET?
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
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?
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?
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.
Answer: Option E
82. Which of the following statements are correct about the String Class in C#.NET?
A. 1, 2, 5
B. 2, 4
C. 1, 3, 4
D. 3, 5
Answer: Option C
A. 1, 3
B. 3, 5
C. 2, 4
D. 1, 2, 4
Answer: Option C
Answer: Option D
85. Which of the following statements are correct about arrays used in C#.NET?
A. 1, 2
B. 1, 3, 5
C. 3, 4
D. 1, 2, 5
E. 4, 5
Answer: Option D
Answer: Option A
Answer: Option B
A. 1, 2
B. 3, 4
C. 1, 2, 4
D. 3, 5
Answer: Option A
Answer: Option A
Answer: Option C
Answer: Option B
92. Which of the following are true about classes and struct?
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?
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?
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?
A. 1, 5
B. 3, 4
C. 1, 2
D. 4, 5
Answer: Option B
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?
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
Answer: Option A
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
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?
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?
A.1, 2, 3
B. 2, 4, 5
C. 1, 3, 5
D.1, 2
Answer: Option A
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
Answer: Option B
Answer: Option A
Answer: Option C
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
Answer: Option D
Answer: Option C
Answer: Option D
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?
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
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
A.1, 2
B. 2, 3
C. 3, 5
D.4, 5
E. None of these
Answer: Option A
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
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
A.1, 2
B. 2, 3
C. 3, 5
D.4, 5
E. None of these
Answer: Option A
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
Answer: Option A
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
Answer: Option C
136. Which of the following statements are correct about the Bitwise & operator used in C#.NET?
A.1, 2, 4
B. 2, 3, 5
C. 3, 4
D.3, 4, 5
E. None of these
Answer: Option D
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
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
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?
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?
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?
A.1, 2, 5
B. 2, 3, 5
C. 2, 3
D.4, 5
E. None of these
Answer: Option A
Answer: Option A
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?
A.1, 2, 3
B. 2, 3, 5
C. 3, 5
D.3, 4
E. None of these
Answer: Option B
Answer: Option A
1. Stack
2. Tree
3. SortedDictionary
4. SortedArray
Answer: Option C
153. Which of the following statements are valid about generics in .NET Framework?
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
Answer: Option C
B. No
A. 1, 2, 3, 4
B. 1, 2
C. 1, 2, 4, 5
D. 3, 6
E. 1, 2, 3
A. 1, 5
B. 2, 5
C. 3, 4, 5
D. 1, 2, 3, 4
E. 5
C. False
D. 0
string in C# is a Reference
Type.
A. True
B. False
Enumeration (enum) in c# is a
reference type.
A. True
B. False
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>
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.
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
a) System.Int16 = short.
b) System.UInt32 = UInt.
c) System.UInt64 = ULong.
d) System.UInt16 = UShort.
d) int a = b = 42;
View Answer
Answer: c
int n = 10;
Console.WriteLine(m * k);
Console.ReadLine();
c) Expression (m * k) is invalid
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.
5. Arrange following datatype in order of increasing magnitude sbyte, short, long, int.
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.
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
View Answer
Answer: a
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
Output : 74.
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.
a) Long Int
b) Unsigned Long
c) Int
d) Unsigned Int
View Answer
Answer : c
Explanation:By definition.
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.
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
a) Upto 6 digit
b) Upto 8 digit
c) Upto 9 digit
d) Upto 7 digit
View Answer
Answer: d
Explanation : By definition.
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
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.
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();
float b = 12.80f;
float c;
c = a + b;
Console.WriteLine(c);
Console.ReadLine();
View Answer
Answer: c
6. Minimum and Maximum range of values supported by float data type are ?
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;
View Answer
Answer: b
Explanation : 16777216 is exactly 224, and would be represented as 32-bit float like so:
mantissa = . 0
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
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
a) ABCD
b) DCBA
c) 0 * ABCD
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
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
a) 0
b) True
c) False
d) 1
e) -1
View Answer
Answer: c
Explanation : By Definition.
double ZERO = 0;
Console.ReadLine();
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
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
View Answer
Answer: c
a) 8 bit
b) 12 bit
c) 16 bit
d) 20 bit
View Answer
Answer: c
Explanation: None.
char c = 'g';
string s = c.ToString();
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
3. Given is code of days(example:MTWTFSS) which i need to split and hence create a list of days of
week in strings
ocuring in that set of code related to conversion of char to strings.Hence,Select a code to solve the given
error.
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;
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
{"U", "Sunday"}
};
if (list.ContainsKey(tmp))
{
daysArray.Add(list[tmp]);
b) Monday
Tuesday
Wednesday
Friday
Sunday
c) Monday
Tuesday
Wednesday
Friday
Saturday
View Answer
Answer: c.
Explanation:None.
Output: Monday
Tuesday
Wednesday
Friday
Saturday
2. char is n bytes whereas varchar is actual length in bytes of data entered in terms of storage size
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.
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 ?
string s1 = "Delhi";
string s2;
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
int Length;
Str = Console.ReadLine();
Length = Str.Length - 1;
Length --;
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.
Console.WriteLine(hex);
a)
sBytes.AppendFormat("{0:x2}", b);
return sbBytes.Tostring();
b)
static string ConvertstringToHex(string input, system.Text.Encoding encoding)
sBytes.AppendFormat("{0:X2}", b);
return sbBytes.Tostring();
c)
sbBytes.AppendFormat("{0:X2}", b);
Console.WriteLine(sbBytes.ToString());//sbBytes.ToString());
return sbBytes.ToString();
}
}
View Answer
Answer : c.
Explanation: None.
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 ?
Console.WriteLine(normal);
Console.ReadLine();
a)
return encoding.GetString(bytes);
b)
return encoding.GetString(bytes);
}
c)
return encoding.GetString(bytes);
View Answer
Answer : b
Output:
return encoding.GetString(bytes);
string s2;
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
Output: BEST.
Answer : c
Explanation: None.
a) Convenience and better readability of strings when string text consist of backlash characters
c) To embedd a quotation mark by using double quotation marks inside a verbatim string
View Answer
Answer : d
Explanation : By definition.
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
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
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.
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
2. int i;
int j = 0;
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.
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.
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
Output: 65,97
a) Dr.Gupta
b) Good Morning
View Answer
Answer: c.
int a = 5;
int b = 10;
int c;
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.
const int a = 5;
const int b = 6;
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
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
class ABC
static int m;
int n;
int j = 10;
Scope declaration:
array element
= array element
array element
View Answer
Answer: b
class Program
int 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
Output:0, 1, 2, 3, 4
class Program
int 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
class Program
int 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
int i ;
int j = 0;
j += i;
Console. WriteLine(j);
Console. ReadLine();
a) 0, 1, 6, 18, 40
b) 0, 1, 5, 20, 30
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.
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
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.
int i = 100;
int i = 200;
Console. ReadLine();
a) 5, 10, 15, 20
b) 0, 5, 10, 20
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,
b) <datatype><var_name>;
c) <var_name><data type>;
d) <var_name> = <value>;
View Answer
Answer: a
Explanation: By definition.
class Program
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
Output:15, 5
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
View Answer
Answer: a
Explanation:By definition
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
a) 1, 3
b) 2, 3
c) 1, 2, 3
d) 1
View Answer
Answer: b
Explanation:By definition.
int i = 123;
object o = i;
i = 456;
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
Output:456, 123
int i = 546;
object o = i;
int n =(int) o;
o = 70;
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
a) To store a value of one data type into a variable of another data type
c) To prevent situations of run time error during change or conversion of data type
View Answer
Answer: c
Explanation : By Definition.
b) Explicit Conversion
View Answer
Answer: b
Explanation : By Definition.
View Answer
Answer: b
Explanation : None.
4. For given set of code select relevant solution for conversion of data type.
long total;
Console.ReadLine();
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
View Answer
Answer: c
Explanation: By definition.
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
c) Potentially Unsafe
View Answer
Answer: b, c
Explanation:By definition.
int a = 76;
char b;
b = (char)a;
Console.WriteLine(b);
Console.ReadLine();
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.
float sum;
int i;
sum = 0.0F;
}
Console.WriteLine("sum =" +sum);
Console.ReadLine();
a) 2.000
b) 2.910
c) 2.928
d) 3.000
View Answer
Answer: c
Explanation:None.
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
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 :
int a = 22;
long b = 44;
double c = 1.406;
b = a;
c = a;
a = (int)b;
b = (long)c;
}
float a = 16.4f;
int b = 12;
float c;
c = a * ( b + a) / (a - b) ;
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
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 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 6 : x = 91 1( 85 + 6 is evaluated )
Output : 90.
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)
Second pass:
Step 3: 80 2*82
Step 4: 80 164.
Third pass:
Output : -84 .
View Answer
Answer: c
Explanation : By definition.
int i, j = 1, k;
for (i = 0; i < 3; i++)
k = j++ - ++j;
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 = -2.
i = 1 , j = 3.
k = -2.
i = 2 , j = 5.
k = -2.
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.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.
Output : My name.
int n = 5;
int x = 4;
int z, 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
int n = 5;
int x = 4;
int z, c, k;
z = 3 * x * x + 2 * x + 4 / x + 8;
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
Step 1: c = 1,n = 5
Row 1: A
Step 2: c = 2, n = 5
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
{
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)
else if (a > b)
Console.ReadLine();
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
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.
int a = 4;
int b = 5;
int c = 6;
int d = 8;
Console.WriteLine((a * b / c) + d);
else
Console.WriteLine((b * c + d )/ a);
a) Line 1 a is greater to b
11
View Answer
Answer: a.
Explanation :Now, here in if condition both conditions of parenthesis and hence evaluating operators
based on parenthesis are tested.
Result : 11
for expression : (b * c + d )/ a
Result : 9
The relational operator >= between both expressions checks for largest figure and hence
consecutively executes if condition.
11
2. Check for given code whether the given relation operator works according to the if condition or not.
int a = 10;
int b = 5;
int c = 12;
int e = 8;
int d;
Console.WriteLine(d);
if (d == 1)
Console.WriteLine((a * (c - b) / e + (b + c)));
else
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.
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
Output :0.
C# is not great!.
20.
a) >=
b) !=
c) Not
d) <=
e) <>=
View Answer
Answer: c, e.
Explanation:By definition.
int n = 2;
int p = 4;
int q = 5;
int w = 3;
Console.WriteLine("b");
else
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
--n = 2 - 1 =1.
a.
Output : 8 1
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.
Output : y = 5, m = 6; y =7 , m = 7.
int a = 3, b = 5, c = 1;
int z = ++b;
int y = ++c;
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
So, 1 || 1 = 1. So, b = 1.
Output : 2, 2, 2
int a = 4, b = 5, c = 7, u = 9;
int h;
Console.WriteLine(h);
Console.WriteLine(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').
Output : 11
False.
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
Output : 0 1.
class method1
class Program
int a = 23, b = 0, c;
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.
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,
Output:-1 21 1
int a = 8, b = 6, c = 10;
Console.WriteLine("figure is hypotenuse");
}
else
Console.WriteLine("figure is square");
a) Figure is square
b) Figure is hypotenuse
c) False
View Answer
Answer : a.
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.
varA = 10;
varB = 10;
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.
When using OR operation it gives FALSE only when both the values are FALSE. In all other cases OR
operation gives true.
varA = 10;
varB = 10;
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.
byte b1 = 0 * AB;
byte b2 = 0 * 99;
byte temp;
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.
a) &, |
b) ^, ~
c) <<, >>
d) +=, -=
View Answer
Answer: d
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 :
int res;
/*_______________*/
Console.WriteLine(res);
b) x % y == 0 ? y += 10:(x += 10);
View Answer
Answer: b
Output : {
int res;
x % y == 0 ? y += 10:(x += 10);
Console.WriteLine(res);
int y = 5;
int x;
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.
a) :?
b) ?;
c) ?:
d) ??
View Answer
Answer: c.
Explanation:By definition.
int a = 4;
int c = 2;
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
evaluated as true.
Output: True
True
View Answer
Answer: c.
Explanation:By definition.
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
Output: In else
In main
int i;
int b = 8, a = 32;
if ((a / b * 2)== 2)
continue;
else if (i != 4)
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
Output:0 1 2 3
Console.WriteLine("Enter a letter:");
char c = (char)Console.Read();
if (Char.IsDigit(c) == true)
Console.WriteLine("A number");
Console.ReadLine();
1. Enter a letter :
2. Enter a letter :
A
3. Enter a letter :
A number
4. Enter a letter :
a) a ,b ,c
b) b ,c ,d
c) a ,d ,b
d) b ,c
View Answer
Answer: d
Enter a letter :
A number
int i, 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
i = 2 : j = 2 == 1 as (i == j).
i = 1 : j = 1 == 1 (as i==j)
i = 0 : j = 2 == 0 .
So, 0 0 1
010
100
Output: 0 0 1
010
100
/*___________________________*/
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
if (num[i] % 2 == 0)
even += 1;
else
odd += 1;
Console.ReadLine();
Console.WriteLine("cquestionbank");
else
{
break;
a) cquestionbank
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.
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
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
int a = -1;
int b = -1;
Console.WriteLine("a");
else
Console.WriteLine("b");
Console.ReadLine();
a) a
b) b
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.
int a = -1;
int b = -1;
if (Convert.ToBoolean(++a == ++b))
Console.WriteLine(a);
else
Console.WriteLine(b);
Console.ReadLine();
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 ;
c) java
View Answer
Answer: c
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.
int a = 5, b = 10;
if (Convert.ToBoolean(Convert.ToInt32(++a)) || Convert.ToBoolean(Convert.ToInt32(++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
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.
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.
int i = 2, j = 4;
switch (i + j * 2)
case 1 :
case 2 :
break;
case 3 to 10:
Console.WriteLine("3 to 10");
break;
Console.ReadLine();
a) 3 to 10 will be printed
View Answer
Answer: c
Explanation: Syntax error switch case do not work with syntax as 3 to 10:
Output :
int i = 2,j = 4;
switch (i + j * 2)
case 1 :
case 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.
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.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
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
int i = 2, j = 3, k = 4;
switch (i + j - k)
++i;
k += j;
break;
--i;
k -= j;
break;
default:
i += j;
break;
a) 1 3 1
b) 2 3 4
c) 5 3 4
View Answer
Answer: a
Explanation:Solving expression (i + j k) gives 1 and hence,solving for case 1:case 3:case 5:.
Output : 1
int i = 9 , j = 7;
switch (i - j + 3)
case 9: 7:
j += 6;
break;
case 5:
i -= 4;
break;
Console.ReadLine();
a) 5 7
b) 9 13
d) 9 7
View Answer
Answer: c
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
View Answer
Answer: d
5.0f = (int)5.0f.
5.0L =(int)5.0L.
int i;
int j = 1;
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
d) 12
View Answer
Answer: c
Output :
int i;
int j = 1;
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();
}
switch (ch)
case 'A':
case 'a':
break;
case 'B':
case 'b':
break;
case 'C':
case 'c':
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.
char ch = 'p';
switch (ch)
case 'p':
break;
default:
Console.WriteLine("default");
break;
Console.WriteLine("main");
}
a) coco main
b) coco 112
View Answer
Answer: c
int i;
for (i = 0; ; )
Console.WriteLine("hello");
Console.ReadLine();
a) No output
b) hello
View Answer
Answer: c
Explanation: Testing condition for the loop is absent.So,loop will continue executing.
Output : hello
hello
hello
float f;
Console.WriteLine( ++f );
Console.ReadLine();
a) 1.1
b) 0.1
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
int I, X;
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
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:
int I, J = 0;
J = J + I;
I += 2;
Console.ReadLine();
a) 1 2 3 4 5 6 7 8 9
b) 25
c) 1
View Answer
Answer: d.
Output : 25.
int i = 5;
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
int i, s = 0;
Console.WriteLine(s);
Console.ReadLine();
}
a) Code report error
View Answer
Answer: d
Output: 55.
a) Only 1 is correct
b) Only 2 is correct
View Answer
Answer: b
Explanation:By defination.
int i;
Console.WriteLine("Hi");
for (i = 1; i <= 10; i++)
Program.Main(args);
Console.ReadLine();
View Answer
Answer: c
Output: Hi
Hi
*****
****
***
**
int i,j;
console.WriteLine("*");
console.WriteLine("\n");
console.WriteLine("*");
console.WriteLine("\n");
console.WriteLine("*");
console.WriteLine("\n");
}
d) for ( i = 0;i <= 4; i++)
console.WriteLine("*");
console.WriteLine("\n");
View Answer
Answer: c
int 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.
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 :
int 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;
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
Output:j = 0.
13. Select the output for following set of code :
int i = -10;
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
int i, j;
j = 1;
while (i % j == 2)
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.
{
float s = 0.1f;
++s;
Console.WriteLine(s);
Console.ReadLine();
a) 0.1
b) 1.1
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
int i;
i = 0;
while (i++ < 5)
Console.WriteLine(i);
Console.WriteLine("\n");
i = 0;
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
int x = 0;
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.
int x;
x = Convert.ToInt32(Console.ReadLine());
int c = 1;
while (c <= x)
if (c % 2 == 0)
c++;
Console.ReadLine();
}
for x = 8.
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.
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
Output: 2345.
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:
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 :
int i = 0;
if (i % 10 == 0)
continue;
else
break;
i += 10;
Console.WriteLine(i % 10);
View Answer
Answer :c
Explanation:None.
int i = 1, j = 1;
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.
int i = 1;
while (i <= 1)
{
Console.WriteLine("Hello...");
else
Console.WriteLine("Hi...");
i++;
Console.ReadLine();
a) Hi
b) Hello.
c) Hiinfinite times
View Answer
Answer :b
Output:Hello.
int i = 0;
while (i++ != 0) ;
Console.WriteLine(i);
Console.ReadLine();
a) -127 to +127
b) 0 to 127
c) 1
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
Output: 1.
int i = 1, j = 2, k = 3;
do
{
Console.WriteLine((Convert.ToBoolean(Convert.ToInt32(i++))) &&
(Convert.ToBoolean(Convert.ToInt32(++j))));
Console.ReadLine();
a) 0 0 0
c) 1 1 1
View Answer
Answer :b
Explanation : 1 AND 1 = True.Similarly , non zero number || non zero number = True.
do
Console.WriteLine(i++ - ++j);
Console.ReadLine();
}
a) 0.05
b) -0.05
c) 0.95
d) -0.04999995
View Answer
Answer :d.
Explanation : None.
Output : -0.04999995
int i = 1, j = 5;
do
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
Output: 5 25.
int i = 1234 ,j = 0;
Console.WriteLine(j);
a) do
j = j + (i % 10);
b) do
j = j + (i % 10);
c) do
j = j + (i % 10);
}while ((i % 10)!= 0);
d) do
j = j + (i % 10);
View Answer
Answer :a.
int i = 1234,j = 0;
do
j = j +( i % 10);
Console.WriteLine(j);
long x;
x = Convert.ToInt32(Console.ReadLine());
do
{
Console.WriteLine(x % 10);
Console.ReadLine();
enter x = 1234.
b) prints 1
c) prints reverse of x
View Answer
Answer :c
Output: 4321.
int i, s = 0, a = 1, d;
i = Convert.ToInt32(Console.ReadLine());
do
d = i % (2 * 4);
s = s + d * a;
Console.ReadLine();
enter i = 342.
d) It finds reverse of i
View Answer
Answer :b.
Explanation : None.
Output : i = 342.
s = 526.
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);
int x = 10;
do
Console.WriteLine( x++);
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.
int 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
View Answer
Answer :c
Explanation : the execution of for loop is done for consecutive six times.
Output : 1 1 1 1 1 1
int x = 0;
do
x++;
if (x == 5)
{
x++;
continue;
break;
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 .
int x;
int j = 1;
do
j++;
}while (x % j == 2);
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.
int i;
if (i < 7)
i++;
continue;
Console.ReadLine();
a) 12
b) 11
d) 13.
View Answer
Answer :c
Explanation : Continue loop cannot be used within if loop .replace while with if(i <7).
int 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
View Answer
Answer :c
Explanation: Undefined label even in main().The syntax goto even: is incorrect instead use goto
even;.
Output:
int i;
if (i % 2 == 0)
goto even;
else
Console.WriteLine(number is odd:);
Console.ReadLine();
even:
Console.WriteLine(number is even:);
Console.ReadLine();
int i = 1, j;
do
for (j = 1; ; j++)
if (j > 2)
break;
if (i == j)
continue;
Console.WriteLine(i + " " + j);
i++;
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 :
int i = 10 , j = 0;
label:
i--;
if ( i > 0)
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 :
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 :
int i = 0;
if (i == 0)
goto label;
label: Console.WriteLine("HI...");
Console.ReadLine();
a) Hiinfinite times
c) Hi Hi
d) Hi
View Answer
Answer :d
Output : Hi
{
int i = 0, j = 0;
i++;
while (j < 3)
Console.WriteLine("loop\n");
goto l1;
Console.ReadLine();
b) loop
c) loop loop
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.
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.
int i = 0;
int j = 0;
{
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
View Answer
Answer:c.
Explanation : None.
Output : hi
hi
hi
hi
hi
hi.
int a = 0;
int i = 0;
int b;
a++;
Console.WriteLine("Hello \n");
continue;
Console.ReadLine();
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
Console.WriteLine("HI");
continue;
Console.WriteLine("Hello");
Console.ReadLine();
a) Hi Hello
b) Hi
c) Hello
View Answer
Answer :d
Explanation: Absence of any loop condition in order to make decision of break or continue.
class sample
public int i;
public int[] arr = new int[10];
arr[i] = val;
class Program
s.i = 10;
sample.fun(1, 5);
s.fun(1, 5);
Console.ReadLine();
View Answer
Answer: a
s.i = 10;
sample.fun(1, 5);
sample.fun(1, 5);
Console.ReadLine();
a) :
b) ::
c) #
View Answer
Answer: b
Explanation: By definition.
a) :
b) ::
c) .
d) #
View Answer
Answer: c
a) type
b) scope
d) None of mentioned
View Answer
Answer: c
class class_name
member variables
variable1;
variable2;
variableN;
method1(parameter_list)
method body
method2(parameter_list)
method body
methodN(parameter_list)
method body
}
}
class sample
public int i;
public int j;
this.i = i;
this.j = j;
class Program
s.i = 1;
s.j = 2;
s.fun(s.i, s.j);
Console.ReadLine();
}
a) Error while calling s.fun() due to inaccessible level
c) 1 2
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.
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
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.
class z
public int X;
public int Y;
X = a;
Y = b;
class Program
z s = new z();
s.set(10, 20);
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.
b) n = name();
c) name n = name();
d) n = new name();
View Answer
Answer: a
Explanation:None.
a) protected,public
b) private,public
c) private
d) public
View Answer
Answer: c
Explanation:None.
class z
class Program
z n = new z();
n.name1 = "harsh";
n.show();
Console.ReadLine();
a) Syntax error
View Answer
Answer: c
Explanation: Member function show() accessed using object of class z which is n as object.member().
View Answer
Answer: c
Explanation:None.
class test
Console.WriteLine("Csharp:");
class Program
test t;
t.print();
Console.ReadLine();
View Answer
Answer: c
t.print();
Console.ReadLine();
a) &
b) ref
c) #
d) $
View Answer
Answer :b.
Explanation : None.
2. Select output for following set of code :
int a = 5;
Console.WriteLine(a);
Console.ReadLine();
a = a * a;
a) 5
b) 0
c) 20
d) 25
View Answer
Answer :d.
Output: 25.
fun1(ref arr);
Console.ReadLine();
array[i] = array[i] + 5;
a) 6 7 8 9 10
b) 15 17 8 8 20
c) 15 17 8 29 20
View Answer
Answer :a
a[0] = 1 + 5 = 6.
a[1] = 2 + 5 = 7.
.
a[4] = 5 + 5 = 10.
Output : 15 17 8 29 20.
int a = 10 , b = 20;
Console.ReadLine();
int t;
t = i;
i = j;
j = t;
View Answer
Answer :b
func(ref a);
Console.ReadLine();
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
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.
Output : 3 5 7 9 11.
c) When ref are used any changes made to parameters in method will be refelected in variable when
control passed back to calling method
View Answer
Answer: b ,c
Explanation: None.
View Answer
Answer :b.
Explanation : None.
int X = 0;
if (Convert.ToBoolean(X = 0))
Console.WriteLine("It is zero");
else
Console.ReadLine();
a) It is zero
b) It is not zero
c) Infinite loop
Answer :b.
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
int X = 6,Y = 2;
X *= X / Y;
Console.WriteLine(X);
Console.ReadLine();
a) 12
b) 6
c) 18
View Answer
Answer : c.
Explanation: X*=X/Y.
X=x*(X/Y).
Output: 18.
int x = 4 ,b = 2;
x -= b/= x * b;
Console.ReadLine();
a) 4 2
b) 0 4
c) 4 0
d) None of mentioned
View Answer
Answer :c.
Output: 4 0
a) float
b) int
c) long
Answer :b
Explanation: None.
int x = 8;
int b = 16;
int C = 64;
x /= b /= C;
Console.ReadLine();
a) 8 2 32
b) 32 4 8
c) 32 2 8
View Answer
Answer :d.
int x = 8;
int b = 16;
int C = 64;
x /= b /= C;
Console.ReadLine();
a) 8 2 32
b) 32 4 8
c) 32 2 8
View Answer
Answer:c.
Output: 32 2 8.
Explanation: x / = b / =C is x = x * c /b.
int a = 5;
int s = 0, c = 0;
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
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.
View Answer
Answer: a.
Explanation: None.
Mul();
m();
Console.ReadLine();
Console.WriteLine("4");
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.
m();
Console.ReadLine();
Console.WriteLine("HI");
m();
a) HI HI HI
b) HI
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
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?
return decimal;
View Answer
Answer: b
int i = 10;
double d = 35.78;
fun(i);
fun(d);
Console.ReadLine();
Console.WriteLine(d);
a) 35.78
10
b) 10
35.00
c) 10
35.78
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
Output:10
35.78
a) 0
b) 2
c) 1
View Answer
Answer: c
Explanation:a method can return only either single value or no value if no then its declared as void
method();
int y = 3;
y++;
if (y <= 5)
Console.WriteLine("hi");
Main(args);
}
Console.ReadLine();
a) hi hi.
b) hi
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
return (x + x);
return (x + 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);}.
p();
void p()
Console.WriteLine("hi");
b) hi
c) hi infinite times
View Answer
Answer: a
a) 1
b) 2
c) Any number
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
2. Correct way of defining constructor of the given class as if objects of classes are created as:
p = pp;
t = tt;
b) sample s;
c) public sample()
{
p = 0;
t = 0.0f;
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;
i = ii;
k = kk;
View Answer
Answer: d.
Explanation: return types of parameters of object of class matches with defined constructor arguments
types.
View Answer
Answer: d, c
Explanation: None.
c) both a & b
View Answer
Answer: a
Explanation: Once the object is declared means, the constructor are also declared by default.
a) True
b) False
View Answer
Answer: b
Explanation:C# provides feature of method overloading which means methods with same name but
different types and arguments.
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
class abc
{
console.writeline("first method");
a();
console.writeline("second method");
console.writeline(i);
b();
class program
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
20
first method
second method
a) int
b) float
c) void
View Answer
Answer: d
Explanation: Constructors do not have any return type not even void included in it.
a) delete
b) class
c) constructor
d) None of mentioned
View Answer
Answer: c
Explanation: By definition.
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
3. Name a method same name as that of class which is used to destroy objects also called automatically
when application is finally on
a) Constructor
b) Finalize()
c) Destructor
d) End
View Answer
Answer :c
d) We have to specify run the garbage collector after executing VISUAL STUDIO.NET
View Answer
Answer :b, c.
Explanation :None.
a) new
b) free
c) delete
View Answer
Answer :c
Explanation: New is used to allocate memory in the constructors.Hence,we should use delete to free
that memory.
Answer :a, b
Explanation : None.
class sample
int i;
double k;
i = ii;
k = kk;
Console.WriteLine(j);
~sample()
double j = i - k;
Console.WriteLine(j);
class Program
{
static void Main(string[] args)
Console.ReadLine();
a) 0 0
b) 10.5 0
d) 10.5 5.5
View Answer
Answer :d
Explanation: First constructor sample is called and hence then destructor ~sample is evaluated.
a) int
b) void
c) float
View Answer
Answer :d
Explanation: Destructors donot have any return type not even void.
int width;
int height;
int length;
width = w;
height = h;
length = l;
public ~box()
class Program
Console.ReadLine();
a) 0
b) 180
View Answer
Answer: c
class box
int width;
int height;
int length;
this.width = w;
this.height = h;
this.length = l;
~ box()
console.writeline(volume);
class Program
Console.ReadLine();
a) 0
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. 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 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. 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. 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 */
}
}
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. 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. 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;
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 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
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. 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.