Online C# Programming Test - C# Programming Test 4



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

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

Your Answer: Option (Not Answered)

Correct Answer: Option C

Learn more problems on : .NET Framework

Discuss about this problem : Discuss in Forum


2.

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

int val;
for (val = -5; val <= 5; val++)
{
    switch (val)
    {
        case 0:
            Console.Write ("India"); 
            break;
    }
    
    if (val > 0)
        Console.Write ("B"); 
    else if (val < 0)
        Console.Write ("X");
}

A.
XXXXXIndia
B.
IndiaBBBBB
C.
XXXXXIndiaBBBBB
D.
BBBBBIndiaXXXXX
E.
Zero

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

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

Your Answer: Option (Not Answered)

Correct Answer: Option B

Learn more problems on : Functions and Subroutines

Discuss about this problem : Discuss in Forum


4.

Which of the following CANNOT occur multiple number of times in a program?

A.
namespace
B.
Entrypoint
C.
Class
D.
Function
E.
Subroutine

Your Answer: Option (Not Answered)

Correct Answer: Option B

Learn more problems on : Functions and Subroutines

Discuss about this problem : Discuss in Forum


5.

Which of the following is the correct way to create an object of the class Sample?

  1. Sample s = new Sample();
  2. Sample s;
  3. Sample s; s = new Sample();
  4. s = new Sample();

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

Your Answer: Option (Not Answered)

Correct Answer: Option A

Learn more problems on : Classes and Objects

Discuss about this problem : Discuss in Forum


6.

Which of the following statements are correct?

  1. Data members ofa 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 public function within the same class.
  5. Member function of a class are by default private.

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

Your Answer: Option (Not Answered)

Correct Answer: Option C

Learn more problems on : Classes and Objects

Discuss about this problem : Discuss in Forum


7.

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

namespace IndiabixConsoleApplication
{ 
    class Sample
    { 
        public int index; 
        public int[] arr = new int[10]; 
        
        public void fun(int i, int val)
        { 
            arr[i] = val;
        }
    }
     
    class MyProgram
    { 
        static void Main(string[] args)
        {
            Sample s = new Sample(); 
            s.index = 20; 
            Sample.fun(1, 5); 
            s.fun(1, 5); 
        } 
    } 
}

A.
s.index = 20 will report an error since index is public.
B.
The call s.fun(1, 5) will work correctly.
C.
Sample.fun(1, 5) will set a value 5 in arr[ 1 ].
D.
The call Sample.fun(1, 5) cannot work since fun() is not a shared function.
E.
arr being a data member, we cannot declare it as public.

Your Answer: Option (Not Answered)

Correct Answer: Option B

Learn more problems on : Classes and Objects

Discuss about this problem : Discuss in Forum


8.

Which of the following is the correct way to define the constructor(s) of the Sample class if we are to create objects as per the C#.NET code snippet given below?

Sample s1 = new Sample(); 
Sample s2 = new Sample(9, 5.6f);

A.
public Sample()
{
    i = 0; 
    j = 0.0f;
}
public Sample (int ii, Single jj)
{
    i = ii;
    j = jj;
}
B.
public Sample (Optional int ii = 0, Optional Single jj = 0.0f)
{
    i = ii;
    j = jj;
}
C.
public Sample (int ii, Single jj)
{
    i = ii;
    j = jj;
}
D.
Sample s;
E.
s = new Sample();

Your Answer: Option (Not Answered)

Correct Answer: Option A

Learn more problems on : Constructors

Discuss about this problem : Discuss in Forum


9.

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

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


10.

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

A.
True
B.
False

Your Answer: Option (Not Answered)

Correct Answer: Option B

Explanation:

It depends upon how the function func() has been defined in the base class. If the function func() is defined public in base class then an object of the derived class can access the function func().

Learn more problems on : Inheritance

Discuss about this problem : Discuss in Forum


11.

If s1 and s2 are references to two strings, then which of the following is the correct way to compare the two references?

A.
s1 is s2
B.
s1 = s2
C.
s1 == s2
D.
strcmp(s1, s2)
E.
s1.Equals(s2)

