Online C# Programming Test - C# Programming Test 9

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 constitutes the .NET Framework?
  1. ASP.NET Applications
  2. CLR
  3. Framework Class Library
  4. WinForm Applications
  5. Windows Services
1, 2
2, 3
3, 4
2, 5
Your Answer: Option
(Not Answered)
Correct Answer: Option

2.
Which of the following statements are correct about the C#.NET code snippet given below?
if (age > 18 && no < 11)
    a = 25;
  1. The condition no < 11 will be evaluated only if age > 18 evaluates to True.
  2. The statement a = 25 will get executed if any one condition is True.
  3. The condition no < 11 will be evaluated only if age > 18 evaluates to False.
  4. The statement a = 25 will get executed if both the conditions are True.
  5. && is known as a short circuiting logical operator.
1, 3
2, 5
1, 4, 5
3, 4, 5
None of these
Your Answer: Option
(Not Answered)
Correct Answer: Option

3.
How many values is a function capable of returning?
1
0
Depends upon how many params arguments does it use.
Any number of values.
Depends upon how many ref arguments does it use.
Your Answer: Option
(Not Answered)
Correct Answer: Option

4.
Which of the following will be the correct output for the C#.NET program given below?
namespace IndiabixConsoleApplication
{ 
    class SampleProgram
    { 
        static void Main(string[] args)
        {
            int a = 5; 
            int s = 0, c = 0;
            Proc(a, ref s, ref c);
            Console.WriteLine(s + " " + c);
        }
        static void Proc(int x, ref int ss, ref int cc)
        {
            ss = x * x;
            cc = x * x * x;
        } 
    } 
}
0 0
25 25
125 125
25 125
None of the above
Your Answer: Option
(Not Answered)
Correct Answer: Option

5.
Which of the following statements is correct about the C#.NET code snippet given below?
class Sample
{
    private int i;
    public Single j;
    private void DisplayData()
    {
        Console.WriteLine(i + " " + j);
    }
    public void ShowData()
    {
        Console.WriteLine(i + " " + j);
    }
}
j cannot be declared as public.
DisplayData() cannot be declared as private.
DisplayData() cannot access j.
ShowData() cannot access to i.
There is no error in this class.
Your Answer: Option
(Not Answered)
Correct Answer: Option

6.
What will be the size of the object created by the following C#.NET code snippet?
namespace IndiabixConsoleApplication
{ 
    class Baseclass
    {
        private int i; 
        protected int j; 
        public int k;
    }
    class Derived: Baseclass
    {
        private int x; 
        protected int y; 
        public int z;
    }
    class MyProgram
    { 
        static void Main (string[ ] args)
        { 
            Derived d = new Derived();
        } 
    } 
}
24 bytes
12 bytes
20 bytes
10 bytes
16 bytes
Your Answer: Option
(Not Answered)
Correct Answer: Option

7.
In an inheritance chain which of the following members of base class are accessible to the derived class members?
  1. static
  2. protected
  3. private
  4. shared
  5. public
1, 3
2, 5
3, 4
4, 5
Your Answer: Option
(Not Answered)
Correct Answer: Option

8.
It is illegal to make objects of one class as members of another class.
True
False
Your Answer: Option
(Not Answered)
Correct Answer: Option

9.
Which of the following is the correct way to define a variable of the type struct Emp declared below?
struct Emp
{
    private String name; 
    private int age; 
    private Single sal;
}
  1. Emp e(); e = new Emp();
  2. Emp e = new Emp;
  3. Emp e; e = new Emp;
  4. Emp e = new Emp();
  5. Emp e;
1, 3
2, 5
4, 5
1, 2, 4
Your Answer: Option
(Not Answered)
Correct Answer: Option

10.
The space required for structure variables is allocated on stack.
True
False
Your Answer: Option
(Not Answered)
Correct Answer: Option

11.
Which of the following CANNOT be a target for a custom attribute?
Enum
Event
Delegate
Interface
Namespace
Your Answer: Option
(Not Answered)
Correct Answer: Option

12.
In which of the following collections is the Input/Output based on a key?
  1. Map
  2. Stack
  3. BitArray
  4. HashTable
  5. SortedList
1 and 2 only
2 and 3 only
1, 2 and 3 only
4 and 5 only
All of the above
Your Answer: Option
(Not Answered)
Correct Answer: Option

13.
If a class Student has an indexer, then which of the following is the correct way to declare this indexer to make the C#.NET code snippet given below work successfully?
Student s = new Student(); 
s[1, 2] = 35;
class Student
{ 
    int[ ] a = new int[5, 5]; 
    public property WriteOnly int this[int i, int j]
    { 
        set
        { 
            a[i, j] = value;
        } 
    }
}
class Student
{ 
    int[ , ] a = new int[5, 5]; 
    public int property WriteOnly
    { 
        set
        { 
            a[i, j] = value;
        } 
    } 
}
class Student
{ 
    int[ , ] a = new int[5, 5];
    public int this[int i, int j] 
    {
        set
        { 
            a[i, j] = value;
        } 
    } 
}
class Student
{ 
    int[ , ] a = new int[5, 5];
    int i, j; 
    public int this
    { 
        set
        { 
            a[i, j] = value;
        } 
    } 
}
Your Answer: Option
(Not Answered)
Correct Answer: Option

14.
Which of the following statements is correct about a namespace in C#.NET?
Namespaces help us to control the visibility of the elements present in it.
A namespace can contain a class but not another namespace.
If not mentioned, then the name 'root' gets assigned to the namespace.
It is necessary to use the using statement to be able to use an element of a namespace.
We need to organise the classes declared in Framework Class Library into different namespaces.
Your Answer: Option
(Not Answered)
Correct Answer: Option

15.
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.Program.Main(String[] args) in
D:\ConsoleApplication\Program.cs:line 14
  1. The program did not handle an exception called IndexOutOfRangeException.
  2. The program execution continued after the exception occurred.
  3. The exception occurred in line number 14.
  4. In line number 14, the program attempted to access an array element which was beyond the bounds of the array.
  5. The CLR could not handle the exception.
1 only
1, 2 and 3 only
2 and 5 only
1, 3 and 4 only
None of the above
Your Answer: Option
(Not Answered)
Correct Answer: Option

16.
It is compulsory for all classes whose objects can be thrown with throw statement to be derived from System.Exception class.
True
False
Your Answer: Option
(Not Answered)
Correct Answer: Option

17.
In order for an instance of a derived class to completely take over a class member from a base class, the base class has to declare that member as
new
base
virtual
overrides
overloads
Your Answer: Option
(Not Answered)
Correct Answer: Option

18.
Which of the following statement is correct about the C#.NET code snippet given below?
public class Sample
{
    public int x;
    public virtual void fun()
    { }
}
public class DerivedSample : Sample
{
    new public void fun()
    { }
}
DerivedSample class hides the fun() method of base class.
The DerivedSample class version of fun() method gets called using Sample class reference which holds DerivedSample class object.
The code replaces the DerivedSample class version of fun() method with its Sample class version.
It is not possible to hide Sample class version of fun() method without use of new in DerivedSample class.
Your Answer: Option
(Not Answered)
Correct Answer: Option

19.
Which of the following statements is correct about an interface used in C#.NET?
If a class implements an interface partially, then it should be an abstract class.
A class cannot implement an interface partially.
An interface can contain static methods.
An interface can contain static data.
Multiple interface inheritance is not allowed.
Your Answer: Option
(Not Answered)
Correct Answer: Option

20.
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

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