Explore topic-wise MCQs in General Awareness.

This section includes 1698 Mcqs, each offering curated multiple-choice questions to sharpen your General Awareness knowledge and support exam preparation. Choose a topic below to get started.

1151.

What will be the output of the given code snippet below? { delegate string F(string str); class sample { public static string fun(string a) { return a.Replace(',''-'); } } class Program { static void Main(string[] args) { F str1 = new F(sample.fun); string str = str1("Test Your c#.NET skills"); Console.WriteLine(str); } } }

A. Test Your
B. Test-Your-C#.NET-Skills
C. Ur C#.NET Skills
D. None of the mentioned
Answer» C. Ur C#.NET Skills
1152.

What will be the output of given set of code? { delegate string f(string str); class sample { public static string fun(string a) { return a.Replace('k', 'o'); } } class Program { static void Main(string[] args) { f str1 = new f(sample.fun); string str = str1("Test Ykur C#.NET Skills"); Console.WriteLine(str); Console.ReadLine(); } } }

A. Test Ykur C#.NET Skills
B. Test Ykour C#.NET Skills
C. Test Your C#.NET Skills
D. Test ur C#.NET Skills
Answer» D. Test ur C#.NET Skills
1153.

What does the following code block defines? class Gen { T ob; }

A. Generics class declaration
B. Generic constructor declaration
C. A simple class declaration
D. All of the mentioned
Answer» B. Generic constructor declaration
1154.

What does the following code set defines? public Gen(T o) { ob = o; }

A. Generics class decleration
B. Declaration of variable
C. Generic constructor declaration
D. All of the mentioned
Answer» D. All of the mentioned
1155.

For the code snippet shown below, which of the following statements are valid? public class Generic { public T Field; public void TestSub() { T i = Field + 1; } } class MyProgram { static void Main(string[] args) { Generic gen = new Generic(); gen.TestSub(); } }

A. Addition will produce result 1.
B. Result of addition is system-dependent.
C. Program will generate run-time exception.
D. 0
Answer» E.
1156.

Which of the following statements are valid about generics in .NET Framework? 1. Generics is a language feature. 2. We can create a generic class, however, we cannot create a generic interface in C#.NET. 3. Generics delegates are not allowed in C#.NET. 4. Generics are useful in collection classes in .NET framework. 5. None of the above

A. 1 and 2 Only
B. 1, 2 and 3 Only
C. 1 and 4 Only
D. All of the above
Answer» D. All of the above
1157.

For the code snippet shown below, which of the following statements are valid? public class TestMcqsMentor { public void TestSub (M arg) { Console.Write(arg); } } class MyProgram { static void Main(string[] args) { TestMcqsMentor Bits = new TestMcqsMentor(); Bits.TestSub("TestMcqsMentor"); Bits.TestSub(4.2f); } }

A. Program will compile and on execution will print: TestMcqsMentor4.2
B. A non generic class Hello cannot have generic subroutine.
C. Compiler will generate an error.
D. Program will generate a run-time exception.
Answer» B. A non generic class Hello cannot have generic subroutine.
1158.

Which of the following statements is valid about advantages of generics? public class Generic { public T Field; } class Program { static void Main(string[ ] args) { Generic g = new Generic(); g.Field = "Hello"; Console.WriteLine(g.Field); } }

A. Generics shift the burden of type safety to the programmer rather than compiler.
B. Generics require use of explicit type casting.
C. Generics provide type safety without the overhead of multiple implementations.
D. Generics eliminate the possibility of run-time errors.
Answer» D. Generics eliminate the possibility of run-time errors.
1159.

Select the correct implementation of the interface which is mentioned below. interface a1 { int fun(int i); }

A. class a { int fun(int i) as a1.fun { } }
B. class a: implements a1 { int fun(int i) { } }
C. class a: a1 { int a1.fun(int i) { } }
D. None of the mentioned
Answer» D. None of the mentioned
1160.

Correct statement about c#.NET code snippet given below is? interface a1 { void f1(); int f2(); } class a :a1 { void f1() { } int a1.f2() { } }