Your Answer: Option (Not Answered)

Correct Answer: Option E

Learn more problems on : Strings

Discuss about this problem : Discuss in Forum


12.

Creating empty structures is allowed in C#.NET.

A.
True
B.
False

Your Answer: Option (Not Answered)

Correct Answer: Option B

Learn more problems on : Structures

Discuss about this problem : Discuss in Forum


13.

Which of the following statements is incorrect about delegate?

A.
Delegates are reference types.
B.
Delegates are object oriented.
C.
Delegates are type-safe.
D.
Delegates serve the same purpose as function pointers in C and pointers to member function operators in C++.
E.
Only one method can be called using a delegate.

Your Answer: Option (Not Answered)

Correct Answer: Option E

Learn more problems on : Delegates

Discuss about this problem : Discuss in Forum


14.

Which of the following statements is incorrect about a delegate?

A.
A single delegate can invoke more than one method.
B.
Delegates can be shared.
C.
Delegate is a value type.
D.
Delegates are type-safe wrappers for function pointers.
E.
The signature of a delegate must match the signature of the method that is to be called using it.

Your Answer: Option (Not Answered)

Correct Answer: Option C

Learn more problems on : Delegates

Discuss about this problem : Discuss in Forum


15.

With which of the following can the ref keyword be used?

  1. Static data
  2. Instance data
  3. Static function/subroutine
  4. Instance function/subroutine

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

Your Answer: Option (Not Answered)

Correct Answer: Option B

Learn more problems on : Delegates

Discuss about this problem : Discuss in Forum


16.

The [Serializable()] attribute gets inspected at

A.
Compile-time
B.
Run-time
C.
Design-time
D.
Linking-time
E.
None of the above

Your Answer: Option (Not Answered)

Correct Answer: Option B

Learn more problems on : Attributes

Discuss about this problem : Discuss in Forum


17.

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.

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

Your Answer: Option (Not Answered)

Correct Answer: Option C

Learn more problems on : Attributes

Discuss about this problem : Discuss in Forum


18.

Which of the following is absolutely neccessary to use a class Point present in namespace Graph stored in library?

A.
Use fully qualified name of the Point class.
B.
Use using statement before using the Point class.
C.
Add Reference of the library before using the Point class.
D.
Use using statement before using the Point class.
E.
Copy the library into the current project directory before using the Point class.

Your Answer: Option (Not Answered)

Correct Answer: Option C

Learn more problems on : Namespaces

Discuss about this problem : Discuss in Forum


19.

Which of the following C#.NET code snippets will correctly print "Hello C#.NET"?

A.
import System; 
namespace IndiabixConsoleApplication
{ 
    class MyProgram
    { 
        static void Main(string[] args)
        { 
            Console.WriteLine("Hello C#.NET");
        } 
    } 
}
B.
using System;
namespace IndiabixConsoleApplication
{ 
    class MyProgram
    { 
        static void Main(string[ ] args)
        { 
            WriteLine("Hello C#.NET");
        } 
    } 
}
C.
using System.Console; 
namespace IndiabixConsoleApplication
{ 
    class MyProgram
    { 
        static void Main (string[ ] args)
        { 
            WriteLine("Hello C#.NET");
        } 
    } 
}
D.
using System;
namespace IndiabixConsoleApplication
{ 
    class MyProgram
    { 
        static void Main(string[] args)
        { 
            Console.WriteLine("Hello C#.NET");
        }
    }
}

Your Answer: Option (Not Answered)

Correct Answer: Option D

Learn more problems on : Namespaces

Discuss about this problem : Discuss in Forum


20.

Which of the following statements is correct?

A.
The conditional logical operators cannot be overloaded.
B.
When a binary operator is overloaded the corresponding assignment operator, if any, must be explicitly overloaded.
C.
We can use the default equality operator in an overloaded implementation of the equality operator.
D.
A public or nested public reference type does not overload the equality operator.
E.
The array indexing operator can be overloaded.

Your Answer: Option (Not Answered)

Correct Answer: Option A

Learn more problems on : Polymorphism

Discuss about this problem : Discuss in Forum


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