C# Programming Test

C# Programming Test

Free C# Programming Mock Test: Placement

Practice the free Online C# Programming Test to get success in future placement. This online mock test will help you in the time of final placements.

General Instructions:
1. Each Programming test contains 15 questions.
2. Total allotted time is 20 minutes for each test.
3. No negative marking.
4. Try to finish it on time.
5. The Test will be submitted automatically if the time expired.
6. Don’t refresh the page.
0%

C# Programming Test 1

1 / 15

Which of the following statements is correct?

2 / 15

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.

3 / 15

Which of the following statements is incorrect about a delegate?

4 / 15

Creating empty structures is allowed in C#.NET.

5 / 15

If a base class contains a member function func(), and a derived class does not contain a function with this name, an object of the derived class cannot access func().

6 / 15

There is no private or protected inheritance in C#.NET.

7 / 15

There is no private or protected inheritance in C#.NET.

8 / 15

Which of the following statements are correct?

  1. Data members of a class are by default public.
  2. Data members of a class are by default private.
  3. Member functions of a class are by default public.
  4. A private function of a class can access a publicfunction within the same class.Member function of a class are by default private.

9 / 15

Which of the following statements are correct about functions and subroutines used in C#.NET?

  1. A function cannot be called from a subroutine.
  2. The ref keyword causes arguments to be passed by reference.
  3. While using ref keyword any changes made to the parameter in the method will be reflected in that variable when control passes back to the calling method.
  4. A subroutine cannot be called from a function.
  5. Functions and subroutines can be called recursively

10 / 15

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.It provides an event driven programming model for building Windows Device Drivers

11 / 15

Which of the following statements are correct?

  1. All operators in C#.NET can be overloaded.
  2. We can use the new modifier to modify a nested type if the nested type is hiding another type.
  3. In case of operator overloading all parameters must be of the different type than the class or struct that declares the operator.
  4. Method overloading is used to create several methods with the same name that performs similar tasks on similar data types.Operator overloading permits the use of symbols to represent computations for a type.

12 / 15

Which of the following statements are correct?

  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.

13 / 15

Which one of the following statements is correct?

14 / 15

What will be the output of the C#.NET code snippet given below?


int num = 1, z = 5;

if (!(num <= 0)) Console.WriteLine( ++num + z++ + ” “ + ++z );

else

Console.WriteLine( –num + z– + ” “ + –z );

15 / 15

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.

Your score is

The average score is 33%

0%

0%

C# Programming Test 2

1 / 15

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();

}


 

2 / 15

In a HashTable Key cannot be null, but Value can be.

3 / 15

Which of the following statements are correct about Structures used in C#.NET?

  1. A Structure can be declared within a procedure.
  2. Structs can implement an interface but they cannot inherit from another struct.
  3. struct members cannot be declared as protected.
  4. A Structure can be empty.
  5. It is an error to initialize an instance field in a struct.

4 / 15

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();


 

5 / 15

Which of the following statements are correct about the this reference?

  1. this reference can be modified in the instance member function of a class.
  2. Static functions of a class never receive the this
  3. Instance member functions of a class always receive a this
  4. this reference continues to exist even after control returns from an instance member function.
  5. While calling an instance member function we are not required to pass the this reference explicitly

6 / 15

What will be the output of the C#.NET code snippet given below?


byte b1 = 0xAB;

byte b2 = 0x99;

byte temp;

temp = (byte)~b2;

Console.Write(temp + ” “);

temp = (byte)(b1 << b2); Console.Write (temp + ” “);

temp = (byte) (b2 >> 2);

Console.WriteLine(temp);

7 / 15

Which of the following statements is correct about Managed Code?

8 / 15

All code inside finally block is guaranteed to execute irrespective of whether an exception occurs in the protected block or not.

9 / 15

In C#.NET if we do not catch the exception thrown at runtime then which of the following will catch it?

10 / 15

If a namespace is present in a library then which of the following is the correct way to use the elements of the namespace?