A. Class a is an abstract class
B. A method table would not be created for class a
C. The definition of f1() in class a should be void a1.f1()
D. None of the mentioned
Answer» D. None of the mentioned
1161.

Choose the correct statement about following code snippet given below: interface a1 { void f1(); void f2(); } class a :a1 { private int i; void a1.f1() { } }

A. Class a could not have an instance data
B. Class a is an abstract class
C. Class a fully implements the interface a1
D. None of the mentioned
Answer» C. Class a fully implements the interface a1
1162.

What will be the output of the given code snippet? interface calc { void cal(int i); } public class maths :calc { public int x; public void cal(int i) { x = i * i; } } class Program { public static void Main(string[] args) { display arr = new display(); arr.x = 0; arr.cal(2); Console.WriteLine(arr.x); Console.ReadLine(); } }

A. 0
B. 2
C. 4
D. None of the mentioned
Answer» D. None of the mentioned
1163.

What will be the output of the given code snippet? interface calc { void cal(int i); } class displayA :calc { public int x; public void cal(int i) { x = i * i; } } class displayB :calc { public int x; public void cal(int i) { x = i / i; } } class Program { public static void Main(string[] args) { displayA arr1 = new displayA(); displayB arr2 = new displayB(); arr1.x = 0; arr2.x = 0; arr1.cal(2); arr2.cal(2); Console.WriteLine(arr1.x + " " + arr2.x); Console.ReadLine(); } }

A. 0 0
B. 2 2
C. 4 1
D. 1 4
Answer» D. 1 4
1164.

Correct way to implement the interface given below? interface abc { string name { get; set; } } a) class emp :employee { private string str; public string firstname; { get { return str; } set { str = value; } } } b) class emp :implements person { private string str; public string firstname { get { return str; } set { str = value; } } } c) class emp: implements person { private string str; public string person.firstname { get { return str; } set { str = value; } } }

A. A
B. B
C. C
D. None of the mentioned
Answer» B. B
1165.

In order to avoid ambiguity among an interface derived from two base interfaces with same method name(and signature), the right code among the following given codes is? a) interface i1 { void m1(); } interface i2 { void m1(); } interface i3 :i1, i2 { } class c3 :i3 { void i1.m1() { } void i1.m1() { } } b) interface i1 { void m1(); } interface i2 { void m1(); } interface i3 :i1, i2 { } class c3 :i3 { void i1.i2.m1() { } } c) interface i1 { void m1(); } interface i2 { void m1(); } interface i3 :i1, i2 { } class c3 :i3 { void i1.m1() { } void i2.m1() { } }

A. A
B. B
C. C
D. All of the mentioned
Answer» D. All of the mentioned
1166.

Arrange the following overloaded operators in increasing order of precedence? %, <

A. % < <
B. <
C. & < -
D. / < - < % < + < <
Answer» C. & < -
1167.

Correct way to define operator method or to perform operator overloading is?

A. public static op(arglist) { }
B. public static retval op(arglist) { }
C. public static retval operator op(arglist) { }
D. All of the mentioned
Answer» D. All of the mentioned
1168.

Choose the correct statement about the following code snippet in C#.NET: interface abc { String FirstName { get; set; } String LastName { get; set; } void print(); void stock(); int fun(); }

A. Functions should be declared inside an interface
B. It is workable code
C. Properties cannot be declared inside an interface
D. None of the mentioned
Answer» C. Properties cannot be declared inside an interface
1169.

What will be the correct output for the given code snippet? class recursion { int fact(int n) { int result; if (n == 1) return 1; result = fact(n - 1) * n; return result; } } class Program { public static void main(String args[]) { recursion obj = new recursion() ; Console.WriteLine(obj.fact(4)); } }

A. 24
B. 30
C. 120
D. 144
Answer» B. 30
1170.

What will be the correct output the for the given code snippet? class maths { int fact(int n) { int result; if (n == 1) return 1; result = fact(n - 1) * n; return result; } } class Output { static void main(String args[]) { maths obj = new maths() ; Console.WriteLine(obj.fact(1)); } }

A. 2
B. 10
C. 1
D. 0
Answer» D. 0
1171.

What will be the correct output for the given code snippet? class maths { int fact(int n) { int result; if (n == 1) return 1; result = fact(n - 1) * n; return result; } } class Output { static void main(String args[]) { maths obj = new maths() ; Console.WriteLine(obj.fact(4)*obj.fact(2)); } }

A. 64
B. 60
C. 120
D. 48
Answer» E.
1172.

What will be the correct output for the given code snippet? class maths { int fact(int n) { int result; if (n == 1) return 1; result = fact(n - 1) * n; return result; } } class Output { static void main(String args[]) { maths obj = new maths() ; Console.WriteLine(obj.fact(4)*(3)); } }

A. 64
B. 60
C. 72
D. 84
Answer» D. 84
1173.

What will be the output of the given code snippet? class maths { public int fact(int n) { int result; result = fact(n - 1) * n; return result; } } class Program { static void Main(string[] args) { maths obj = new maths(); Console.WriteLine(obj.fact(4)); Console.ReadLine(); } }

A. 24
B. 30
C. Compile time error
D. Runtime Error
Answer» E.
1174.

What will be the correct output for the given code snippet? class maths { public int fact(int n) { int result; if (n == 2) return 1; result = fact(n - 1) * n; return result; } } class Program { static void Main(string[] args) { maths obj = new maths(); Console.WriteLine(obj.fact(4)); Console.ReadLine(); } }

A. 24
B. 0
C. 12
D. 1
Answer» D. 1
1175.

Which of the following statements are correct? 1. All operators in C#.NET can be overloaded. 2. We can use the new modifier to modify a nested type if the nested type is hiding another type. 3. In case of operator overloading all parameters must be of the different type than the class or struct that declares the operator. 4. Method overloading is used to create several methods with the same name that performs similar tasks on similar data types. 5. Operator overloading permits the use of symbols to represent computations for a type.

A. 1, 3
B. 2, 4
C. 2, 5
D. 3, 4
Answer» D. 3, 4
1176.

Select the output for the given set of code? public class sample { public static int x = 100; public static int y = 150; } public class newspaper :sample { new public static int x = 1000; static void Main(string[] args) { console.writeline(sample.x + " " + sample.y + " " + x); } }

A. 100 150 1000
B. 1000 150 1000
C. 100 150 1000
D. 100 150 100
Answer» D. 100 150 100
1177.

Correct way to overload + operator?

A. Public sample operator + ( sample a, sample b)
B. Public static sample operator + (sample a, sample b)
C. Public static sample operator + (sample a, sample b)
D. All of the mentioned
Answer» E.
1178.

Correct statement about C# code is? public class maths { public int x; public virtual void a() { } } public class subject : maths { new public void a() { } }

A. The subject class version of a() method gets called using sample class reference which holds subject class object
B. Subject class hides a() method of base class
C. The code replaces the subject class version of a() with its math class version
D. None of the mentioned
Answer» E.
1179.

Correct code to be added for overloaded operator for C# .net code given below is? class csharp { int x, y, z; public csharp() { } public csharp(int a ,int b ,int c) { x = a; y = b; z = c; } Add correct set of code here public void display() { console.writeline(x + " " + y + " " + z); } class program { static void Main(String[] args) { csharp s1 = new csharp(5 ,6 ,8); csharp s3 = new csharp(); s3 = - s1; s3.display(); } } } a) public static csharp operator -(csharp s1) { csharp t = new csharp(); t.x = s1.x; t.y = s1.y; t.z = -s1.z; return t; } b) public static csharp operator -(csharp s1) { csharp t = new csharp(); t.x = s1.x; t.y = s1.y; t.z = s1.z; return t; } c) public static csharp operator -(csharp s1) { csharp t = new csharp(); t.x = -s1.x; t.y = -s1.y; t.z = -s1.z; return t; }

A. A
B. B
C. C
D. None of the mentioned
Answer» D. None of the mentioned
1180.

