Online C# Programming Test - C# Programming Test - Random

Instruction:

  • This is a FREE online test. Beware of scammers who ask for money to attend this test.
  • Total number of questions: 20.
  • Time allotted: 30 minutes.
  • Each question carries 1 mark; there are no negative marks.
  • DO NOT refresh the page.
  • All the best!

Marks : 2/20


Total number of questions
20
Number of answered questions
0
Number of unanswered questions
20
Test Review : View answers and explanation for this test.

1.
Which of the following assemblies can be stored in Global Assembly Cache?
Private Assemblies
Friend Assemblies
Shared Assemblies
Public Assemblies
Protected Assemblies
Your Answer: Option
(Not Answered)
Correct Answer: Option

2.
Which of the following security features can .NET applications avail?
  1. PIN Security
  2. Code Access Security
  3. Role Based Security
  4. Authentication Security
  5. Biorhythm Security
1, 4, 5
2, 5
2, 3
3, 4
Your Answer: Option
(Not Answered)
Correct Answer: Option

3.
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.
1, 2, 4
2, 3, 5
3, 4
3, 4, 5
None of these
Your Answer: Option
(Not Answered)
Correct Answer: Option

4.
Which of the following statements are correct about the following code snippet?
int a = 10; 
int b = 20;
bool c;
c = !(a > b);
  1. There is no error in the code snippet.
  2. An error will be reported since ! can work only with an int.
  3. A value 1 will be assigned to c.
  4. A value True will be assigned to c.
  5. A value False will be assigned to c.
1, 3
2, 4
4, 5
1, 4
None of these
Your Answer: Option
(Not Answered)
Correct Answer: Option

5.
A function returns a value, whereas a subroutine cannot return a value.
True
False
Your Answer: Option
(Not Answered)
Correct Answer: Option

6.
How can you prevent inheritance from a class in C#.NET ?
Declare the class as shadows.
Declare the class as overloads.
Declare the class as sealed.
Declare the class as suppress.
Declare the class as override.
Your Answer: Option
(Not Answered)
Correct Answer: Option
Explanation:
C#.NET allows sealed attribute to be used as a part of class statement. Classes declared with sealed keyword cannot be used as based class for other classes. Most important reason to do this world be to prevent behavior of a class to be changed in any way.

7.
Which statement will you add in the function fun() of class B, if it is to produce the output "Welcome to IndiaBIX.com!"?
namespace IndiabixConsoleApplication
{ 
    class A
    {
        public void fun()
        {
            Console.Write("Welcome");
        } 
    } 
    class B: A
    {
        public void fun()
        {
            // [*** Add statement here ***]
            Console.WriteLine(" to IndiaBIX.com!");
        } 
    } 
    class MyProgram
    { 
        static void Main (string[ ] args)
        { 
            B b = new B(); 
            b.fun();
        } 
    } 
}
base.fun();
A::fun();
fun();
mybase.fun();
A.fun();
Your Answer: Option
(Not Answered)
Correct Answer: Option

8.
Which of the following statements are correct about arrays used in C#.NET?
  1. Arrays can be rectangular or jagged.
  2. Rectangular arrays have similar rows stored in adjacent memory locations.
  3. Jagged arrays do not have an access to the methods of System.Array Class.
  4. Rectangular arrays do not have an access to the methods of System.Array Class.
  5. Jagged arrays have dissimilar rows stored in non-adjacent memory locations.
1, 2
1, 3, 5
3, 4
1, 2, 5
4, 5
Your Answer: Option
(Not Answered)
Correct Answer: Option

9.
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);
0
1
2
-1
-2
Your Answer: Option
(Not Answered)
Correct Answer: Option

10.
Which of the following will be the correct result of the statement b = a in the C#.NET code snippet given below?
struct Address
{
    private int plotno;
    private String city; 
}
Address a = new Address(); 
Address b; 
b = a;
All elements of a will get copied into corresponding elements of b.
Address stored in a will get copied into b.
Once assignment is over a will get garbage collected.
Once assignment is over a will go out of scope, hence will die.
Address of the first element of a will get copied into b.
Your Answer: Option
(Not Answered)
Correct Answer: Option

