C# MCQ Final
C# MCQ Final
Control Structures
What will be the correct output for given code snippet?
class maths
{
public int fact(int n)
{
int result;
if (n == 2)
return 1;
result = fact(n - 1) * n;
return result;
}
}
class Program
{
static void Main(string[] args)
{
maths obj = new maths();
Console.WriteLine(obj.fact(4));
Console.ReadLine();
}
}
12
24
Please read the questions carefully and choose the most appropriate option.Which of the given options are TRUE?
1.The goto statement passes control to the next iteration of the enclosing iteration statement in which it appears.
2.Branching is performed using jump statements which cause an immediate transfer of the program control.
Both 1 and 2
only 1
only 2
class maths
{
public int fact(int n)
{
int result;
if (n == 1)
return 1;
result = fact(n - 1) * n;
return result;
}
}
class Output
{
static void Main(String[] args)
{
maths obj = new maths() ;
Console.WriteLine(obj.fact(4)*(3));
}
}
64
72
60
84
Recursive methods are faster that programmers written loop to call the function repeatedly using a stack
No output
1.1
11
12
13
12
22
32
11
21
31
11
12
13
111111
0 0 0….infinite times
1 1 1….infinite times
It finds reverse of i
21
21
21
21
11
21
21
11
1
1
1
1
21
1
21
21
0.05
-0.04999995
0.95
-0.05
Please read the questions carefully and choose the most appropriate option.Which of the given options can be use
a while loop and transfer control outside the loop?
1.break
2.goto
only 1
only 2
Both 1 and 2
prints ’1′
prints reverse of x
Please read the questions carefully and choose the most appropriate option.Which of the given options are TRUE?
1.The switch statement is a control statement that handles multiple selections and enumerations by passing cont
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.
only 1
Both 1 and 2
only 2
000
111
class Program
{
static void Main(string[] args)
{
int i = 5;
int j;
method1(ref i);
method2(out j);
Console.WriteLine(i + " " + j);
}
static void method1(ref int x)
{
x = x + x;
}
static void method2(out int x)
{
x = 6;
x = x * x;
}
}
10 36
36 0
36 10
00
Which of these data types is used by operating system to manage the Recursion in Csharp?
Array
Stack
Queue
Tree
class maths
{
public int fact(int n)
{
int result;
if (n == 1)
return 1;
result = fact(n - 1) * n;
return result;
}
}
class Output
{
static void Main(String[] args)
{
maths obj = new maths();
Console.WriteLine(obj.fact(1));
Console.ReadLine();
}
}
10
class recursion
{
public int fact(int n)
{
int result;
if (n == 1)
return 1;
result = fact(n - 1) * n;
return result;
}
}
class Program
{
public static void Main(String[] args)
{
recursion obj = new recursion();
Console.WriteLine(obj.fact(4));
Console.ReadLine();
}
}
30
24
120
144
Recursion another process of defining a method that calls other methods repeatedly
Recursion is a process of defining a method that calls other methods which in turn call again this method
12345
5 6 7 8 9 10
10
1 2 3 4 7 8 9 10
30 55
00
0 55
55 30
11
21
31
12
22
32
11
12
13
11
12
13
Which of these will happen if recursive method does not have a base case?
2.XML
What is not true about XSLT?
XSLT uses a set of rules that govern how a document is to be materialized is created.
HTTPS.
#PCDATA.
DOCTYPE.---------------------
XML.
None
place the values of the columns as attributes in the resulting XML document.---------------------------
place the values of the columns into elements rather than attributes.
SOAP was defined as an XML-based standard for providing remote procedure calls over the Internet.
None
an intersection table.
global elements.-----------------------
If the XML data instance conforms to the DTD, the document is said to be:
not-type-valid.
an HTML document.
type-invalid.
type-valid---------------
XML is:
With XML, there is a clear separation between document structure, content and materialization.
The document that is used by XSLT to indicate how to transform the elements of the XML document to another format is
a(n):
stylesheet. ----------------------
HTML page.
stored procedure.
DOCTYPE procedure.
An XML component that defines the structure of a document is known as a(n):
HTML Stylesheet.
DOCTYPE
DTD. -------------
#PCDATA.
SOAP.
HTML
XSLT. ---------------------
DTD
Which of the following statements are correct about the Collection Classes available in Framework Class Library?
None
Elements stored in a collection can be modified only if allelements are of similar types.
It is not Easy to adopt the existing Collection classes for newtype of objects
For the code set given below,which of the following statements are perfectly valid?
Class MyConatiner requires that it’s type arguement must implement Icomparable interface
Which of the following is the correct way to access all elements of the Queue collection created using the
C#.NET code snippet given below? Queue q = new Queue();
q.Enqueue("Sachin");
q.Enqueue('A');
q.Enqueue(false);
q.Enqueue(38);
q.Enqueue(5.4);
IEnumerator e;
e = q.GetEnumerable();
while (e.MoveNext())
Console.WriteLine(e.Current);
IEnumerable e;
e = q.GetEnumerator();
while (e.MoveNext())
Console.WriteLine(e.Current);
IEnumerator e;
e = Queue.GetEnumerator();
while (e.MoveNext())
Console.WriteLine(e.Current);
IEnumerator e;
e = q.GetEnumerator();
while (e.MoveNext())
Console.WriteLine(e.Current);
A HashTable t maintains a collection of names of states and capital city of each state. Which of the following is th
find out whether "Kerala" state is present in this collection or not?
t.ContainsState("Kerala");
t.HasValue("Kerala");
t.ContainsKey("Kerala");
t.HasKey("Kerala");
Sorted Array
Tree
Stack
ANS 30
Correct statement valid about generic procedures in C#.NET are?
Csharp
None
Gen()
Gen
Gen<>
ANS -IDictionaryComparer
public Gen(T o) {
ob = o;
}
Decleration of variable
Which of the following is the correct way to find out the number of elements currently present in an ArrayList Coll
arr.MaxIndex
arr.Capacity
arr.UpperBound
arr.Count
arr.GrowSize
Are generics in C# are same as the generics in java and templates in C++?
No
May be
Yes
Which of these type parameters is used for a generic methods to return and accept any type of object?
40
Runtime Error
Choose the statements which are valid for given code snippet:
class a
{
public void x(int p, double k)
{
Console.WriteLine("k : csharp!");
}
}
x s = new x();
delegate void d = new del(ref x);
d(8, 2.2f);
Suppose value of the Capacity property of ArrayList Collection is set to 4. What will be the capacity of the Collec
element to it?
16
32
public name { /* … */ }
For the code given below which statements are perfectly valid?
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? S
st.Push(11);
st.Push(22);
st.Push(-53);
st.Push(33);
st.Push(66);
IEnumerator e;
e = st.GetEnumerator();
while (e.MoveNext())
Console.WriteLine(e.Current);
IEnumerable e;
e = st.GetEnumerator();
while (e.MoveNext())
Console.WriteLine(e.Current);
IEnumerator e;
e = st.GetEnumerable();
while (e.MoveNext())
Console.WriteLine(e.Current);
IEnumerator e;
e = Stack.GetEnumerator();
while (e.MoveNext())
Console.WriteLine(e.Current);
4. ABSTRACT CLASS
Please read the questions carefully and choose the most appropriate option.Read the below
statement carefully.
Statement 1: The abstract keyword enables you to create classes and class members solely
for the purpose of inheritance—to define features of derived, non-abstract classes.
Statement 2: An abstract class can be instantiated.
A type of class which does not have it’s own objects but acts as a base class for
it’s subclass is known as?
Sealed class
Static class
Abstract class
None of the mentioned
Please read the questions carefully and choose the most appropriate option.Which of
the given options are TRUE?
You should not use the static or virtual modifiers in an abstract method declaration.
You should use the static or virtual modifiers in an abstract method declaration.
namespace ConsoleApplication4
{
public abstract class A
{
public int i = 7;
public abstract void display();
}
class B: A
{
public int j;
public override void display()
{
Console.WriteLine(i);
Console.WriteLine(j);
}
}
class Program
{
static void Main(string[] args)
{
B obj = new B();
A obj1 = new B();
obj.j = 1;
obj1.i = 8;
obj.display();
Console.ReadLine();
}
}
}
1, 8
1, 7
7, 1
0, 8
Please read the questions carefully and choose the most appropriate option.Which
of the given options are TRUE about "Abstract Methods"?
1.An abstract method is implicitly a virtual method.
2.Abstract method declarations are only permitted in abstract classes.
only 2
None of the listed options
Both 1 and 2
only 1
Please read the questions carefully and choose the most appropriate option.
If you add a new method to an Abstract class, then which of the given options hold TRUE?
You have to track down all the implementations of the interface and define implementation
for the new method.
None of the 2 listed options
You have the option of providing default implementation and therefore all the existing
code might work properly.
namespace ConsoleApplication4
{
abstract class A
{
public int i;
public abstract void display();
}
class B: A
{
public int j;
public int sum;
public override void display()
{
sum = i + j;
Console.WriteLine(+i + "\n" + +j);
Console.WriteLine("sum is:" +sum);
}
}
class Program
{
static void Main(string[] args)
{
A obj = new B();
obj.i = 2;
B obj1 = new B();
obj1.j = 10;
obj.display();
Console.ReadLine();
}
}
}
2, 10
12
0, 0
0
0, 10
10
2, 0
2
Which of the following modifier is used when an abstract method is redefined by a derived class?
Base
Virtual
Overloads
Override
namespace ConsoleApplication4
{
abstract class A
{
int i;
public abstract void display();
}
class B: A
{
public int j;
public override void display()
{
Console.WriteLine(j);
}
}
class Program
{
static void Main(string[] args)
{
B obj = new B();
obj.j = 2;
obj.display();
Console.ReadLine();
}
}
}
0
Please read the questions carefully and choose the most appropriate option
.If the various implementations only share method signatures, then what is better to use?
Please read the questions carefully and choose the most appropriate option.
If the various implementations are of the same kind and use common behaviors or status,
then what is better to use?
namespace ConsoleApplication4
{
abstract class A
{
public int i ;
public int j ;
public abstract void display();
}
class B: A
{
public int j = 5;
public override void display()
{
this.j = 3;
Console.WriteLine(i + " " + j);
}
}
class Program
{
static void Main(string[] args)
{
B obj = new B();
obj.i = 1;
obj.display();
Console.ReadLine();
}
}
}
05
10
13
15
Please read the questions carefully and choose the most appropriate
option.Which of the given options are TRUE about "Abstract Classes"?
1.Abstract classes may also define abstract methods
2.An abstract class can be instantiated.
only 1
Both 1 and 2
only 2
The modifier used to define a class which does not have objects of
it’s own but acts as a base class for it’s subclass is
Sealed
New
abstract
Static
5.DEBUG
What is the shortcut key that is used to Start or resume execution of your code and then halts execution when it reaches
the selected statement?
Ctrl-Shift-F5
Ctrl-F10
Ctrl-F5
Ctrl-F9
What is the shortcut key that is used to allow you to attach or detach the debugger to one or more running process?
Ctrl-Alt-H Ctrl-Alt-P
Ctrl-Alt-W Ctrl-Alt-D
What is the shortcut key that is used to set the execution point to the line of code you choose
Ctrl-F10
Ctrl-Shift-F10
Ctrl-F5
Ctrl-Shift-F5
What is the shortcut key that is used to execute remaining lines out from procedure?
Shift-F5
Shift-F11
F11
F5
What is the shortcut key that is used to execute remaining lines out from procedure?
F5
Shift-F11
F11
Shift-F5
What is the shortcut key that is used to run the startup project and attaches the debugger?
F9
F10
F5
F6
What is the shortcut key that is used to set or removes breakpoint at the current line?
F10
F5
F9
F6
What is the shortcut key that is used to run the code without invoking debugger?
F9
F5
F10
Ctrl-F5
What is the shortcut key that is used to clear all of the breakpoints in the project?
Ctrl-Shift-F5
Ctrl-Shift-F9
Ctrl-Shift-F6
Ctrl-Shift-F10
What is the shortcut key that is used to execute the next line of code but doesnot step into any function calls available in
break and run modes ,this terminates the debugging session?
Shift-F11
Shift-F10
Shift-F5
Shift-F9
What is the shortcut key that is used to display the threads window to view all of the threads for the current process?
Ctrl-Alt-P
Ctrl-Alt-H
Ctrl-Alt-D
Ctrl-Alt-W
What is the shortcut key that is used to enable or disable the breakpoint on the current line of code?
Ctrl-F5 Ctrl-Shift-F5
Ctrl-F9 Ctrl-Shift-F9
What is the shortcut key that is used to Start or resume execution of your code and then halts execution when it reaches
the selected statement?
Ctrl-Shift-F5
Ctrl-F9
Ctrl-F10
Ctrl-F5
What is the shortcut key that is used to display breakpoint dialogWhat is the shortcut key that is used to display
breakpoint dialog
Ctrl-Alt-D
Ctrl-Alt-B
Ctrl-Alt-C
Ctrl-Alt-Q
what are the commands that are not available in break mode to proceed for further debugging
StepOut
Continue
Break
StepIn
If debug point is on a methodcall,______will execute the entire method at a time and stops at the nextline
Break
StepOut
Step over
Step In
6.GARBAGE
Please read the questions carefully and choose the most appropriate option.Imagine the scenario below.
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 given programming constructs should be used to implement this idea?
Namespace
Interface
Attribute
Delegate
int x = 8;
int b = 16;
int C = 64;
x /= b /= C;
Console.ReadLine();
}
Run time error
32 4 8
8 2 32
32 2 8
**********************************
Please read the questions carefully and choose the most appropriate option.Which of the given options is TRUE?
An object is destroyed by the garbage collector when only one reference refers to it.
****************************************************************
int i, j;
if (i == j)
Console.WriteLine("1");
else
Console.WriteLine("0");
Console.WriteLine("\n");
}
Console.ReadLine();
001
010
100
100
001
010
010
100
001
100
010
001
****************************************************************
class number
get
return num1;
set
{
num1 = value;
get
return num2;
set
num2 = value;
class Program
p.anumber = 20;
k.anumber1 = 40;
int m = p.anumber;
int t = k.anumber1;
Console.ReadLine();
}
}
sum = 60
number = 40
number = 20
None
number = 20
number = 40
sum = 60
****************************************************************
class number
get
return length;
set
length = value;
class Program
{
public static void Main(string[] args)
int k = p.number1 * 3 / 9;
Console.WriteLine(k);
Console.ReadLine();
180
30
****************************************************************
class student
get
if (index < 3)
return scores[index];
else
Console.WriteLine("invalid index");
return 0;
private set
{
if (index < 3)
scores[index] = value;
else
Console.WriteLine("invalid index");
class Program
else
Console.ReadLine();
****************************************************************
int i;
int b = 8, a = 32;
if ((a / b * 2)== 2)
continue;
else if (i != 4)
else
break;
Console.ReadLine();
01234
0123
123456789
012345678
****************************************************************
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();
Rahul Dravid
Sachin Tendulkar
Ms Dhoni
****************************************************************
class number
get
return num1;
set
num1 = value;
}
}
get
return num2;
set
num2 = value;
class Program
int m = p.anumber;
int t = k.anumber1;
Console.ReadLine();
sum = 0
sum = 1200
sum = 120
func(ref a);
Console.ReadLine();
if (x[i] % 2 == 0)
x[i] = x[i] + 1;
Console.WriteLine(x[i]);
numbers are : 2 4 6 8 10
numbers are : 3 5 7 9 11
numbers are : 2 3 4 5 6
****************************************************************
int x = 4 ,b = 2;
x -= b/= x * b;
Console.ReadLine();
}
40
None of mentioned
04
42
Assembly.loadfile()
Assembly.reflectiononlyload
Assembly.load()
Assembly.load from()
****************************************************************
/*___________________________*/
Console.ReadLine();
if(num[i] % 2 = 0)
even += 1;
else
odd += 1;
}
if ((num % 2) == 0)
even += 1;
else
odd += 1;
if(num[i] % 2 == 0)
even += 1;
else
odd += 1;
if((num * i) == 0)
even += 1;
else
odd += 1;
****************************************************************
get
return length;
class Program
int l;
l = p.number1 + 40;
int k = l * 3 / 4;
Console.WriteLine(k);
Console.ReadLine();
75
80
30
7.BASIC
Please read the questions carefully and choose the most appropriate option.Which of the given options is TRUE about
Common Language Runtime (CLR)?
1.In CLR, code is expressed in the form of byte code called the Common Intermediate Language (CIL), previously known
as MSIL (Microsoft Intermediate Language)
2.It manages memory but not code execution and other system services.
only 2
Both 1 and 2
only 1
Please read the questions carefully and choose the most appropriate option.Which of the given options are TRUE about
Attributes in C#.NET?
1.On compiling a C#.NET program the attributes applied are recorded in the metadata of the assembly.
2.On compilation all the attribute's tags are deleted from the program.
only 2
only 1
Both 1 and 2
Sets the current position in the stream to the specified offset from specified origin and hence returns the new position
None
extract
this
super
Please read the questions carefully and choose the most appropriate option.Read the below statements carefully.
Statement 1: It launches separate process for every application running under it.
Which of the statements are TRUE about the benefits we get on running managed code under CLR?
Select the method which writes the contents of the stream to the physical device.
void Flush()
void fflush()
flush()
fflush()
Sytem.Input.stream
System.IO.stream
System.Output.stream
System.Root
System.Base
System.Object
System.Type
Correct statement about the C#.NET code given below is?
class trial
int i;
float d;
struct sample
private int x;
private Single y;
private trial z;
BufferedStream
MemoryStream
FileStream
Which of these is method is used for reading bytes from the file?
put()
write()
Read()
WriteByte()
Choose the filemode method which is used to create a new output file with condition that file with same name if existed
it destroyes the old file:
FileMode.Truncate
FileMode.OpenOrCreate
FileMode.CreateNew
FileMode.Create
Statement 2: CLR ensures that an application would not be able to access memory that it is not authorized to access.
Which of the following statements are TRUE about the .NET CLR?
Please read the questions carefully and choose the most appropriate option.Which of the given options are TRUE about
Attributes in C#.NET?
1.The attributes applied can be read from an assembly using Reflection class.
only 1
only 2
Both 1 and 2
struct sample
public int i;
}
class Program
a.i = 10;
fun(ref a);
Console.WriteLine(a.i);
x.i = 20;
Console.WriteLine(x.i);
a) 10 10
b) 20 10
c) 10 20
d) 20 20
Which is the correct way to settle down values into the structure variable ‘e’ defined as?
struct emp
e.name = “Ankit”;
e.age = 24;
e.sal = 200;
name = “Ankit”;
age = 24;
sal = 200;
With emp e
.name = “Ankit”;
.age = 24;
.sal = 200;
Which method of character stream class returns the numbers of characters successfully read starting at count?
int Read()
Which of these is used to perform all input & output operations in C#?
Methods
classes
streams
Variables
Attempts to read up to count bytes into buffer starting at buffer[offset], returning the number of bytes successfully read?
int ReadByte()
1.In CLR, code is expressed in the form of byte code called the Common Intermediate Language (CIL), previously known
as MSIL (Microsoft Intermediate Language)
2.It manages memory but not code execution and other system services.
only 2
Both 1 and 2
only 1
struct sample
public int i;
class Program
a.i = 10;
fun(ref a);
Console.WriteLine(a.i);
x.i = 20;
Console.WriteLine(x.i);
}
20
10
20
20
10
10
10
20
8.Access Specifier
What will be size of object created depicted by csharp code snippet?
class baseclass
{
private int a;
protected int b;
public int c;
}
class derived : baseclass
{
private int x;
protected int y;
public int z;
}
class Program
{
static Void Main(string[] args)
{
derived a = new derived();
}
}
20 bytes
16 bytes
24 bytes
12 bytes
33
23
class access
{
public int x;
private int y;
public void cal(int a, int b)
{
x = a + 1;
y = b;
}
public void print()
{
Console.WriteLine(" " + y);
}
}
class Program
{
static void Main(string[] args)
{
access obj = new access();
obj.cal(2, 3);
Console.WriteLine(obj.x);
obj.print();
Console.ReadLine();
}
}
Run time error
33
23
class sum
{
public int x;
public int y;
public int add (int a, int b)
{
x = a + b;
y = x + b;
return 0;
}
}
class Program
{
static void Main(string[] args)
{
sum obj1 = new sum();
sum obj2 = new sum();
int a = 2;
obj1.add(a, a + 1);
obj2.add(5, a);
Console.WriteLine(obj1.x + " " + obj2.y);
Console.ReadLine();
}
}
3, 2
6, 9
5, 9
9, 10
class static_out
{
public static int x;
public static int y;
public int add(int a, int b)
{
x = a + b;
y = x + b;
return 0;
}
}
class Program
{
static void Main(string[] args)
{
static_out obj1 = new static_out();
static_out obj2 = new static_out();
int a = 2;
obj1.add(a, a + 1);
obj2.add(5, a);
Console.WriteLine(static_out.x + " " + static_out.y );
Console.ReadLine();
}
}
77
66
97
79
Which of these is used as default specifier for a member of class if no access specifier is used for it?
protected
public
private
class math
{
public int a,b;
public math(int i, int j)
{
a = i;
b = j;
}
public void sum(math m)
{
m.a *= 2;
m.b += 2;
}
}
class Program
{
static void Main(string[] args)
{
math t = new math(20, 10);
t.sum(t);
Console.WriteLine(t.a + " " + t.b);
Console.ReadLine();
}
}
20, 10
40, 12
10, 20
5, 40
class sum
{
public int x;
private int y;
public void math(int a, int b)
{
x = a * 4;
y = b;
}
}
class Program
{
static void Main(string[] args)
{
sum p = new sum();
p.math(12, 30);
Console.WriteLine(p.x + " " + p.y);
Console.ReadLine();
}
}
0, 0
48, 30
48, 0
class test
{
public int a;
public int b;
public test(int i, int j)
{
a = i;
b = j;
}
public void meth(test o)
{
o.a *= 2;
o.b /= 2;
}
}
class Program
{
static void Main(string[] args)
{
test obj = new test(10, 20);
obj.meth(obj);
Console.WriteLine(obj.a + " " + obj.b);
Console.ReadLine();
}
}
10, 20
40, 20
20, 40
20, 10
9.Delegates
1…Please read the questions carefully and choose the most appropriate option.Which of the given options is FALSE about
delegate?
only 2
None of the listed options …………………
only 1
Both 1 and 2
class sample
class Program
A str1;
str1 = sample.fun;
str1(ref str);
Console.WriteLine(str);
ur C#.net skills
ur C#.NET
Test Your
3… Choose the statements which makes delegate in C#.NET different from a normal class?
c) Only system and compilers can derive explicitly from the Delegate or MulticasteDelegate class
4…Which is the correct way to call the function abc() of the given class csharp given below?
class csharp
Console.WriteLine("A:Just do it!");
return 0;
d(10);
del d;
d(10);
d(10);
5…Please read the questions carefully and choose the most appropriate option.Which of the given options is FALSE about
delegate?
The signature of a delegate must match the signature of the method that is to be called using it.
6…Choose statements which differentiate delegate in C#.NET than a conventional function pointer in other languages?
public
new
protected
internal
8…An Event is
result of a party
9…Suppose a Generic class called as SortObjects is to made capable of sorting objects of any type(integer, single, byte
etc).Hence, which following programming
interface
attribute
encapsulation
delegate
11…Please read the questions carefully and choose the most appropriate option.Which of the given options are TRUE
about a delegate?
The declaration of a delegate must match the signature of the method that we intend to call using it.
12…Please read the questions carefully and choose the most appropriate option.In which of the given areas are
delegates commonly used?
1.Multithreading
2.Event handling
only 1
Both 1 and 2
only 2
Both 1 and 2
only 1
only 2
the del class will contain a one arguement constructor and an invoke() method
16…Choose statements which differentiate delegate in C#.NET than a conventional function pointer in other languages?
17…Please read the questions carefully and choose the most appropriate option.In which of the given areas are
delegates commonly used?
1.Multithreading
2.Event handling
Both 1 and 2
only 2
only 1
only 2
Both 1 and 2
only 1
class sample
return a.Replace(',''-');
class Program
Console.WriteLine(str);
}
}
a) Test Your
b) Test-Your-C#.NET-Skills
c) ur C#.NET Skills
class sample
class Program
Console.WriteLine(str);
Console.ReadLine();
2.Delegates cannot be used to call procedures that receive variable number of arguments.
only 2
only 1
Both 1 and 2
10.Class
Select the output for following set of code :
class z
{
public string name1;
public string address;
public void show()
{
Console.WriteLine("{0} is in {1}", name1, address);
}
}
class Program
{
static void Main(string[] args)
{
z n = new z();
n.name1 = "harsh";
n.address = "new delhi";
n.show();
Console.ReadLine();
}
}
Syntax error
class sample
{
public int i;
public int[] arr = new int[10];
public void fun(int i, int val)
{
arr[i] = val;
}
}
class Program
{
static void Main(string[] args)
{
sample s = new sample();
s.i = 10;
sample.fun(1, 5);
s.fun(1, 5);
Console.ReadLine();
}
}
Please read the questions carefully and choose the most appropriate option.Which of the following components of
framework provide an extensible set of classes that can be used by any .NET compliant programming language?
1..NET class libraries
2.Component Object Model
Both 1 and 2
only 1
only 2
class sample
{
public int i;
public int j;
public void fun(int i, int j)
{
this.i = i;
this.j = j;
}
}
class Program
{
static void Main(string[] args)
{
sample s = new sample();
s.i = 1;
s.j = 2;
s.fun(s.i, s.j);
Console.WriteLine(s.i + " " + s.j);
Console.ReadLine();
}
}
Error as ‘this’ reference would not be able to call ‘i’ and ‘j’
12
Please read the questions carefully and choose the most appropriate option.Which of the given keywords is used to
data and behavior of a base class by replacing a member of a base class with a new derived member?
new
override
base
overloads
Please read the questions carefully and choose the most appropriate option.Which of the given options are
TRUE about the String Class in C#.NET?
All the listed options
Please read the questions carefully and choose the most appropriate option.Which of the given options CANNOT be
custom attribute?
All the listed options
Delegate
Namespace
Event
class z
{
public int X;
public int Y;
public const int c1 = 5;
public const int c2 = c1 * 25;
public void set(int a, int b)
{
X = a;
Y = b;
}
}
class Program
{
static void Main(string[] args)
{
z s = new z();
s.set(10, 20);
Console.WriteLine(s.X + " " + s.Y);
Console.WriteLine(z.c1 + " " + z.c2);
Console.ReadLine();
}
}
20 10
10 20
5 125
10 20
20 10
Please read the questions carefully and choose the most appropriate option.Which of the given options are TRUE?
A private function of a class can access a public function within the same class.
true
type
scope
Please read the questions carefully and choose the most appropriate option.With which of the given options can the ref keywo
1.Static data
2.Instance data
only 1
only 2
Both 1 and 2
class test
{
public void print()
{
Console.WriteLine("Csharp:");
}
}
class Program
{
static void Main(string[] args)
{
test t;
t.print();
Console.ReadLine();
}
}
None of the mentioned
Please read the questions carefully and choose the most appropriate option.Which of the given options are
TRUE about the 'this' reference?
this' reference can be modified in the instance member function of a class.
this' reference continues to exist even after control returns from an instance member function.
Select the output for following set of code :
class sample
{
public int i;
public int j;
public void fun(int i, int j)
{
this.i = i;
this.j = j;
}
}
class Program
{
static void Main(string[] args)
{
sample s = new sample();
s.i = 1;
s.j = 2;
s.fun(s.i, s.j);
Console.WriteLine(s.i + " " + s.j);
Console.ReadLine();
}
}
12
Error as ‘this’ reference would not be able to call ‘i’ and ‘j’
Please read the questions carefully and choose the most appropriate option.
Static procedures can access instance data? State TRUE or FALSE?
false
true
11.Data Type
static void Main(string[] args)
{
int[] x = {65, 66, 67, 68, 69, 70};
fun(x);
Console.ReadLine();
}
static void fun(params int[] b )
{
int i;
for (i = 5; i > 0 ; i--)
{
b[i] = b[i] + 32;
Console.WriteLine(Convert.ToChar(b[i]));
}
}
A, B, C, D, E, F
F, E, D, C, B, A
b, c, d, e, f
f, e, d, c, b
enum per
{
a,
b,
c,
d,
}
per.a = 10;
Console.writeline(per.b);
11
void func(int x)
{
void func(int[] x)
{
Which of these method of class String is used to check whether a given string starts with a particular substring or
EndsWith()
StartsWith()
Ends()
Starts()
Please read the questions carefully and choose the most appropriate option.Which of the given options are TRUE
enumerators?
1.Values of enum elements cannot be populated from a database.
2.Enum is a class declared in System namespace
only 2
Both 1 and 2
only 1
Please read the questions carefully and choose the most appropriate option.Which of the given options are TRUE
1.The value of each successive enumerator is decreased by 1.
2.Values of enum elements cannot be populated from a database.
Both 1 and 2
only 2
only 1
Please read the questions carefully and choose the most appropriate option.Which of the given options are TRUE about enumerators?
1.An enum variable can be defined inside a class or a namespace.
2.An enum variable cannot have a protected access modifier.
only 1
Both 1 and 2
only 2
Please read the questions carefully and choose the most appropriate option.What is the size of a Decimal data type?
16 byte
8 byte
32 byte
4 byte
By default the first enumerator had a value equals to number of elements present in the list
enum color:byte
{
yellow = 500,
green = 1000,
pink = 1300
}
Please read the questions carefully and choose the most appropriate option.Which of the given data types does not store a sign?
long
int
short
byte
3, 4, 7, 8, 5, 1, 2, 3, 4, 5
4, 6, 10, 12, 5
3, 4, 7, 8, 5
Please read the questions carefully and choose the most appropriate option.Which of the given options are TRUE
A String is a primitive.
enum colors
{
red,
black,
pink
}
black
red
class A
{
internal int i;
int j;
public A()
{
i = 1;
j = 2;
}
}
class Program
{
static void Main(string[] args)
{
A obj1 = new A();
Console.WriteLine(obj1.i.ToString());
Console.ReadLine();
}
}
true
false
1 4.0 harsh
1 4 hars
14
1 4 harsh
Please read the questions carefully and choose the most appropriate option.Which of the given options are TRUE?
1.String literals can contain any character literal including escape sequences.
2.Attempting to access a character that is outside the bounds of the string results in an IndexOutOfRangeExceptio
Both 1 and 2
only 2
only 1
Please read the questions carefully and choose the most appropriate option.An enum that is declared inside a clas
namespace or interface is treated as public. State True or False.
true
false
out
var
param
ref
Ixgo
Ixig
Ixigo
Ixigo
12.Properties
Choose the correct statement about properties describing the indexers?
No need to use the name of the property while using an indexed property
class math
{
int ad;
public int add
{
set
{
ad = value;
}
}
}
class math
{
int ad;
public int add
{
get
{
return ad;
}
set
{
ad = value;
}
}
}
None
class math
{
public int add
{
set
{
add = value;
}
}
}
Private
Public
Protected
Protected Internal
Lm njk
Useful for usage in classes which store sensitive information like password of a user
Properties once set and hence values cannot be read back in nature
Consider a class maths and we had a property called as sum.b is a reference to a maths object and we want the s
Console.WriteLine(b.sum)to fail.Which is the correct solution to ensure this functionality?
class math
{
public int add
{
get
{
return ad;
}
}
}
class math
{
int ad;
public int add
{
get
{
return ad;
}
set
{
ad = value;
}
}
}
None
class math
{
int ad;
public int add
{
get
{
return ad;
}
}
}
Consider a class maths and we had a property called as sum.b is a reference to a maths object and we want the c
work.Which is the correct solution to ensure this functionality?
b.maths = 10;
Console.WriteLine(b.maths);
Declare maths property with only get, set and normal accessors
If math class had add property with get accessors then which statements will work correctly?
math.add = 20;
Please read the questions carefully and choose the most appropriate option.A property can be declared inside a c
Interface. State TRUE or FALSE.
false
true
Please read the questions carefully and choose the most appropriate option.A property can be declared inside a n
procedure. State TRUE or FALSE.
false
true
13.OOC 1
The capability of an object in Csharp to take number of different forms and hence display
behaviour as according is known as
}
public class subject : maths
{
new public void a()
{
Interface
interface
Intf
intf
Which of these can be used to fully abstract a class from its implementation?
Interfaces
Objects
None of the Mentioned
Packages
Which of these method of Thread class is used to Suspend a thread for a period of time?
suspend()
stop()
sleep()
terminate()
protected member
public member
private member
static member
Wait()
Pulse()
All of the mentioned
PulseAll()
Can’t Say
false
true
None of the mentioned
W) Given the class sample inherited by class sample1. Which are correct statements about construction of
object of class sample?
While creating the object firstly the constructor of class sample will be called followed by constructor
of class sample 1
The order of calling constructors depend on whether constructors in class sample and sample 1 are
private or public
While creating the object firstly constructor of class sample 1 will be called followed by constructor of
class sample
suspend()
sleep()
Abort()
synchronize
synchronized
synch
syn
A type of class which does not have it’s own objects but acts as a base class for it’s subclass is known as?
Static class
Sealed class
Abstract class
None of the mentioned
Which of following keyword used to change data and behaviour of a base class by replacing a member of a base c
new derived member?
Base
new
Overloads
Overrides
process based
All the given options
thread based
14.OOC-2
System.net
All of the mentioned
System.Linq
System.Threading
Until the call of which type of method the newly created thread will not start executing?
Please read the questions carefully and choose the most appropriate option.Which of the given options are TRUE
1.The subclass inherits all the super class attributes and extends them or adds others.
2.C Sharp supports multiple inheritance
only 1
only 2
Both 1 and 2
None of the listed options
Single inheritance
Hierarchical inheritance
Multiple inheritance
Multilevel inheritance
Please read the questions carefully and choose the most appropriate option.Read the below statement carefully.
Statement 1: An interface in C# is a pure abstract class
Statement 2: An interface contains only definition of events, indexers, methods and/or properties.
Which of the above statements is TRUE about "Interfaces"?
Please read the questions carefully and choose the most appropriate option.
Which of the given options are TRUE?
Please read the questions carefully and choose the most appropriate option.
Which of the given options are FALSE?
Statement 1: Inheritance is a relationship between classes where one class is the parent class of another.
Statement 2: Parent class is also called Base class, Super class and Ancestor
Which of the above statements are TRUE?
Please read the questions carefully and choose the most appropriate option..
Which of the given options is TRUE about "Interfaces"?
Classes and structs inheriting interfaces, may or may not provide an implementation for each interface memb
Classes and structs inheriting interfaces must provide an implementation for each interface member defined
Please read the questions carefully and choose the most appropriate option.If you add a new method to an Interface, then which of the given op
You have to track down all the implementations of the interface and define implementation for the new meth
None of the 2 listed options
You have the option of providing default implementation and therefore all the existing code might work prope
Please read the questions carefully and choose the most appropriate option.Read the below statements carefully.
Statement 1: Interface requires more time to find the actual method in the corresponding classes where as an abstract class is faster
Statement 2: Abstract method declarations are only permitted in abstract classes.
Which of the above statements are TRUE?
only 2
only 1
None of the listed options
Both 1 and 2
Please read the questions carefully and choose the most appropriate option.Inheritance enables you to create new
classes?
Please read the questions carefully and choose the most appropriate option.Which of the given options are TRUE
An interface describes the methods, properties, and events that a class needs to implement,
and the type of parameters each member needs to receive and return.
An interface describes the methods, properties, and events that a class needs to implement,
but not the type of parameters each member needs to receive and return.
Please read the questions carefully and choose the most appropriate option.Is it possible to implement any
number of interfaces in a single derived class?
No, there is a limit to the number of interfaces you can implement in a single derived class
Yes, and you may or may not provide signature of all methods, in the derived class
Yes, but you should provide signatures of all methods, in the derived class
Please read the questions carefully and choose the most appropriate option.Which of the given options are
TRUE?
Please read the questions carefully and choose the most appropriate option.Which of the given options are TRUE?
Please read the questions carefully and choose the most appropriate option.
Which of the given options are FALSE?
Multiple classes may implement the same interface, and a single class may implement one or more interfaces
In interface at least one method should not be abstract.
None of the listed options
Interfaces are essentially definitions of how a class needs to respond.
15.OOC-3
190, 26
190, 0
0, 26.78f
190,
26.78f
Please read the questions carefully and choose the most appropriate option.
Which of the given options are logical operators in C#.Net?
||
&&
!
All the listed options
A
B
B
B
A
A
Compile time error
Please read the questions carefully and choose the most appropriate option.
Which of the given options is TRUE?
Please read the questions carefully and choose the most appropriate option.
Which of the given options is TRUE?
When overriding a method, the names and type signatures of the override method
must be the same as the virtual method that is being overriden.
Both the listed options
None of the 2 listed options
Abstract methods are implicitly virtual.
Please read the questions carefully and choose the most appropriate option.
Which of the given options is TRUE?
Each derived class does not have its own version of a virtual method.
None of the 2 listed options
Both the listed options
By default methods are virtual.
Please read the questions carefully and choose the most appropriate option.
In which of the following should the methods of a class differ if they are to be treated
as overloaded methods?
Please read the questions carefully and choose the most appropriate option.
A derived class can stop virtual inheritance by declaring an override as
inheritable
not inheritable
sealed
extends
What could be the output for set of code?
class overload
{
public int x;
int y;
public int add(int a)
{
x = a + 1;
return x;
}
public int add(int a, int b)
{
x = a + 2;
return x;
}
}
class Program
{
static void Main(string[] args)
{
overload obj = new overload();
overload obj1 = new overload();
int a = 0;
obj.add(6);
obj1.add(6, 2);
Console.WriteLine(obj.x);
Console.WriteLine(obj1.x);
Console.ReadLine();
}
}
8 10
78
88
02
Please read the questions carefully and choose the most appropriate option.
Which of the following keyword is used to overload user-defined types by
defining static member functions?
Please read the questions carefully and choose the most appropriate option.Which of the given options is TRUE?
When a binary operator is overloaded the corresponding assignment operator, if any, must be explicitly overl
None of the 2 listed options
The conditional logical operators cannot be overloaded.
Both the listed options
Please read the questions carefully and choose the most appropriate option.
Which of the given options can be declared as a virtual in a class?
Methods
Properties
All the listed options
Events
Please read the questions carefully and choose the most appropriate option.In
which of the following should the methods of a class differ if they are to be treated as overloaded methods?
Type of arguments
Order of arguments
All the listed options
Number of arguments
190, 26.78f
0, 26.78f
190, 0
190, 26
Please read the questions carefully and choose the most appropriate option
.Which of the given options are necessary for Run-time Polymorphism?
Please read the questions carefully and choose the most appropriate option.
A derived class can stop virtual inheritance by declaring an override as
not inheritable
extends
inheritable
sealed
Please read the questions carefully and choose the most appropriate option.
Which of the given options is TRUE?
When overriding a method, the names and type signatures of the override
method must be the same as the virtual method that is being overriden.
Abstract methods are implicitly virtual.
Both the listed options
None of the 2 listed options
Please read the questions carefully and choose the most appropriate option.Which of the following keyword is used to overload user-defined ty
opoverload
All the listed options
Operator………..
op
Please read the questions carefully and choose the most appropriate option.Which of the given options is TRUE?
16.OOC-4
Please read the questions carefully and choose the most appropriate option.Which of the given statements is TRU
Please read the questions carefully and choose the most appropriate option.It is possible to create a custom attrib
options?
Classes
Classes, Methods and Member-Variables
Classes and Methods
Methods
}
public class newspaper :sample
{
new public static int x = 1000;
static void Main(string[] args)
{
console.writeline(sample.x + " " + sample.y + " " + x);
}
}
}
class Program
{
static void Main(string[] args)
{
sample1 obj = new sample1();
Console.ReadLine();
}
}
Please read the questions carefully and choose the most appropriate option.Which of the given statements is TRU
Please read the questions carefully and choose the most appropriate option.Which of the given statements is TRU
Please read the questions carefully and choose the most appropriate option.
Which of the given statements is TRUE about an interface used in C#.NET?
Which statement should be added in function a() of class y to get output “i love csharp”?
class x
{
public void a()
{
Console.WriteLine("i love csharp");
}
}
class y : x
{
public void a()
{
/* add statement here */
Console.Write("bye");
}
}
class program
{
static void Main(string[] args)
{
y obj = new y();
obj.a();
}
}
base.a();
x.a();
a()
x::a();
Please read the questions carefully and choose the most appropriate option.Which of the given options can implement an interface?
1.class
2.enum
Both 1 and 2
None of the listed options
only 1
only 2
Please read the questions carefully and choose the most appropriate option.
Which of the given statements is TRUE about an interface used in C#.NET?
Please read the questions carefully and choose the most appropriate option.
Which of the given statements is TRUE about an interface used in C#.NET?
Please read the questions carefully and choose the most appropriate option.Which of the given options can be dec
1.Events
2.Structures
Console.WriteLine(base.a + ” ” + a);
Console.WriteLine( mybase.a + ” ” + a);
Console.WriteLine(a + ” ” + base.a);
Console.WriteLine( a + ” ” + this.a);
Please read the questions carefully and choose the most appropriate option.Which of the given options can be dec
1.Properties
2.Method
only 1
None of the listed options
Both 1 and 2
only 2
Please read the questions carefully and choose the most appropriate option.Which of the given statements is TRU
1.Interfaces can contain only method declaration.
2.Interfaces can contain static data and methods.
Both 1 and 2
only 2
None of the listed options
only 1
Please read the questions carefully and choose the most appropriate option.Which of the given statements is TRU
1.One class can implement only one interface.
2.In a program if one class implements an interface then no other class in the same program can implement this
17.OOC-5
Creating an instantiation for a thread doesn't mean that thread has started its execution process
A thread can exist only in two states, running and blocked
By multithreading CPU’s idle time is minimized, and we can take maximum use of it
Two thread in Csharp can have same priority
14
22
00
41
What is multithreaded programming?
Choose the correct statement about following code snippet given below:
interface a1
{
void f1();
void f2();
}
class a :a1
{
private int i;
void a1.f1()
{
}
}
Class a is an abstract class
Compile time error
Class a could not have an instance data
Class a fully implements the interface a1
Which keyword is used for using the synchronization features defined by the Monitor class?
synchronized
Monitor
lock
locked
A class member declared protected becomes member of subclass of which type?
protected member
private member
static member
public member
Select the correct statement among the given statements?
1
-127 to +127
It is not necessary to declare size of an array with it’s type
0 to 127
In Inheritance concept which of following members of base class are accessible to derived class members?
shared
static
private
protected
A class consists of two interfaces with each interface consisting of three methods.
The class had no instance data which indicates correct size of object created from this class?
16 bytes
12 bytes
24 bytes
0 bytes
Runnable
System
String
Thread
Given the class sample inherited by class sample 1. Which are correct statements about
construction of object of class sample?
While creating the object firstly constructor of class sample 1 will be called followed by
constructor of class sample
The constructor of only sample class will be called
The order of calling constructors depend on whether constructors in class sample and
sample 1 are private or public
While creating the object firstly the constructor of class sample will be called
followed by constructor of class sample 1
The modifier used to define a class which does not have objects of it’s own but acts as
a base class for it’s subclass is?
Sealed
New
Static
abstract
Its a method that allow to many threads to access any information the require
Its a process of handling situations when two or more threads need access to a shared resource
Its a process by which many thread are able to access same shared resource simultaneously
Its a process by which a method is able to access many different threads simultaneously
Which of the following is correct way of implementing an interface addition by class maths?
Static
Sealed
abstract
New
What is synchronization in reference to a thread?
Its a process by which many thread are able to access same shared resource simultaneously
Its a process of handling situations when two or more threads need access to a shared resource
Its a process by which a method is able to access many different threads simultaneously
Its a method that allow to many threads to access any information the require
Which keyword is used for using the synchronization features defined by the Monitor class?
lock
Monitor
synchronized
locked
18.OOC-6
000
0
111
25 100000 12.34
Correct code to be added for overloaded operator – for C# .net code given below?
class csharp
{
int x, y, z;
public csharp()
{
}
public csharp(int a ,int b ,int c)
{
x = a;
y = b;
z = c;
}
Add correct set of code here
public void display()
{
console.WriteLine(x + " " + y + " " + z);
}
class program
{
static void Main(String[] args)
{
csharp s1 = new csharp(5 ,6 ,8);
csharp s3 = new csharp();
s3 = - s1;
s3.display();
}
}
}
7.5 8
80
4 3.5
87
The following set of code run on single level of inheritance. Find correct statement about the code?
class sample
{
int i = 10;
int j = 20;
public void display()
{
Console.WriteLine("base method ");
}
}
class sample1 : sample
{
public int s = 30;
}
class Program
{
static void Main(string[] args)
{
sample1 obj = new sample1();
Console.WriteLine("{0}, {1}, {2}", obj.i, obj.j, obj.s);
obj.display();
Console.ReadLine();
}
}
3
2
1
Compile Time Error
Select the sequence of execution of function f1(), f2() & f3() in C# .NET CODE?
class baseclass
{
public void f1() {}
public virtual void f2() {}
public virtual void f3() {}
}
class derived : baseclass
{
new public void f1() {}
public override void f2() {}
public new void f3() {}
}
class Program
{
static void Main(string[] args)
{
baseclass b = new derived();
b.f1 ();
b.f2 ();
b.f3 ();
}
}
f1() of base class get executed f2() of derived class get executed
f3() of base class get executed
f1() of base class get executed f2() of derived class get executed
f3() of derived class get executed
f1() of derived class get executed f2() of base class get executed
f3() of base class get executed
f1() of derived class get executed f2() of derived class get executed
f3() of base class get executed
Correct code to be added for overloaded operator – for C# .net code given below?
class csharp
{
int x, y, z;
public csharp()
{
}
public csharp(int a ,int b ,int c)
{
x = a;
y = b;
z = c;
}
Add correct set of code here
public void display()
{
console.WriteLine(x + " " + y + " " + z);
}
class program
{
static void Main(String[] args)
{
csharp s1 = new csharp(5 ,6 ,8);
csharp s3 = new csharp();
s3 = - s1;
s3.display();
}
}
}
19.CONSOLE
None
StreamWriter
StringWriter
StreamReader
Choose the output return when read() reads the character from the console?
Boolean
Integer
Char
String
Which of these method used to read single character from the console?
get()
getline()
readLine()
read()/./////
….
Which method in Console enables to read individual inputs directly from the keyboard in
a non line buffered manner?
Read()
ReadLine()
ReadKey()
All the given options
Console.In
Console.Out
Console.Error
None
what would be the output for following input from the console as a character?
1
I/O EXCEPTION ERROR
0
false
SystemInputException
I/O Exception
SystemException
InterruptedException
readLine()
getline()
get()
read()
ReadLine()
ReadByte()
Readkey()
Read()
Read(), ReadLine()
ReadKey(), ReadLine()
Read(), ReadLine(), ReadKey()
ReadLine()
Choose the output returned when error condition generates while read() reads from the console.
-1
false
All the given options
0