Which of the following is a correct statement about the C#.NET code given below? struct book { private String name; private int pages; private Single price; } book b = new book();

A. New structure can be inherited from struct book
B. When the program terminates, variable b will get garbage collected
C. The structure variable b will be created on the stack
D. When the program terminates, variable b will get garbage collected
Answer» D. When the program terminates, variable b will get garbage collected
1181.

Which of the following is a correct statement about the C#.NET code given below? class trial { int i; float d; } struct sample { private int x; private Single y; private trial z; } sample s = new sample();

A. Trial object referred by z is created on the stack
B. Z is created on the heap
C. Both s and z will be created on the heap
D. S will be created on the stack
Answer» E.
1182.

Which of the following statement is correct about the C#.NET code snippet given below? public class Sample { public int x; public virtual void fun() { } } public class DerivedSample : Sample { new public void fun() { } }

A. DerivedSample class hides the fun() method of base class.
B. The DerivedSample class version of fun() method gets called using Sample class reference which holds DerivedSample class object.
C. The code replaces the DerivedSample class version of fun() method with its Sample class version.
D. It is not possible to hide Sample class version of fun() method without use of new in DerivedSample class.
Answer» B. The DerivedSample class version of fun() method gets called using Sample class reference which holds DerivedSample class object.
1183.

Which of the following operators cannot be overloaded? 1. true 2. false 3. new 4. ~ 5. sizeof

A. 1, 3
B. 2, 4
C. 3, 5
D. All of the above
Answer» D. All of the above
1184.

Which of the following can be declared as a virtual in a class? 1. Methods 2. Properties 3. Events 4. Fields 5. Static fields

A. 1, 2, 3
B. 3, 5
C. 2, 4
D. 2, 3, 5
Answer» B. 3, 5
1185.

Which of the following are necessary for Run-time Polymorphism? 1. The overridden base method must be virtual, abstract or override. 2. Both the override method and the virtual method must have the same access level modifier. 3. An override declaration can change the accessibility of the virtual method. 4. An abstract inherited property cannot be overridden in a derived class. 5. An abstract method is implicitly a virtual method.

A. 1, 3
B. 1, 2, 5
C. 2, 3, 4
D. 4 only
Answer» C. 2, 3, 4
1186.

Which of the following can be facilitated by the Inheritance mechanism? 1. Use the existing functionality of base class. 2. Overrride the existing functionality of base class. 3. Implement new functionality in the derived class. 4. Implement polymorphic behaviour. 5. Implement containership.

A. 1, 2, 3
B. 3, 4
C. 2, 4, 5
D. 3, 5
Answer» B. 3, 4
1187.

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),
Answer» C. Console.WriteLine(mybase.i + " " + i),
1188.

Which of the following statements are correct about the C#.NET code snippet given below? 1. count should be declared as public if it is to become available in the inheritance chain. 2. count should be declared as protected if it is to become available in the inheritance chain. 3. While constructing an object referred to by i firstly constructor of index class will be called followed by constructor of index1 class. 4. Constructor of index class does not get inherited in index1 class. 5. count should be declared as Friend if it is to become available in the inheritance chain. namespace McqsMentorConsoleApplication { class index { protected int count; public index() { count = 0; } } class index1: index { public void increment() { count = count +1; } } class MyProgram { static void Main(string[] args) { index1 i = new index1(); i.increment(); } } }

A. 1, 2, 5
B. 2, 3, 4
C. 3, 5
D. 4, 5
Answer» C. 3, 5
1189.

What will be the size of the object created by the following C#.NET code snippet? namespace McqsMentorConsoleApplication { class Baseclass { private int i; protected int j; public int k; } class Derived: Baseclass { private int x; protected int y; public int z; } class MyProgram { static void Main (string[ ] args) { Derived d = new Derived(); } } }

A. 24 bytes
B. 12 bytes
C. 20 bytes
D. 10 bytes
Answer» B. 12 bytes
1190.