11.
Which of the following will be the correct output for the C#.NET program given below?
namespace IndiabixConsoleApplication
{ 
    struct Sample
    { 
        public int i;
    }
    class MyProgram
    { 
        static void Main(string[] args)
        {
            Sample x = new Sample(); 
            x.i = 10; 
            fun(ref x); 
            Console.Write(x.i + " ");
        }
        public static void fun(ref Sample y)
        { 
            y.i = 20;
            Console.Write(y.i + " "); 
        } 
    } 
}
20 10
10 20
10 10
20 20
None of the above
Your Answer: Option
(Not Answered)
Correct Answer: Option

12.
Creating empty structures is allowed in C#.NET.
True
False
Your Answer: Option
(Not Answered)
Correct Answer: Option

13.
Which of the following is the necessary condition for implementing delegates?
Class declaration
Inheritance
Run-time Polymorphism
Exceptions
Compile-time Polymorphism
Your Answer: Option
(Not Answered)
Correct Answer: Option

14.
Which of the following statements are correct about enum used in C#.NET?
  1. Every enum is derived from an Object class.
  2. Every enum is a value type.
  3. There does not exist a way to print an element of an enum as a string.
  4. Every enum is a reference type.
  5. The default underlying datatype of an enum is int.
1, 2, 5
1, 4
3, 5
2, 3, 4
Your Answer: Option
(Not Answered)
Correct Answer: Option

15.
How many enumerators will exist if four threads are simultaneously working on an ArrayList object?
1
3
2
4
Depends upon the Project Setting made in Visual Studio.NET.
Your Answer: Option
(Not Answered)
Correct Answer: Option

16.
Which of the following statements are correct about the Collection Classes available in Framework Class Library?
Elements of a collection cannot be transmitted over a network.
Elements stored in a collection can be retrieved but cannot be modified.
It is not easy to adopt the existing Collection classes for newtype of objects.
Elements stored in a collection can be modified only if allelements are of similar types.
They use efficient algorithms to manage the collection, thereby improving the performance of the program.
Your Answer: Option
(Not Answered)
Correct Answer: Option

17.
If ListBox is class present in System.Windows.Forms namespace, then which of the following statements are the correct way to create an object of ListBox Class?
  1. using System.Windows.Forms; 
    ListBox lb = new ListBox();
  2. using LBControl = System.Windows.Forms;
    LBControl lb = new LBControl();
  3. System.Windows.Forms.ListBox lb = new System.Windows.Forms.ListBox();
  4. using LBControl lb = new System.Windows.Forms.ListBox;
  5. using LBControl = System.Windows.Forms.ListBox; 
    LBControl lb = new LBControl();
1, 3
2, 4, 5
1, 3, 5
5 only
Your Answer: Option
(Not Answered)
Correct Answer: Option

18.
Which of the following statements are correct about the exception reported below?
Unhandled Exception: System.lndexOutOfRangeException: Index was outside the bounds of the array: at IndiabixConsoleApplication.MyProgram.SetVal(Int32 index, Int32 val) in D:\Sample\IndiabixConsoleApplication\MyProgram.cs:line 26 at IndiabixConsoleApplication.MyProgram.Main(String[] args) in D:\Sample\IndiabixConsoleApplication\MyProgram.cs:line 20
  1. The CLR failed to handle the exception.
  2. The class MyProgram belongs to the namespace MyProgram.
  3. The function SetVal() was called from Main() in line number 20.
  4. The exception occurred in line number 26 in the function SetVal()
  5. The runtime exception occurred in the project IndiabixConsoleApplication.
1 only
1 and 2 only
3, 4 and 5 only
All of the above
None of the above
Your Answer: Option
(Not Answered)
Correct Answer: Option

19.
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.
1, 2
1, 4, 5
3, 4
3 only
Your Answer: Option
(Not Answered)
Correct Answer: Option

20.
A class implements two interfaces each containing three methods. The class contains no instance data. Which of the following correctly indicate the size of the object created from this class?
12 bytes
24 bytes
0 byte
8 bytes
16 bytes
Your Answer: Option
(Not Answered)
Correct Answer: Option

*** END OF THE TEST ***
Time Left: 00:29:56
Post your test result / feedback here: