C# Test1

35 Questions | Attempts: 135
Share

SettingsSettingsSettings
C Programming Quizzes & Trivia

Questions and Answers
  • 1. 

    What is redefining a single method multiple times so that you can use the same method name, but vary the number and types of parameters?

    • A.

      Encapsulation

    • B.

      Abstaction

    • C.

      Overloading

    • D.

      Overriding

    Correct Answer
    C. Overloading
  • 2. 

    Where can polymorphism be applied?(Choose any 3 options)

    • A.

      Methods

    • B.

      Indexers

    • C.

      Properties

    • D.

      Fields

    Correct Answer(s)
    A. Methods
    B. Indexers
    C. Properties
  • 3. 

    Storage or sucket based network streams

    • A.

      Basic

    • B.

      SOAP

    • C.

      Binary

    • D.

      XML

    Correct Answer
    C. Binary
  • 4. 

    Which of the following property specifies the type of validation that the XmlValidatingReader should perform?

    • A.

      XmlReaderValidationType

    • B.

      ReaderValidationType

    • C.

      XmlValidatingReaderType

    • D.

      Validation Type

    Correct Answer
    D. Validation Type
  • 5. 

    What does FileStream objects do?

    • A.

      Exposes a file in XML Mode

    • B.

      Exposes a file in Text Mode

    • C.

      Exposes a Stream around a file, supporting synchronous and a aynchronous write

    • D.

      Exposes a Stream around a file, supporting synchronous and a synchronous read operations

    Correct Answer(s)
    C. Exposes a Stream around a file, supporting synchronous and a aynchronous write
    D. Exposes a Stream around a file, supporting synchronous and a synchronous read operations
  • 6. 

    What are your observations on the following code?(Choose any 2)    private void CheckForReferenceType<T>(T type) where T:class, IHoldVal    {     type.Val = 3;     }

    • A.

      Code denotes Reference Type Generics Constraint

    • B.

      Code denotes usage of Generics Constraint

    • C.

      Code denotes Base Class Generics Constraint

    • D.

      Code denotes Interface Generics Constraint

    Correct Answer(s)
    A. Code denotes Reference Type Generics Constraint
    D. Code denotes Interface Generics Constraint
  • 7. 

    Which of the following describes the web services, its parameters & how to use it?

    • A.

      WSDL

    • B.

      UDDI

    • C.

      XML

    • D.

      SOAP

    Correct Answer
    A. WSDL
  • 8. 

    How does the throw statement work in exception handling?

    • A.

      The throw statement terminates the execution of the program and passes the control to the finally block in the calling program

    • B.

      The throw statement raises a new exception, and the CLR unwinds the stack looking for the entry point of the program int the call chain and restarts the program

    • C.

      The throw statement attempts to pass the control to the nearest catch statement, and the CLR unwinds the stack looking for an exception handler, try/catch, in the call chain with a catch block

    • D.

      The throw statement raises a new exception, and the CLR unwinds the stack looking for an exception handler, try/catch, in the call chain with a catch block

    Correct Answer
    D. The throw statement raises a new exception, and the CLR unwinds the stack looking for an exception handler, try/catch, in the call chain with a catch block
  • 9. 

    What does SOAP Header element contain?

    • A.

      SOAP Header element contains message hierarchy

    • B.

      The SOAP Header element contains application-specific information, like authentication, payment, etc about the SOAP message

    • C.

      SOAP Header element contains definition of a message

    • D.

      SOAP Header element contains verbose description of a message

    Correct Answer
    C. SOAP Header element contains definition of a message
  • 10. 

    Which of the following exception is thrown for explicit conversions?

    • A.

      ExternalException

    • B.

      SystemException

    • C.

      InvalidOperationException

    • D.

      InvalidCastException

    Correct Answer
    D. InvalidCastException
  • 11. 

    Identify approaches that help reduce data over the network(Choose any 3)

    • A.

      Return only the columns and rows that you need

    • B.

      Return complete data

    • C.

      Provide data paging for large results

    • D.

      Cache data where possible

    Correct Answer(s)
    A. Return only the columns and rows that you need
    C. Provide data paging for large results
    D. Cache data where possible
  • 12. 

    Rearrange the stages of Garbage Collection process    1.Objects that are not referenced anymore are cleaned up    2.Garbage Collect constructs the active-object graph    3.Reset the Next Object Pointer so that the next object is allocated    4.Heap objects are compacted to eliminate heap fragmentation    

    • A.

      A.2,1,4,3

    • B.

      B.1,2,3,4

    • C.

      C.3,2,4,1

    • D.

      D.4,3,1,2

    Correct Answer
    A. A.2,1,4,3
  • 13. 

    How do you create a Client proxy class in C# for XML web service?

    • A.

      Wsdl http://hostServer/WebserviceRoot/WebServiceName.asmx?XML

    • B.

      Wsdl/WSDL <>http://hostServer/WebserviceRoot/WebServiceName.asmx<>

    • C.

      Wsdl http://hostServer/WebserviceRoot/WebServiceName.asmx?WSDL

    • D.

      Wsdl http://hostServer/WebserviceRoot/WebServiceName.asmx

    Correct Answer
    C. Wsdl http://hostServer/WebserviceRoot/WebServiceName.asmx?WSDL
  • 14. 

    Which is the exception that is thrown when a non-fatal application error occurs?

    • A.

      InvalidCastException

    • B.

      SystemException

    • C.

      StackOverflowException

    • D.

      ApplicationException

    Correct Answer
    D. ApplicationException
  • 15. 

    Which of the following statements are true about finally block? (Choose any 3)  

    • A.

      Finally block is executed even if an error occurs

    • B.

      Finally block is definately executed when leaving a try block

    • C.

      Finally block is used to perform any necessary clean-up jobs

    • D.

      Finally block is not executed if an error occurs

    Correct Answer(s)
    A. Finally block is executed even if an error occurs
    B. Finally block is definately executed when leaving a try block
    C. Finally block is used to perform any necessary clean-up jobs
  • 16. 

    What does the following code do? string contents = File.ReadAllText(fileNameWithPath):

    • A.

      Reads all contents from a text file

    • B.

      Reads all contents from a text file to the memory

    • C.

      Reads all contents from a text file to a variable

    • D.

      Reads first line from a text file

    Correct Answer
    C. Reads all contents from a text file to a variable
  • 17. 

    What are your obeservations on the following code?(Choose 2) private static object m_CustomersLock = new object(); private static List<string> m_Customers = new List<string>(); try { Monitor.Enter(m_CustomersLock); m_Customers.Add("General Electric"); }

    • A.

      Following code blocks all the threads from accessing Customer list

    • B.

      Following code ensures only a single thread is blocked from accessing Customer List

    • C.

      Lock on m_CustomersLock has to be released in a finally block

    • D.

      Extension methods are called by instance methods syntax

    • E.

      Extension methods are defined as protected methods

    • F.

      Extension methods are defined as static methods

    • G.

      Extension methods are called by static methods

    Correct Answer(s)
    D. Extension methods are called by instance methods syntax
    F. Extension methods are defined as static methods
  • 18. 

    What is the definition of polymorphism?

    • A.

      The capability to dynamically invoke methods in a class based on their type

    • B.

      Method of determining what is required by the object is contained within the object

    • C.

      An object-oriented principle relating to how one class, a derived class, can share the characteristics and behaviour from another class a base class

    • D.

      An object-oriented principle associated with hiding the internals of an object from the outside world

    Correct Answer
    A. The capability to dynamically invoke methods in a class based on their type
  • 19. 

    What does the following code denote?(Choose any 2) public class Contact { public string Name {get;set;} public string Email{get;set;} public string Address{get;set;} public string City{get;set;} protected string FullAddress() { return Address+' '+City; } } class Customer : Contact { public string FullAddress() { string fullAddress =" "; //Some statement return fullAddress; } }

    • A.

      It shows how a method in base class in hidden from the user

    • B.

      It is an example of inheritance

    • C.

      It shows how a method in base class can be used in the derived class

    • D.

      It shows how polymorphism is implemented

    Correct Answer(s)
    A. It shows how a method in base class in hidden from the user
    B. It is an example of inheritance
  • 20. 

    What are your observations on the following cod?(Choose any 2) using system; struct SimpleStruct { protected int xval; public int X { get { return xval; } set { if (value <100) xval = value; } } public void DisplayX() { Console.WriteLine("The stored values is:{0}, xval); } }

    • A.

      Struct members can be inherited

    • B.

      Following code is an example of a class

    • C.

      Struct members cannot be declared as protected

    • D.

      Following code is an example of a struct

    Correct Answer(s)
    C. Struct members cannot be declared as protected
    D. Following code is an example of a struct
  • 21. 

    Which of the following property gets the XmlReader to construct XmlValidatingReader?

    • A.

      Reader

    • B.

      XmlLang

    • C.

      ReadState

    • D.

      XmlReader

    Correct Answer
    A. Reader
  • 22. 

    Which of the following is the necessary condition for implementing delegates?

    • A.

      Class declaration

    • B.

      Inheritance

    • C.

      Run-time Polymorphism

    • D.

      Exceptions

    • E.

      Compile-time Polymorphism

    Correct Answer
    A. Class declaration
  • 23. 

    Which of the following statements are correct about the delegate declaration given below? delegate void del(int i);
    1. On declaring the delegate a class called del will get created.
    2. The signature of del need not be same as the signature of the method that we intend to call using it.
    3. The del class will be derived from the MulticastDelegate class.
    4. The method that can be called using del should not be a static method.
    5. The del class will contain a one-argument constructor and an lnvoke() method.

    • A.

      1, 2 and 3 only

    • B.

      1, 3 and 5 only

    • C.

      2 and 4 only

    • D.

      4 only

    • E.

      All of the above

    Correct Answer
    B. 1, 3 and 5 only
  • 24. 

    Which of the following is the correct way to call subroutine MyFun() of the Sample class given below? class Sample { public void MyFun(int i, Single j) { Console.WriteLine("Welcome to IndiaBIX !"); } }

    • A.

      Delegate void del(int i); Sample s = new Sample(); del d = new del(ref s.MyFun); d(10, 1.1f);

    • B.

      Delegate void del(int i, Single j); del d; Sample s = new Sample(); d = new del(ref s.MyFun); d(10, 1.1f);

    • C.

      Sample s = new Sample(); delegate void d = new del(ref MyFun); d(10, 1.1f);

    • D.

      Delegate void del(int i, Single]); Sample s = new Sample(); del = new delegate(ref MyFun); del(10, 1.1f);

    Correct Answer
    B. Delegate void del(int i, Single j); del d; Sample s = new Sample(); d = new del(ref s.MyFun); d(10, 1.1f);
  • 25. 

    Which of the following statements are correct about an ArrayList collection that implements the IEnumerable interface?
    1. The ArrayList class contains an inner class that implements the IEnumerator interface.
    2. An ArrayList Collection cannot be accessed simultaneously by different threads.
    3. The inner class of ArrayList can access ArrayList class's members.
    4. To access members of ArrayList from the inner class, it is necessary to pass ArrayList class's reference to it.
    5. Enumerator's of ArrayList Collection can manipulate the array.

    • A.

      1 and 2 only

    • B.

      1 and 3 and 4 only

    • C.

      2 and 5 only

    • D.

      All of the above

    • E.

      None of the above

    Correct Answer
    B. 1 and 3 and 4 only
  • 26. 

    In which of the following collections is the Input/Output index-based?
    1. Stack
    2. Queue
    3. BitArray
    4. ArrayList
    5. HashTable

    • A.

      1 and 2 only

    • B.

      5 only

    • C.

      3 and 4 only

    • D.

      1, 2 and 5 only

    • E.

      All of the above

    Correct Answer
    C. 3 and 4 only
  • 27. 

    In a HashTable Key cannot be null, but Value can be.

    • A.

      True

    • B.

      False

    Correct Answer
    A. True
  • 28. 

    Which of the following is the correct way to access all elements of the Queue collection created using the C#.NET code snippet given below?

    • A.

      IEnumerator e; e = q.GetEnumerator(); while (e.MoveNext()) Console.WriteLine(e.Current);

    • B.

      IEnumerable e; e = q.GetEnumerator(); while (e.MoveNext()) Console.WriteLine(e.Current);

    • C.

      IEnumerator e; e = q.GetEnumerable(); while (e.MoveNext()) Console.WriteLine(e.Current);

    • D.

      IEnumerator e; e = Queue.GetEnumerator(); while (e.MoveNext()) Console.WriteLine(e.Current);

    Correct Answer
    A. IEnumerator e; e = q.GetEnumerator(); while (e.MoveNext()) Console.WriteLine(e.Current);
  • 29. 

    Which of the following will be the correct output for the C#.NET program given below? namespace IndiabixConsoleApplication { class Sample { int i; Single j; public void SetData(int i, Single j) { i = i; j = j; } public void Display() { Console.WriteLine(i + " " + j); } } class MyProgram { static void Main(string[ ] args) { Sample s1 = new Sample(); s1.SetData(10, 5.4f); s1.Display(); } } }

    • A.

      10 5

    • B.

      10 5.4

    • C.

      10 5.400000

    • D.

      0 0

    • E.

      None of the above

    Correct Answer
    D. 0 0
  • 30. 

    Which of the following statements are correct?
    1. Data members ofa class are by default public.
    2. Data members of a class are by default private.
    3. Member functions ofa class are by default public.
    4. A private function of a class can access a public function within the same class.
    5. Member function of a class are by default private

    • A.

      1, 3, 5

    • B.

      1, 4

    • C.

      2, 4, 5

    • D.

      1, 2, 3

    • E.

      None of these

    Correct Answer
    C. 2, 4, 5
  • 31. 

    Which of the following statements are correct about the this reference?
    1. this reference can be modified in the instance member function of a class.
    2. Static functions of a class never receive the this reference.
    3. Instance member functions of a class always receive a this reference.
    4. this reference continues to exist even after control returns from an instance member function.
    5. While calling an instance member function we are not required to pass the this reference explicitly.

    • A.

      1, 4

    • B.

      2, 3, 5

    • C.

      3, 4

    • D.

      2, 5

    • E.

      None of these

    Correct Answer
    B. 2, 3, 5
  • 32. 

    Which of the following statements are correct about an interface in C#.NET?
    1. A class can implement multiple interfaces.
    2. Structures cannot inherit a class but can implement an interface.
    3. In C#.NET, : is used to signify that a class member implements a specific interface.
    4. An interface can implement multiple classes.
    5. The static attribute can be used with a method that implements an interface declaration.

    • A.

      1, 2, 3

    • B.

      2, 4

    • C.

      3, 5

    • D.

      None of the above.

    Correct Answer
    A. 1, 2, 3
  • 33. 

    Which of the following statements is correct?

    • A.

      When a class inherits an interface it inherits member definitions as well as its implementations.

    • B.

      An interface cannot contain the signature of an indexer.

    • C.

      To implement an interface member, the corresponding member in the class must be public as well as static.

    • D.

      Interfaces members are automatically public.

    Correct Answer
    D. Interfaces members are automatically public.
  • 34. 

    Which of the following statements should be added to the subroutine fun( ) if the C#.NET code snippet given below is to output 9 13? class BaseClass { protected int i = 13; } class Derived: BaseClass { int i = 9; public void fun() { // [*** Add statement here ***] } }

    • A.

      Console.WriteLine(base.i + " " + i);

    • B.

      Console.WriteLine(i + " " + base.i);

    • C.

      Console.WriteLine(mybase.i + " " + i);

    • D.

      Console.WriteLine(i + " " + mybase.i);

    • E.

      Console.WriteLine(i + " " + this.i);

    Correct Answer
    B. Console.WriteLine(i + " " + base.i);
  • 35. 

    Assume class B is inherited from class A. Which of the following statements is correct about construction of an object of class B?

    • A.

      While creating the object firstly the constructor of class B will be called followed by constructor of class A.

    • B.

      The constructor of only class B will be called.

    • C.

      The constructor of only class A will be called.

    • D.

      The order of calling constructors depends upon whether constructors in class A and class B are private or public.

    • E.

      While creating the object firstly the constructor of class A will be called followed by constructor of class B.

    Correct Answer
    E. While creating the object firstly the constructor of class A will be called followed by constructor of class B.

Quiz Review Timeline +

Our quizzes are rigorously reviewed, monitored and continuously updated by our expert board to maintain accuracy, relevance, and timeliness.

  • Current Version
  • Feb 11, 2013
    Quiz Edited by
    ProProfs Editorial Team
  • Dec 29, 2011
    Quiz Created by
    D_mahalakshmi
Back to Top Back to top
Advertisement
×

Wait!
Here's an interesting quiz for you.

We have other quizzes matching your interest.