avatar
durai test 2

Guest 65 9th Dec, 2019

MARKUP 9.13 KB
                                           
                         e:Navin Raaj
Assessment:DotNet-2
Score:43.33 (13/30)
Question:1 off 30
What could be the output of the following program?
using System;
class A { public virtual void F() { Console.WriteLine("f of A"); } }
class B extends A { new public void F() { Console.WriteLine("f of B"); } }
class Test {
 public static void Main() {
  A obj = new B();
  obj.f();
 }
}
*A		f of A
B		f of B
C		No output
D		Compilation fails

Question:2 off 30
Which access modifier provides visibility only to the elements of assembly, in which it is existing?
A		public
B		protected
C		private
*D		internal

Question:3 off 30
What could be the output of the following program?
using System;
class Program {
 public static void Main() {
  String s = "Programming";
   Console.Write(s.Substring(3, 4));
 }
}
*A		gram
B		gra
C		ogra
D		ogr

Question:4 off 30
Which two of the following statements will invoke the constructor of class Employee?
A		Employee e;
*B		Employee e = new Employee(10, "Goel");
*C		Employee e = new Employee();
D		Employee[] e = new Employee[10];

Question:5 off 30
What could be the output of the following program?
using System;
class Program {
 public static void Main() { Action(); }
 public void Action() { Console.Write("Action"); }
}
A		Action
B		No output
C*		Compilation fails
D		Run time error

Question:6 off 30
Consider the following class.
using System;
class User {
 private string password;
 public string Password {set { password = value; } }
 public User() {
  password = "default";
 }
}
Which of the following snippet will compile without any error?
A		User u = new User(); u.password = "[email protected]";
B*		User u = new User(); u.Password = "[email protected]";
C		User u = new User(); string pass = u.Password;
D		User u = new User(); Console.Write(u.Password);

Question:7 off 30
There is exactly one copy of this variable exists, regardless of how many times the class has been instantiated. The above statement refers to __________.
A		Global variable
B		Instance variable
C*		Static variable
D		Reference variable

Question:8 off 30
using System;
class Parent {
 public int x=10;
}
class Child:Parent {
 public int x=20;
 public void PrintX() {
  //L7
 }
}
class Program {
 static void Main() {
  Child c = new Child();
  c.PrintX();
 }
}
Considering the above program, which statement when replaced at L7 will give the output 20 10?
A*		Console.Write(x + " " + base.x);
B		Console.Write(this.x + " " + base(x));
C		Console.Write(x + " " + (base)x);
D		It is not possible to access the Parent class variable 'x'.

Question:9 off 30
How many objects of the class Test is created in the below mentioned program?
class Test {
 public static void Main() {
  Test[] t = new Test[3];
 }
}
A*		0
B		1
C		2
D		3

Question:10 off 30
Which is the only modifier that is applicable for a local variable?
A		public
B*		const
C		static
D		readonly

Question:11 off 30
(I) Static method can access instance data variables of a class.
(II) Instance method can access static data variables of a class.
A		Both statements I and II are false
B*		Statement I is false and II is true.
C		Statement I is true and II is false.
D		Both statements I and II are true.

Question:12 off 30
What could be the output of the following program?
using System;
using System.Text;
class Test {
 public static void Main() {
  StringBuilder x = new StringBuilder("Tom");
  Greet(x);
  Console.Write(x);
 }
 public static void Greet(StringBuilder x) {
  x.Append(" Hello");
 }
}
A		Tom
B		Hello
C		Hello Tom
D* 		Tom Hello

Question:13 off 30
What could be the output of the following program?
using System;
class A {
 public A() { Console.Write("A"); }
}
class B : A {
 public B() { Console.Write("B"); }
}
public class Test {
 public static void Main() {
  B b = new B();
 }
}
A		A
B		B
C*		AB
D		BA

Question:14 off 30
Which one of the following is not overloading?
A		Same method name with different type of parameter.
B		Same method name with different number of parameters.
C		Same method name with different type and different number of parameters.
D*		Same method name with same type and number of parameters.

Question:15 off 30
Which two of the following are the valid overriding versions for the method M()?
class A {
 protected void M() { }
}
A		private void M()
B*		protected void M()
C		protected int M()
D*		public void M()

