class Test{
Static void Main() {
int [] Array1 = {3,2,1);
int i = Array.IndexOf(Array1,3);
Console.WriteLine(i)
}
}
What will be the output of above code?
A -
3
B -
1
C -
0
D -
2
2-
class Question(
public Hashtable Directory = new Hashtable();
public string this[string Person] {
get {
return (string) Directory[Person];
}
set {
Directory[Person] = value;
}
}
}
Class Test {
static void Main() {
Question Dir = new Question();
// Add code here ……………….
}
}
Two persons named SMITH and MARTIN are to be added in the directory created above. To
achieve this which of the following are the valid statements that can be added in the sace
specified in the .code above?
Consider the class below:
Public class Test {
Public static void Main( ) {
int [ ] a = { 99, 22, 11, 55, 44, 88, 2, -3 };
int result = 0;
for ( int I = 0; i < a.Lenght; i++)
{
if ( a[ i ] > 30)
result += a[ i ];
} //end for
Console.WriteLine( "Result is: ", result );
}
}
The ouput of this C# program will be:
A -
Result is: 332
B -
Result is: 286
C -
Result is: 280
D -
Result is: 154
4-
Within the namspace we can declare following:
A -
Class
B -
Delegates
C -
All the options mentioned
D -
Interface
5-
Concatenating with strings are done with:
A -
method calls
B -
operator overloading
C -
reserved words
D -
operator overloading and method calls
6-
class IndexExample{
String Message;
Public static void Main() {
IndexExample obj=new IndexExample("WELCOME");
for(int i=0; i < 7; i++) {
System.Comsole.Write(obj[i]);
}
}
Public IndexExample (string s) { Message=s }
Public string this[int 1] {
get {
if(i >= 0 && i < Message.Length)
return Message.Substring(i, 1: ;
else
return "";
set {
if(i >= 0 && i < Message.Length)
Message=Message.Substring(0,i: +value + Message.Substring(i+1);
}
}
} What will be the output of above code?
A -
The code will compile successfully and output will be; WELCOME
B -
All over above
C -
Code will generate a run time error
D -
#
7-
Consider this example:
Class Example
{
Void firstMethod( )
{
in myVar;
. . .
Void anotherMethod( )
{
myVar = 42;
. . .
}
}
A -
This code OK. Another variable myVar is automatically create, and set to 42
B -
This code would fail to compile because anotherMethod is trying to use the variable myVar, which is not scope
C -
This code would fail to compile because anotherMethod is trying to use the variable myVar, which is not get memory with new() keyword
D -
This code OK. myVar is set to 42
8-
Consider array items, which contains the values 0, 2, 4, 6 and 8. If method changeArray
is called with the method call changeArray( item, items[ 2 ] ), what values are stored in items
after the method has finished executing?
Public static void ChangeArray( int[ ] passeArray, int value )
{
passedArray[ value ] = 12;
value = 5;
} // end method ChangeArray
A -
0, 2, 4, 6, 12
B -
0, 2, 12, 6, 8
C -
0, 2, 4, 6, 5
D -
0, 2, 5, 6, 12
9-
Contructors can not have ____.
A -
name
B -
overloaded constructors
C -
return values
D -
Argument
10-
Defining two methods with the same name but with different parameters is called.