Which statement will you add in the function fun() of class B, if it is to produce the output Welcome to McqsMentor.com! ? namespace McqsMentorConsoleApplication { class A { public void fun() { Console.Write("Welcome"); } } class B: A { public void fun() { // [*** Add statement here ***] Console.WriteLine(" to McqsMentor.com!"); } } class MyProgram { static void Main (string[ ] args) { B b = new B(); b.fun(); } } }

A. Base.fun(),
B. A::fun(),
C. Fun(),
D. Mybase.fun(),
Answer» B. A::fun(),
1191.

Which of the following is the correct way to settle down values into the structure variable e defined in the following code snippet? struct emp { public String name; public int age; public Single sal; } emp e = new emp();

A. e.name = "Ankit"; e.age = 24; e.sal = 200;
B. With emp e { .name = "Ankit"; .age = 24; .sal = 200; }
C. name = "Ankit"; age = 24; sal = 200;
D. All of the mentioned
Answer» B. With emp e { .name = "Ankit"; .age = 24; .sal = 200; }
1192.

Calculate the number of bytes a structure variable s occupies in the memory if it is defined as follows. class abc { int i; Decimal d; } struct sample { private int x; private Single y; private trial z; } sample s = new sample();

A. 24 bytes
B. 8 bytes
C. 16 bytes
D. 12 bytes
Answer» E.
1193.

Which of the following is the correct result for the given statement in the C#.NET statement given below? p = q struct employee { private int employee id; private string city; } employee q = new employee(); employee p; p = q;

A. Elements of q will be copied into corresponding elements of p.
B. Address stored in q will get copied into p
C. Address of first element of q will get copied into p
D. Once assignment is over.q will go out of scope and hence get exited forever
Answer» B. Address stored in q will get copied into p
1194.

If no access modifier for a class is specified,then class accessibility is defined as?

A. Public
B. Protected
C. Private
D. Internal
Answer» D. Internal
1195.

Select the correct output for the given set of code? class sample { public int i; void display() { Console.WriteLine(i); } } class sample1 : sample { public int j; public void display() { Console.WriteLine(j); } } class Program { static void Main(string[] args) { sample1 obj = new sample1(); obj.i = 1; obj.j = 2; obj.display(); Console.ReadLine(); } }

A. 1
B. 3
C. 2
D. Compile Time error
Answer» D. Compile Time error
1196.

Correct statement about C#.NET code is?

A. Index should be declared as protected if it is to become available in inheritance chain
B. Constructor of sample class does not get inherited in sample 1 class
C. During constructing an object referred to by z, Firstly constructor of sample class will be called followed by constructor of sample 1 class
D. All of the mentioned
Answer» E.
1197.

The following set of code is run on single level of inheritance. Find correct statement about the code? class sample { int i = 10; int j = 20; public void display() { Console.WriteLine("base method "); } } class sample1 : sample { public int s = 30; } class Program { static void Main(string[] args) { sample1 obj = new sample1(); Console.WriteLine("{0}, {1}, {2}", obj.i, obj.j, obj.s); obj.display(); Console.ReadLine(); } }

A. 10, 20, 30
B. 10, 20, 0
C. Compile time error
D. Base method
Answer» D. Base method
1198.

What will be size of the object created depicted by csharp code snippet? class baseclass { private int a; protected int b; public int c; } class derived : baseclass { private int x; protected int y; public int z; } class Program { static Void Main(string[] args) { derived a = new derived(); } }

A. 20 bytes
B. 12 bytes
C. 16 bytes
D. 24 bytes
Answer» E.
1199.

The process of defining a method in subclass having same name & type signature as a method in its superclass is known as?

A. Method overloading
B. Method overriding
C. Method hiding
D. None of the mentioned
Answer» C. Method hiding
1200.

What will be the output for the given set of code? class A { public int i; public void display() { Console.WriteLine(i); } } class B: A { public int j; public void display() { Console.WriteLine(j); } } class Program { static void Main(string[] args) { B obj = new B(); obj.i = 1; obj.j = 2; obj.display(); Console.ReadLine(); } }

A. 0
B. 2
C. 1
D. Compile time error
Answer» C. 1