C# Test
C# Test
C# Test
A. Abstract methods
B. Non Abstract methods
C. Both
D. None
A. private
B. public
C. protected
D. internal
A. True
B. False
C. Maybe
D. Can’t say
1
D. Explicit constructors can be parameterized or parameterless.
7. Reference is a ___.
A. protected, public
B. private, public
C. private
D. public
9. What is the value returned by function compareTo( ) if the invoking string is less
than the string compared?
A. Zero
B. A value of less than zero
C. A value greater than zero
D. None of the mentioned
11. Select the two types of threads mentioned in the concept of multithreading?
A. Foreground
B. Background
C. Only foreground
D. Both foreground and background
2
A. Each property consists of accessor as getting and set.
B. A property cannot be either read or write-only.
C. Properties can be used to store and retrieve values to and from the data
members of a class.
D. Properties are like actual methods that work like data members.
13. If a class ‘demo’ had ‘add’ property with getting and set accessors, then which
of the following statements will work correctly?
A. math.add = 20;
B. math m = new math();
m.add = 10;
C. Console.WriteLine(math.add);
D. None of the mentioned
class sample
int i;
double k;
i = ii;
k = kk;
Console.WriteLine(j);
~sample()
3
double j = i - k;
Console.WriteLine(j);
class Program
A. 0 0
B. 11.5 0
C. Compile-time error
D. 11.5 6.5
class program
int x = 8;
int b = 16;
4
int c = 64;
x /= c /= b;
Console.ReadLine();
A. 2 16 4
B. 4 8 16
C. 2 4 8
D. 8 16 64
A. Protected
B. Public
C. Private
D. Default
A. Default point
B. Invoking point
C. Calling point
D. Throw point
A. Every derived class does not define its own version of the virtual method.
B. By default, the access mode for all methods in C# is virtual.
C. If a derived class, does not define its own version of the virtual method, then
the one present in the base class gets used.
D. All of the above.
5
using System;
class sample
public sample()
Console.WriteLine("constructor 1 called");
public sample(int x)
int p = 2;
int u;
u = p + x;
Console.WriteLine("constructor 2 called");
class Program
Console.ReadLine();
6
}
A. constructor 1 called
constructor 2 called
B. constructor 2 called
constructor 1 called
C. constructor 2 called
constructor 2 called
D. error
20. Which of the following keywords is used to refer base class constructor to
subclass constructor?
A. this
B. static
C. base
D. extend
--------------------------------------------------------------------------------------------
Console.WriteLine("{0},{0}", a, b);
1. 10,10
2. 10,20
3. 20,20
4. 20,10
7
{
Console.WriteLine("{0}+{1}", a, b);
1. 30
2. 20+20
3. 10+10
4. 10+20
Console.WriteLine(Console.Write("Hello"));
1. Error
2. 6Hello
3. Hello6
4. Hello5
Console.WriteLine(a == b);
1. 1
8
2. a==b
3. True
4. true
text = Console.ReadLine();
Console.WriteLine(text);
1. Hello
2. Hello world!
3. Helloworld!
4. None
1. If the sum of two consecutive numbers is 0 then that number should be skipped
Eg -2 + -1 =-3
-1 + 1 =0 --> skipped
-3 + 3 = 0 skipped
9
27. Write a program to reverse a string.
29. Write a program to sort an array (without using any inbuilt function)
30. Write a program to find highest duplicated item and its count from an array.
10