11 / 15

Which of the following is the correct output for the C#.NET code snippet given below?


enum color: int

{

red,

green,

blue = 5,

cyan,

magenta = 10,

yellow

}

Console.Write( (int) color.green + “, ” );

Console.Write( (int) color.yellow );


 

12 / 15

Once applied which of the following CANNOT inspect the applied attribute?

13 / 15

Which of the following statements are correct about delegates?

14 / 15

What is the output of the C#.NET code snippet given below?


namespace IndiaConsoleApplication

{

public enum color

{ red, green, blue };

class SampleProgram

{

static void Main (string[ ] args)

{

color c = color.blue;

switch (c)

{

case color.red:

Console.WriteLine(color.red);

break;

case color.green:

Console.WriteLine(color.green);

break;

case color.blue:

Console.WriteLine(color.blue);

break;

}

}

}

}


 

15 / 15

In which of the following should the methods of a class differ if they are to be treated as overloaded methods?

  1. Type of arguments
  2. Return type of methods
  3. Number of arguments
  4. Names of methods
  5. Order of arguments

Your score is

The average score is 27%

0%

0%

C# Programming Test 3

1 / 15

Which of the following modifier is used when a virtual method is redefined by a derived class?

2 / 15

Which of the followings are NOT a .NET namespace?

  1. Web
  2. Process
  3. Data
  4. Drawing2D
  5. System.Drawing3D

3 / 15

Which of the following will be the correct output for the C#.NET code snippet given below?


String s1 = “Five Star”;

String s2 = “FIVE STAR“;

int c;

c = s1.CompareTo(s2);

Console.WriteLine(c);


 

4 / 15

Which of the following statements are correct about the C#.NET code snippet given below?


int[] a = {11, 3, 5, 9, 4};


  1. The array elements are created on the stack.
  2. Refernce a is created on the stack.
  3. The array elements are created on the heap.
  4. On declaring the array a new array class is created which is derived from System.Array Class.
  5. Whether the array elements are stored in the stack or heap depends upon the size of the array.

5 / 15

Which of the following is correct about the C#.NET snippet given below?


namespace IndiaConsoleApplication

{

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);

}

}

}


 

6 / 15

Which of the following statements is correct?

7 / 15

Which of the following is NOT an Arithmetic operator in C#.NET?

8 / 15

Which of the following statements is correct about the .NET Framework?

9 / 15

Attributes can be applied to

  1. Method
  2. Class
  3. Assembly
  4. Namespace
  5. Enum

10 / 15

Which of the following statements are valid about generics in .NET Framework?

  1. Generics is a language feature.
  2. We can create a generic class, however, we cannot create a generic interface in C#.NET.
  3. Generics delegates are not allowed in C#.NET.
  4. Generics are useful in collection classes in .NET framework.
  5. None of the above

11 / 15

Which of the following statements are correct about a delegate?

  1. Inheritance is a prerequisite for using delegates.
  2. Delegates are type-safe.
  3. Delegates provide wrappers for function pointers.
  4. The declaration of a delegate must match the signature of the method that we intend to call using it.
  5. Functions called using delegates are always late-bound.

12 / 15

Which of the following is the necessary condition for implementing delegates?

13 / 15

Which of the following statements is correct?

14 / 15

A function can be used in an expression, whereas a subroutine cannot be.

15 / 15

Which of the following statements are correct about the Bitwise & operator used in C#.NET?

  1. The &operator can be used to Invert a bit.
  2. The &operator can be used to put ON a bit.
  3. The &operator can be used to put OFF a bit.
  4. The &operator can be used to check whether a bit is ON.
  5. The & operator can be used to check whether a bit is OFF.

Your score is

The average score is 47%

0%

0%

C# Programming Test 4

1 / 15

Which of the following statements correctly define .NET Framework?

2 / 15

