Mphasis Previous Years Solved Sample Placement Papers
-
Which keyword is used to declare an interface in C#?
A: interface
B: Interface
C: implement
D: Implement
Ans: AExplanation:
In C#, an interface can be declared using the
interface
keyword. An interface can contain declarations of methods, properties, indexers, and events. -
In C#, by default, the default interface methods are ___.
A: virtual
B: sealed
C: private
D: public
Ans: AExplanation:
In C#, by default, the default interface methods are virtual unless the
sealed
orprivate
modifier is used. -
In C#, the objects created using the
new
operator are stored in ___.A: Cache Memory
B: Stack Memory
C: Heap Memory
D: None of the above
Ans: CExplanation:
In C#, the objects created using the
new
operator are stored in Heap Memory. -
Which of the following cannot be used to declare an interface in C#?
A: Methods
B: Properties
C: Events
D: Structures
Ans: DExplanation:
In C#, to declare an interface, we cannot use structures.
-
Which access specifier is used in an interface in C#?
A: private
B: public
C: protected
D: All of the above
Ans: BExplanation:
In C#, the interface members are always public, because the purpose of an interface is to enable other types to access a class or struct. No other access modifiers can be applied to interface members.
-
Which type of class does not have its own objects but acts as a base class for its subclass in C#?
A: Abstract Class
B: Static Class
C: Sealed Class
D: Protected Class
Ans: AExplanation:
In C#, the Abstract Class does not have its own objects but acts as a base class for its subclass.
-
Which modifier is used while redefining an abstract method by a derived class in C#?
A: Overloads
B: New
C: Overrides
D: Virtual
Ans: CExplanation:
In C#, the
Overrides
modifier is used while redefining an abstract method by a derived class. -
Does C# support pointers?
A: Yes
B: No
Ans: AExplanation:
Yes, C# supports pointers to a limited extent.
-
A C# pointer is used to store the ___ of another type.
A: Value
B: Memory address
C: Size of the type
D: Reference of the variable
Ans: BExplanation:
A C# pointer is used to store the memory address of another type.
-
C# pointers can only be declared to hold the memory address of ___.
A: value types and arrays
B: reference types
C: pointer types
D: reference and pointer types
Ans: AExplanation:
C# pointers can only be declared to hold the memory address of value types and arrays. Unlike reference types, pointer types are not tracked by the garbage collection mechanism.
-
How many catch blocks can be used with a single try block in C#?
A: One
B: Two
C: Many
D: None of the above
Ans: CExplanation:
In C#, there can be multiple (many) catch blocks with a single try block.
-
Is the use of a return statement necessary in every function in C#?
A: Yes
B: No
Ans: AExplanation:
Yes, the use of a return statement is necessary in every function in C#.
-
Which access specifier should be used for the Main() method in C#?
A: private
B: public
C: protected
D: internal
Ans: BExplanation:
The C# Main() method should be defined as public because it is called by runtime. By default, the Main() method is private.
-
In C#, a namespace is a collection of classes?
A: True
B: False
Ans: AExplanation:
Yes, a namespace is a collection of classes.
-
Which is the C# class from which the UInt data type is derived?
A: System.Int16
B: System.Int32
C: System.UInt16
D: System.UInt32
Ans: DExplanation:
The UInt data type is derived from the
System.UInt32
class. -
Which is the first line of a C# program?
A: using System;
B: using system;
C: using Namespace;
D: namespace MyApplication
Ans: AExplanation:
The first line of a C# program is:
using System;