Namespaces

Q1: 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

ANS:A - 1, 3

In the first statement along with the name space initiation we assigning variable 'b' as a new class and executing it with the specified class b. Issue for book.

In the fourth statement 4 we are declaring class and accessing with a new variable and executing with book class.  



img not found
img

For help Students Orientation
Mcqs Questions

One stop destination for examination, preparation, recruitment, and more. Specially designed online test to solve all your preparation worries. Go wherever you want to and practice whenever you want, using the online test platform.