php mcq questions with answers


                                

Which of the folowing does an indexer allow to index in the same way as an array?

  1. A class
  2. A property
  3. A struct
  4. A function
  5. An interface

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

An Employee class has a property called age and emp is reference to a Employee object and we want the statement Console.WriteLine(emp.age) to fail. Which of the following options will ensure this functionality?

A.Declare age property with only get accessor.
B.Declare age property with only set accessor.
C.Declare age property with both get and set accessors.
D.Declare age property with get, set and normal accessors.
E.None of the above
                                

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.
E.Install the namespace in Global Assembly Cache.Use the elements of the namespace.
                                

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
E.System.Xml
                                

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