C# Programming - Namespaces - Discussion

Discussion Forum : 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();
1, 3
2, 4
3
4, 5
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
4 comments Page 1 of 1.

Nita said:   10 years ago
How can use 3rd option sir?

Balaji Jadhav said:   1 decade ago
Dear Sir,

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

How is it possible answer 3 please reply.

John said:   1 decade ago
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.

Raju said:   1 decade ago
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.

Post your comments here:

Your comments will be displayed after verification.