Online C# Programming Test - C# Programming Test 9



Loading...  Loading Test...

Instruction:

  • This is a FREE online test. DO NOT pay money to anyone to attend this test.
  • Total number of questions : 20.
  • Time alloted : 30 minutes.
  • Each question carry 1 mark, no negative marks.
  • DO NOT refresh the page.
  • All the best :-).


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

A.
1, 2
B.
2, 3
C.
3, 4
D.
2, 5

Your Answer: Option (Not Answered)

Correct Answer: Option B

Learn more problems on : .NET Framework

Discuss about this problem : Discuss in Forum


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.

A.
1, 3
B.
2, 5
C.
1, 4, 5
D.
3, 4, 5
E.
None of these

Your Answer: Option (Not Answered)

Correct Answer: Option C

Learn more problems on : Control Instructions

Discuss about this problem : Discuss in Forum


3.

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

A.
0 0
B.
25 25
C.
125 125
D.
25 125
E.
None of the above

Your Answer: Option (Not Answered)

Correct Answer: Option D

Learn more problems on : Functions and Subroutines

Discuss about this problem : Discuss in Forum


4.

How many values is a function capable of returning?

A.
1
B.
0
C.
Depends upon how many params arguments does it use.
D.
Any number of values.
E.
Depends upon how many ref arguments does it use.

Your Answer: Option (Not Answered)

Correct Answer: Option A

Learn more problems on : Functions and Subroutines

Discuss about this problem : Discuss in Forum


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

A.
j cannot be declared as public.
B.
DisplayData() cannot be declared as private.
C.
DisplayData() cannot access j.
D.
ShowData() cannot access to i.
E.
There is no error in this class.

Your Answer: Option (Not Answered)

Correct Answer: Option E

Learn more problems on : Classes and Objects

Discuss about this problem : Discuss in Forum


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

A.
24 bytes
B.
12 bytes
C.
20 bytes
D.
10 bytes
E.
16 bytes

Your Answer: Option (Not Answered)

Correct Answer: Option A

Learn more problems on : Inheritance

Discuss about this problem : Discuss in Forum


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

A.
1, 3
B.
2, 5
C.
3, 4
D.
4, 5

Your Answer: Option (Not Answered)

Correct Answer: Option B

Learn more problems on : Inheritance

Discuss about this problem : Discuss in Forum


8.

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

A.
True
B.
False

Your Answer: Option (Not Answered)

Correct Answer: Option A

Learn more problems on : Inheritance

Discuss about this problem : Discuss in Forum


9.

The space required for structure variables is allocated on stack.

A.
True
B.
False

Your Answer: Option (Not Answered)

Correct Answer: Option A

Learn more problems on : Structures

Discuss about this problem : Discuss in Forum


10.

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;

A.
1, 3
B.
2, 5
C.
4, 5
D.
1, 2, 4

Your Answer: Option (Not Answered)

Correct Answer: Option C

Learn more problems on : Structures

Discuss about this problem : Discuss in Forum


11.

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

A.
Enum
B.
Event
C.
Delegate
D.
Interface
E.
Namespace

Your Answer: Option (Not Answered)

Correct Answer: Option E

Learn more problems on : Attributes

Discuss about this problem : Discuss in Forum


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

A.
1 and 2 only
B.
2 and 3 only
C.
1, 2 and 3 only
D.
4 and 5 only
E.
All of the above

Your Answer: Option (Not Answered)

Correct Answer: Option D

Learn more problems on : Collection Classes

Discuss about this problem : Discuss in Forum


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;

A.
class Student
{ 
    int[ ] a = new int[5, 5]; 
    public property WriteOnly int this[int i, int j]
    { 
        set
        { 
            a[i, j] = value;
        } 
    }
}
B.
class Student
{ 
    int[ , ] a = new int[5, 5]; 
    public int property WriteOnly
    { 
        set
        { 
            a[i, j] = value;
        } 
    } 
}
C.
class Student
{ 
    int[ , ] a = new int[5, 5];
    public int this[int i, int j] 
    {
        set
        { 
            a[i, j] = value;
        } 
    } 
}
D.
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 C

Learn more problems on : Properties

Discuss about this problem : Discuss in Forum


14.

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

A.
Namespaces help us to control the visibility of the elements present in it.
B.
A namespace can contain a class but not another namespace.
C.
If not mentioned, then the name 'root' gets assigned to the namespace.
D.
It is necessary to use the using statement to be able to use an element of a namespace.
E.
We need to organise the classes declared in Framework Class Library into different namespaces.

Your Answer: Option (Not Answered)

Correct Answer: Option A

Learn more problems on : Namespaces

Discuss about this problem : Discuss in Forum


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.

A.
1 only
B.
1, 2 and 3 only
C.
2 and 5 only
D.
1, 3 and 4 only
E.
None of the above

Your Answer: Option (Not Answered)

Correct Answer: Option D

Learn more problems on : Exception Handling

Discuss about this problem : Discuss in Forum


16.

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

A.
True
B.
False

Your Answer: Option (Not Answered)

Correct Answer: Option B

Learn more problems on : Exception Handling

Discuss about this problem : Discuss in Forum


17.

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()
    { }
}

A.
DerivedSample class hides the fun() method of base class.
B.
The DerivedSample class version of fun() method gets called using Sample class reference which holds DerivedSample class object.
C.
The code replaces the DerivedSample class version of fun() method with its Sample class version.
D.
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 A

Learn more problems on : Polymorphism

Discuss about this problem : Discuss in Forum


18.

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

A.
new
B.
base
C.
virtual
D.
overrides
E.
overloads

Your Answer: Option (Not Answered)

Correct Answer: Option C

Learn more problems on : Polymorphism

Discuss about this problem : Discuss in Forum


19.

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

A.
If a class implements an interface partially, then it should be an abstract class.
B.
A class cannot implement an interface partially.
C.
An interface can contain static methods.
D.
An interface can contain static data.
E.
Multiple interface inheritance is not allowed.

Your Answer: Option (Not Answered)

Correct Answer: Option A

Learn more problems on : Interfaces

Discuss about this problem : Discuss in Forum


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.

A.
1, 2
B.
1, 4, 5
C.
3, 4
D.
3 only

Your Answer: Option (Not Answered)

Correct Answer: Option B

Learn more problems on : Interfaces

Discuss about this problem : Discuss in Forum


Submit your test now to view the Results and Statistics with answer explanation.