C#.NET objective type questions and answers

1. Which of the following statements are correct?
a. An argument passed to a ref parameter need not be initialized first. (False!)
b. Variables passed as out arguments need to be initialized prior to being passed. (False!)
c. Argument that uses params keyword must be the last argument of variable argument list of a method. (True)
d. Pass by reference eliminates the overhead of copying large data items. (True)
e. To use a ref parameter only the calling method must explicitly use the ref keyword. (False!)
Correct answers: c, d
Not answered
2. Which of the following statements are correct about functions and subroutines used in C#.NET?
a. A function cannot be called from a subroutine. (False!)
b. The ref keyword causes arguments to be passed by reference. (True)
c. While using ref keyword any changes made to the parameter in the method will be reflected in that variable when control passes back to the calling method. (True)
d. A subroutine cannot be called from a function. (False!)
e. Functions and subroutines can be called recursively. (True)
Correct answers: b, c, e
Not answered
3. Which of the following statements are correct?
a. C# allows a function to have arguments with default values. (False!)
b. C# allows a function to have variable number of arguments. (True)
c. Omitting the return value type in method definition results into an exception. (False!)
d. Redefining a method parameter in the method's body causes an exception. (False!)
e. params is used to specify the syntax for a function with variable number of arguments. (True)
Correct answers: b, e
Not answered
4. Which of the following statements are correct about functions used in C#.NET?
a. Function definitions cannot be nested. (True)
b. Functions can be called recursively. (True)
c. If we do not return a value from a function then a value -1 gets returned. (False!)
d. To return the control from middle of a function exit function should be used. (False!)
e. Function calls can be nested. (True)
Correct answers: a, b, e
Not answered
5. How many values is a function capable of returning?
a. 1 (True)
b. 0 (False!)
c. Depends upon how many params arguments does it use. (False!)
d. Any number of values. (False!)
e. Depends upon how many ref arguments does it use. (False!)
Correct answers: a
Not answered
6. How many values is a subroutine capable of returning?
a. Depends upon how many params arguments does it use. (False!)
b. Any number of values. (False!)
c. Depends upon how many ref arguments does it use. (False!)
d. 0 (True)
e. 1 (False!)
Correct answers: d
Not answered
7. Which of the following CANNOT occur multiple number of times in a program?
a. namespace (False!)
b. Entrypoint (True)
c. class (False!)
d. function (False!)
e. Subroutine (False!)
Correct answers: b
Not answered
8. Which of the following statements are correct about subroutines used in C#.NET?
a. If we do not return a value from a subroutine then a value -1 gets returned. (False!)
b. Subroutine definitions cannot be nested. (True)
c. Subroutine can be called recursively. (True)
d. To return the control from middle of a subroutine exit subroutine should be used. (False!)
e. Subroutine calls can be nested. (True)
Correct answers: b, c, e
Not answered
9. Which of the following can be facilitated by the Inheritance mechanism?
a. Use the existing functionality of base class. (True)
b. Overrride the existing functionality of base class. (True)
c. Implement new functionality in the derived class. (True)
d. Implement polymorphic behaviour. (False!)
e. Implement containership. (False!)
Correct answers: a, b, c
Not answered
10. Which of the following should be used to implement a 'Has a' relationship between two entities?
a. Polymorphism (False!)
b. Templates (False!)
c. Containership (True)
d. Encapsulation (False!)
e. Inheritance (False!)
Correct answers: c
Not answered
11. Which of the following are reuse mechanisms available in C#.NET?
a. Inheritance (True)
b. Encapsulation (False!)
c. Templates (False!)
d. Containership (True)
e. Polymorphism (False!)
Correct answers: a, d
Not answered
12. Which of the following should be used to implement a 'Like a' or a 'Kind of' relationship between two entities?
a. Polymorphism (False!)
b. Containership (False!)
c. Templates (False!)
d. Encapsulation (False!)
e. Inheritance (True)
Correct answers: e
Not answered
13. How can you prevent inheritance from a class in C#.NET ?
a. Declare the class as shadows. (False!)
b. Declare the class as overloads. (False!)
c. Declare the class as sealed. (True)
d. Declare the class as suppress. (False!)
e. Declare the class as override. (False!)
Correct answers: c
Not answered
14. Which of the following statements are correct about Inheritance in C#.NET?
a. A derived class object contains all the base class data. (True)
b. Inheritance cannot suppress the base class functionality. (False!)
c. A derived class may not be able to access all the base class data. (True)
d. Inheritance cannot extend the base class functionality. (False!)
e. In inheritance chain construction of object happens from base towards derived. (True)
Correct answers: a, c, e
Not answered
15. 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. (False!)
b. While creating the object firstly the constructor of class A will be called followed by constructor of class B. (True)
c. The constructor of only class B will be called. (False!)
d. The constructor of only class A will be called. (False!)
e. The order of calling constructors depends upon whether constructors in class A and class B are private or public. (False!)
Correct answers: b
Not answered
16. Which of the following statements are correct?
a. A struct can contain properties. (True)
b. A struct can contain constructors. (True)
c. A struct can contain protected data members. (False!)
d. A struct cannot contain methods. (False!)
e. A struct cannot contain constants. (False!)
Correct answers: a, b
Not answered
17. When would a structure variable get destroyed?
a. When no reference refers to it, it will get garbage collected. (False!)
b. Depends upon whether it is created using new or without using new. (False!)
c. When it goes out of scope. (True)
d. Depends upon the Project Settings made in Visual Studio.NET. (False!)
e. Depends upon whether we free it's memory using free() or delete(). (False!)
Correct answers: c
Not answered
18. Which of the following statements is correct?
a. A struct never declares a default constructor. (False!)
b. All value types in C# inherently derive from ValueType, which inherits from Object. (True)
c. A struct never declares a default destructor. (False!)
d. In C#, classes and structs are semantically same. (False!)
Correct answers: b
Not answered
19. Which of the following are true about classes and struct?
a. A class is a reference type, whereas a struct is a value type. (True)
b. Objects are created using new, whereas structure variables can be created either using new or without using new. (True)
c. A structure variable will always be created slower than an object. (False!)
d. A structure variable will die when it goes out of scope. (True)
e. An object will die when it goes out of scope. (False!)
Correct answers: a, b, d
Not answered
20. Which of the following statements are correct about Structures used in C#.NET?
a. A Structure can be declared within a procedure. (False!)
b. Structs can implement an interface but they cannot inherit from another struct. (True)
c. struct members cannot be declared as protected. (True)
d. A Structure can be empty. (True)
e. It is an error to initialize an instance field in a struct. (False!)
Correct answers: b, c, d
Not answered
   
Today's date:
Total spent time:
Total answered question:
Total unanswered question:








Post a Comment

0 Comments