A directory of Objective Type Questions covering all the Computer Science subjects. Here you can access and discuss Multiple choice questions and answers for various compitative exams and interviews.

1. If a namespace is present in a library then which of the following is the correct way to use the elements of the namespace?
a. Add Reference of the namespace.Use the elements of the namespace.
b. Add Reference of the namespace.Import the namespace.Use the elements of the namespace.
c. Import the namespace.Use the elements of the namespace.
d. Copy the library in the same directory as the project that is trying to use it.Use the elements of the namespace.
View Answer Report Discuss Too Difficult!
Answer: (b).Add Reference of the namespace.Import the namespace.Use the elements of the namespace.

2. Which of the following is NOT a namespace in the .NET Framework Class Library?
a. System.Process
b. System.Security
c. System.Threading
d. System.Drawing
View Answer Report Discuss Too Difficult!
Answer: (a).System.Process

3. Which of the following statments are the correct way to call the method Issue() defined in the code snippet given below?

namespace College
{
    namespace Lib
    {
        class Book
        {
            public void Issue()
            {
                // Implementation code
            }
        }
        class Journal
        {
            public void Issue()
            {
                // Implementation code
            }
        }
    }
}

1.
College.Lib.Book b = new College.Lib.Book(); 
b.Issue();

2.
Book b = new Book(); 
b.Issue();

3.
using College.Lib; 
Book b = new Book(); 
b.Issue();

4.
using College;
Lib.Book b = new Lib.Book(); 
b.Issue();

5.
using College.Lib.Book; 
Book b = new Book(); 
b.Issue();
a. 1, 3
b. 2, 4
c. 3
d. 4, 5
View Answer Report Discuss Too Difficult!
Answer: (a).1, 3

4. 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.
View Answer Report Discuss Too Difficult!
Answer: (a).Namespaces help us to control the visibility of the elements present in it.

5. 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.
View Answer Report Discuss Too Difficult!
Answer: (c).Add Reference of the library before using the Point class.

6. If a class called Point is present in namespace n1 as well as in namespace n2, then which of the following is the correct way to use the Point class?
a. namespace CompSciBitsConsoleApplication
{
class MyProgram
{
static void Main(string[] args)
{
import n1;
Point x = new Point();
x.fun();
import n2;
Point y = new Point();
y.fun();
}
}
}
b. import n1;
import n2;
namespace CompSciBitsConsoleApplication
{
class MyProgram
{
static void Main(string[] args)
{
n1.Point x = new n1.Point();
x.fun();
n2.Point y = new n2.Point();
y.fun();
}
}
}
c. namespace CompSciBitsConsoleApplication
{
class MyProgram
{
static void Main(string[] args)
{
using n1;
Point x = new Point();
x.fun();
using n2;
Point y = new Point();
y.fun();
}
}
}
d. using n1;
using n2;
namespace CompSciBitsConsoleApplication
{
class MyProgram
{
static void Main(string[] args)
{
n1.Point x = new n1.Point();
x.fun();
n2.Point y = new n2.Point();
y.fun();
}
}
}
View Answer Report Discuss Too Difficult!
Answer: (d).using n1;
using n2;
namespace CompSciBitsConsoleApplication
{
class MyProgram
{
static void Main(string[] args)
{
n1.Point x = new n1.Point();
x.fun();
n2.Point y = new n2.Point();
y.fun();
}
}
}

7. Which of the followings are NOT a .NET namespace?

1. System.Web
2. System.Process
3. System.Data
4. System.Drawing2D
5. System.Drawing3D
a. 1, 3
b. 2, 4, 5
c. 3, 5
d. 1, 2, 3
View Answer Report Discuss Too Difficult!
Answer: (b).2, 4, 5

8. Which of the following statements is correct about namespaces in C#.NET?
a. Namespaces can be nested only up to level 5.
b. A namespace cannot be nested.
c. There is no limit on the number of levels while nesting namespaces.
d. If namespaces are nested, then it is necessary to use using statement while using the elements of the inner namespace.
View Answer Report Discuss Too Difficult!
Answer: (c).There is no limit on the number of levels while nesting namespaces.

9. Which of the following is correct way to rewrite the C#.NET code snippet given below?

using Microsoft.VisualBasic;
using System.Windows.Forms;
MessageBox.Show("Wait for a" + ControlChars.CrLf + "miracle");
a. using System.Windows.Forms;
using CtrlChars = Microsoft.VisualBasic.ControlChars;
MessageBox.Show("Wait for a" + CrLf + "miracle");
b. using Microsoft.VisualBasic;
using System.Windows.Forms;
CtrlChars = ControlChars;
MessageBox.Show("Wait for a" + CtrlChars.CrLf + "miracle");
c. using Microsoft.VisualBasic;
using System.Windows.Forms;
CtrlChars = ControlChars;
MessageBox.Show ("Wait for a" + CrLf + "miracle");
d. using System.Windows.Forms;
using CtrlChars = Microsoft.VisualBasic.ControlChars;
MessageBox.Show("Wait for a" + CtrlChars.CrLf + "miracle");
View Answer Report Discuss Too Difficult!
Answer: (d).using System.Windows.Forms;
using CtrlChars = Microsoft.VisualBasic.ControlChars;
MessageBox.Show("Wait for a" + CtrlChars.CrLf + "miracle");

10. Which of the following statements is correct about the using statement used in C#.NET?
a. using statement can be placed anywhere in the C#.NET source code file.
b. It is permitted to define a member at namespace level as a using alias.
c. A C#.NET source code file can contain any number of using statement.
d. By using using statement it is possible to create an alias for the namespace but not for the namespace element.
View Answer Report Discuss Too Difficult!
Answer: (c).A C#.NET source code file can contain any number of using statement.

Page 1 of 5