C# Programming - Namespaces - Discussion

Discussion :: Namespaces - General Questions (Q.No.3)

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

Answer: Option A

Explanation:

No answer description available for this question.

Raju said: (Oct 8, 2012)  
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.

John said: (Jun 24, 2014)  
How are the methods being called? Externally or internally? Since there are no access modifiers on the classes, the default is internal, which means that the classes, and therefore their methods, can only be accessed by the assembly itself, not an external caller.

Balaji Jadhav said: (Sep 29, 2014)  
Dear Sir,

By Doing Program I had Got That the answer 1 is correct Only,

How is it possible answer 3 please reply.

Nita said: (Oct 29, 2015)  
How can use 3rd option sir?

Post your comments here:

Name *:

Email   : (optional)

» Your comments will be displayed only after manual approval.