Question:16 off 30
Which C# statement will initialize an integer array with integers 1 to 5?
A		int[] x=new {1,2,3,4,5};
B*		int[] x={1,2,3,4,5};
C*		int[] x=new int[]{1,2,3,4,5};
D		int x={1,2,3,4,5}

Question:17 off 30
What could be the output of the following program?
using System;
class Program {
 public Program() {
  Console.WriteLine("Object created");
 }
 public static void Main() {
  Program[] p = new Program[2];
 }
}
A		Object Created
B		Object created
Object created
C*		No output
D		Compilation fails

Question:18 off 30
Which class is the parent class of the class Test?
class Test {
 //Some code
}
A*		System.Object
B		System.object
C		System.Root
D		No parent for class Test

Question:19 off 30
What could be the output of the following program?
using System;
class A { public virtual void F() { Console.WriteLine("f of A"); } }
class B extends A { override public void F() { Console.WriteLine("f of B"); } }
class Test {
 public static void Main() {
  A obj = new B();
  obj.f();
 }
}
A		f of A
B*		f of B
C		No output
D		Compilation fails

Question:20 off 30
What could be the output of the following program?
using System;
class Test {
 public static void Main() {
  int[] a = {1,2,3};
  int[] b;
  b = Reverse(a);
  Console.WriteLine(a[0] + " " + a[1] + " " + a[2]);
  Console.WriteLine(b[0] + " " + b[1] + " " + b[2]);
 }
 public static int[] Reverse(int[] x) {
  int[] y = new int[x.Length];
  for(int i=0,j= x.Length-1; i<x.Length; i++,j--) {
   y[i] = x[j];
  }
  return y;
 }
}
A		1 2 3
1 2 3
B*		1 2 3
3 2 1
C		3 2 1
1 2 3
D		3 2 1
3 2 1

Question:21 off 30
Which one of the following is an enhanced for loop, that prints the content of an array x?
A		foreach(int value in x) { Console.Write(x)); }
B		foreach(value in x) { Console.Write(x)); }
C		foreach(value in x) { Console.Write(value)); }
D*		foreach(int value in x) { Console.Write(value));}

Question:22 off 30
public class A
{
 public int x;
}
public class B: A
{
 public int y;
}
What are the applicable members, when we create object for class 'B'?
A		only x
B		only y
C*		Both x and y
D		Neither x nor y

Question:23 off 30
Which of the following statement is false?
A		Class name and constructor name must be same.
B		Constructor runs automatically on creation of an object.
C		Constructor can be overloaded.
D*		Constructor can have a return type.

Question:24 off 30
What could be the output of the following program?
using System;
class Parent1 { }
class Parent2 { }
class Child : Parent1, Parent2 { }
class Program {
 public static void Main() {
  Child c = new Child();
  Console.Write("Object created");
 }
}
A		Object created
B		No output
C*		Compilation fails
D		Runtime error

Question:25 off 30
What could be the output of the following program?
using System;
public class Test {
 public static void Method(int x, float y) {
  Console.WriteLine("int, float");
 }
 public static void Method(float x, int y) {
  Console.WriteLine("float, int");
 }
 public static void Main() {
  int a = 10, b =20;
  Method(a, b);
 }
}
A		int, float
B		float, int
C		Run time error
D*		Compile time error

Question:26 off 30
What could be the output of the following program?
using System;
class Program {
 public void Program() {
  Console.WriteLine("Object created");
 }
 public static void Main() {
  Program p1 = new Program();
  Program p2 = new Program();
 }
}
A		F
B*		F
C		F
D		T

Question:27 off 30
Which one of the following is an example for boxing in C#?
A		int to float
B*		int to object
C		object to int
D		float to int

Question:28 off 30
Methods in interface are ______________ by default.
A		virtual
B		abstract
C		public
D*		public, virtual and abstract

Question:29 off 30
Which modifier is applicable for the variable x?
class Test {
 int x;
}
A		public
B		protected
C		internal
D*		private

Question:30 off 30
What could be the output of the following program?
using System;
class Program {
 public static void Main() {
  int x = 10;
  Fun1(x);
  Console.Write(x + " ");
  Fun2(ref x);
 Console.Write(x + " ");
 }
 static void Fun1(int x) {
  x++;
 }
 static void Fun2(ref int x) {
  x++;
 }
}
A		10 10
B*		10 11
C		11 12
D		11 11
                      
                                       
To share this paste please copy this url and send to your friends
RAW Paste Data