Which of the following statements are TRUE about the .NET CLR?

  1. It provides a language-neutral development & execution environment.
  2. It ensures that an application would not be able to access memory that it is not authorized to access.
  3. It provides services to run “managed” applications.
  4. The resources are garbage collected.
  5. It provides services to run “unmanaged” applications

3 / 15

Which of the following statements is correct about properties used in C#.NET?

4 / 15

Which of the following will be the correct output for the C#.NET code snippet given below?


enum color : int

{

red = -3,

green,

blue

}

Console.Write( (int) color.red + “, “);

Console.Write( (int) color.green + “, “);

Console.Write( (int) color.blue );


 

5 / 15

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);


 

6 / 15

Which of the following are NOT Relational operators in C#.NET?

  1. >=
  2. !=
  3. Not
  4. <=
  5. <>=

7 / 15

Which of the following is the correct output for the C#.NET program given below?


int i = 20 ;

for( ; ; )

{

Console.Write(i + ” “);

if (i >= -10)

i -= 4;

else

break;

}


 

8 / 15

Which of the following statements is correct?

9 / 15

Which of the following statements is correct about an Exception?

10 / 15

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?

11 / 15

Which of the following will be the correct output for the C#.NET code snippet given below?

 

String s1 = “ALL MEN ARE CREATED EQUAL”;

String s2;

s2 = s1.Substring(12, 3);

Console.WriteLine(s2);

12 / 15

Multiple inheritance is different from multiple levels of inheritance.

13 / 15

Which of the following statements are correct about static functions?

  1. Static functions can access only static data.
  2. Static functions cannot call instance functions.
  3. It is necessary to initialize static data.
  4. Instance functions can call static functions and access static data.
  5. this reference is passed to static functions.

14 / 15

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));


 

15 / 15

Which of the following assemblies can be stored in Global Assembly Cache?

Your score is

The average score is 38%

0%

0%

C# Programming Test 5

1 / 15

Which of the following statements is correct about an interface?

2 / 15

Which of the following is the Object Oriented way of handling run-time errors?

3 / 15

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

4 / 15

Which of the following can be facilitated by the Inheritance mechanism?

  1. Use the existing functionality of base class.
  2. Overrride the existing functionality of base class.
  3. Implement new functionality in the derived class.
  4. Implement polymorphic behaviour.
  5. Implement containership.

5 / 15

The this reference gets created when a member function (non-shared) of a class is called.

6 / 15

What will be the output of the C#.NET code snippet given below?


byte b1 = 0xF7;

byte b2 = 0xAB;

byte temp;

temp = (byte)(b1 & b2);

Console.Write (temp + ” “);

temp = (byte)(b1^b2);

Console.WriteLine(temp);


 

7 / 15

What will be the output of the code snippet given below?


int i;

for(i = 0; i<=10; i++) {    if(i == 4)

{

Console.Write(i + ” “); continue;

}

else if (i != 4)

Console.Write(i + ” “); else

   break;

}


 

8 / 15

Which of the following statements are correct about an interface used in C#.NET?

  1. An interface can contain properties, methods and events.
  2. The keyword must implement forces implementation of an interface.
  3. Interfaces can be overloaded.
  4. Interfaces can be implemented by a class or a struct.
  5. Enhanced implementations of an interface can be developed without breaking existing code.

9 / 15

Which of the following statements is correct about an interface used in C#.NET?

10 / 15

It is compulsory for all classes whose objects can be thrown with throw statement to be derived from System.Exception class.

11 / 15

Which of the following statements is correct about a namespace in C#.NET?

12 / 15

Which of the following CANNOT be a target for a custom attribute?

13 / 15

It is illegal to make objects of one class as members of another class.

14 / 15

Which of the following constitutes the .NET Framework?

  1. NET Applications
  2. CLR
  3. Framework Class Library
  4. WinForm Applications
  5. Windows Services

15 / 15

How many values is a function capable of returning?

Your score is

The average score is 30%

0%

Get up to 100% Scholarship to get Package up to 40 LPA Register Now
+ +