

MCQOPTIONS
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.
1601. |
DIFFERENCE BETWEEN KEYWORDS VAR AND DYNAMIC ? |
A. | Var is introduced in C# (3.0) and Dynamic is introduced in C# (4.0) |
B. | Var is a type of variable where declaration is done at compile time by compiler while Dynamic declaration is achieved at runtime by compiler |
C. | For Var Error is caught at compile time and for Dynamic Error is caught at runtime |
D. | All of the mentioned |
Answer» E. | |
1602. |
Are the given codes :
1. Myclass class; Myclass class2 = null; 2. int i; int j = 0; |
A. | True for (1),False for (2) |
B. | True for (2),False for (1) |
C. | Both (1) and (2) are equivalents |
D. | Both (1) and (2) are not equivalents |
Answer» D. Both (1) and (2) are not equivalents | |
1603. |
What is the output of following set of code ?
int a,b; a = (b = 10) + 5; |
A. | B = 10, a = 5 |
B. | B = 15, a = 5 |
C. | A = 15, b = 10 |
D. | A = 10, b = 10 |
Answer» D. A = 10, b = 10 | |
1604. |
What will be output of the following conversion ?
static void Main(string[] args) { char a = 'A'; string b = "a"; Console.WriteLine(Convert.ToInt32(a)); Console.WriteLine(Convert.ToInt32(Convert.Tochar(b))); Console.ReadLine(); } |
A. | 1, 97 |
B. | 65, 97 |
C. | 65, 97 |
D. | 97, 1 |
Answer» D. 97, 1 | |
1605. |
Select output of the given set of Code :
static void Main(string[] args) { String name = "Dr.Gupta"; Console.WriteLine("Good Morning" + name); } |
A. | Dr.Gupta |
B. | Good Morning |
C. | Good Morning Dr.Gupta |
D. | Good Morning name |
Answer» D. Good Morning name | |
1606. |
Select output for the following set of code.
static void Main(string[] args) { int a = 5; int b = 10; int c; Console.WriteLine(c = a-- - ++b); Console.WriteLine(b); Console.ReadLine(); } |
A. | -7, 10 |
B. | -5, 11 |
C. | -6, 11 |
D. | 15, 11 |
Answer» D. 15, 11 | |
1607. |
Select output for the following set of code .
static void Main(string[] args) { const int a = 5; const int b = 6; for (int i = 1; i <= 5; i++) { a = a * i; b = b * i; } Console.WriteLine(a); Console.WriteLine(b); Console.ReadLine(); } |
A. | 600, 720 |
B. | Compile time error. |
C. | 25, 30 |
D. | 5, 6 |
Answer» C. 25, 30 | |
1608. |
Choose the correct type of variable scope for the given defined variables.Scope declaration:
class ABC { static int m; int n; void fun (int x , ref int y, out int z, int[] a) { int j = 10; } } |
A. | m = static variable, n = local variable, x = output parameter, y = reference parameter, j = instance variable, z =output parameter, a[0]= array element |
B. | m = static variable, n = instance variable, x = value parameter, y = reference parameter, j = local variable, z =output parameter , a[0] = array element |
C. | m = static variable, n = instance variable, x = reference parameter, y = value parameter, j = local variable, z =output parameter, a[0] = array element |
D. | m = local variable, n = instance variable, x = reference parameter, y = value parameter, j = static variable, z =output parameter, a[0] = array element |
Answer» C. m = static variable, n = instance variable, x = reference parameter, y = value parameter, j = local variable, z =output parameter, a[0] = array element | |
1609. |
Select output for the following set of code.
static void Main(string[] args) { string Name = "He is playing in a ground."; char[] characters = Name.ToCharArray(); StringBuilder sb = new StringBuilder(); for (int i = Name.Length - 1; i >= 0; --i) { sb.Append(characters[i]); } Console.Write(sb.ToString()); Console.ReadLine(); } |
A. | He is playing in a grou |
B. | .ground a in playing is He |
C. | .dnuorg a ni gniyalp si eH |
D. | He playing a |
Answer» D. He playing a | |
1610. |
Correct Output for the given set of programming code is :
class Program { static void Main(string[] args) { int i ; for (i = 0; i < 5; i++) { Console.WriteLine(i); } Console.ReadLine(); } } |
A. | 0, 1, 2, 3, 4, 5 |
B. | 0, 1, 2, 3 |
C. | 0, 1, 2, 3, 4 |
D. | 0, 0, 0, 0, 0 |
Answer» D. 0, 0, 0, 0, 0 | |
1611. |
Correct Output for the given set of programming code is :
class Program { static void Main(string[] args) { int i ; for ( i = 0; i < 5; i++) { int j = 0; j += i; Console. WriteLine(j); } Console. WriteLine(i); Console. ReadLine(); } } |
A. | 0, 1, 2, 3, 4, 5, 6 |
B. | 0, 1, 2, 3, 4, 5 |
C. | 0, 1, 2, 3, 4 |
D. | 0, 1, 2, 3 |
Answer» C. 0, 1, 2, 3, 4 | |
1612. |
Scope of variable is related to definition of variable as:a. Region of code within which variable value is valid and hence can be accessed. |
A. | A |
B. | B |
C. | A, b |
D. | None of the mentioned |
Answer» B. B | |
1613. |
Correct Output for the given set of programming code is :
static void Main(string[] args) { int i ; for (i = 0; i < 5; i++) { int j = 0; j += i; Console. WriteLine(j); } Console. WriteLine( i * j); Console. ReadLine(); } |
A. | 0, 1, 6, 18, 40 |
B. | 0, 1, 5, 20, 30 |
C. | Compile time error |
D. | 0, 1, 2, 3, 4, 5 |
Answer» D. 0, 1, 2, 3, 4, 5 | |
1614. |
Select the correct output for the following programming code
class Program { public static void Main(string[] args) { int i = 100; for (a = 0; a < 5; a++) { int i = 200; Console. WriteLine(a * i); } Console. ReadLine(); } } |
A. | 5, 10, 15, 20 |
B. | 0, 5, 10, 20 |
C. | Compile time error |
D. | 0, 1, 2, 3, 4 |
Answer» D. 0, 1, 2, 3, 4 | |
1615. |
Syntax for declaration and initialization of data variable is : |
A. | = , |
B. | , |
C. | , |
D. | = , |
Answer» B. , | |
1616. |
Select the correct output for the following set of code :
class Program { public static void Main(string[] args) { int i, j; i = (j = 5) + 10; Console. WriteLine(i); Console. WriteLine(j); Console. ReadLine(); } } |
A. | 15, 15 |
B. | 10, 5 |
C. | 15, 5 |
D. | 10, 15 |
Answer» D. 10, 15 | |
1617. |
Choose effective differences between Boxing and Unboxing . |
A. | Boxing is the process of converting a value type to the reference type and Unboxing is the process of converting reference to value type |
B. | Boxing is the process of converting a reference type to value type and Unboxing is the process of converting value type to reference type |
C. | In Boxing we need explicit conversion and in Unboxing we need implicit conversion |
D. | Both Boxing and Unboxing we need implicit conversion |
Answer» B. Boxing is the process of converting a reference type to value type and Unboxing is the process of converting value type to reference type | |
1618. |
Select differences between reference type and value type :1. Memory allocated to Value type is from heap and reference type is from System. ValueType |
A. | 1, 3 |
B. | 2, 3 |
C. | 1, 2, 3 |
D. | 1 |
Answer» C. 1, 2, 3 | |
1619. |
Correct output for the following set of code is :
public static void Main(string[] args) { int i = 123; object o = i; i = 456; System. Console. WriteLine("The value-type value = {0}", i); System. Console. WriteLine("The object-type value = {0}", o); Console. ReadLine(); } |
A. | 123, 123 |
B. | 456, 123 |
C. | 456, 456 |
D. | 123, 456 |
Answer» C. 456, 456 | |
1620. |
Correct output for the following set of code is :
public static void Main(string[] args) { int i = 546; object o = i; int n =(int) o; o = 70; System. Console. WriteLine("The value-type value = {0}", n); System. Console. WriteLine("The object-type value = {0}", o); Console. ReadLine(); } |
A. | 546, 0 |
B. | 546, 546 |
C. | 546, 70 |
D. | 70, 546 |
Answer» D. 70, 546 | |
1621. |
For the given set of code select the relevant solution for conversion of data type.
static void Main(string[] args) { int num1 = 20000; int num2 = 50000; long total; total = num1 + num2; Console.WriteLine("Total is : " +total); Console.ReadLine(); } |
A. | Compiler will generate runtime error |
B. | Conversion is implicit type, no error generation |
C. | Specifying datatype for conversion externally will solve the problem |
D. | None of the mentioned |
Answer» C. Specifying datatype for conversion externally will solve the problem | |
1622. |
Subset of int datatype is : |
A. | Long ,ulong, ushort |
B. | Long, ulong, uint |
C. | Long, float, double |
D. | Long, float, ushort |
Answer» D. Long, float, ushort | |
1623. |
Correct Output for the given set of programming code is :
class Program { static void Main(string[] args) { int i ; for (i = 0; i < 5; i++) { Console.WriteLine(i); } Console.ReadLine(); } } |
A. | 0, 1, 2, 3, 4, 5 |
B. | 0, 1, 2, 3, 4 |
C. | 5 |
D. | 4 |
Answer» D. 4 | |
1624. |
Predict the output for the given snippet of code :
int i, j = 1, k; for (i = 0; i < 3; i++) { k = j++ - ++j; Console.Write(k + " "); } |
A. | -4 -3 -2 |
B. | -6 -4 -1 |
C. | -2 -2 -2 |
D. | -4 -4 -4 |
Answer» D. -4 -4 -4 | |
1625. |
Predict the output for the given set of code correctly.
static void Main(string[] args) { int b= 11; int c = 7; int r = 5; int e = 2; int l; int v = 109; int k; int z,t,p; z = b * c; t = b * b; p = b * r * 2; l = (b * c) + (r * e) + 10; k = v - 8; Console.WriteLine(Convert.ToString(Convert.ToChar(z)) + " " + Convert.ToString(Convert.ToChar(t)) + Convert.ToString(Convert.ToChar(p)) + Convert.ToString(Convert.ToChar(l)) + Convert.ToString(Convert.ToChar(v)) + Convert.ToString(Convert.ToChar(k))); Console.ReadLine(); } |
A. | My Name |
B. | My nAme |
C. | My name |
D. | Myname |
Answer» D. Myname | |
1626. |
Choose exact solution for the following code snippet :
static void Main(string[] args) { int a , b; int c = 10; int d = 12; int e = 5; int f = 6; a = c * (d + e) / f + d; Console.WriteLine(a); b = c * ( d + e / f + d); Console.WriteLine(b); if (a < b) { Console.WriteLine(" parantheses changes values"); } else if (a > b) { Counterintelligence("they have same value"); } Console.ReadLine(); } |
A. | They have same value |
B. | Parentheses changes values |
C. | Since both have equal values, no conclusion |
D. | None of the mentioned |
Answer» C. Since both have equal values, no conclusion | |
1627. |
Select the output choice for the following set of code:
public static void Main(string[] args) { double ZERO = 0; Console.WriteLine("RESULT OF DIVISION BY ZERO IS :{0}", (0 / ZERO)); Console.ReadLine(); } |
A. | 0 |
B. | Exception arguement is thrown |
C. | NaN |
D. | None of the mentioned |
Answer» D. None of the mentioned | |
1628. |
What is the Size of Char datatype? |
A. | 8 bit |
B. | 12 bit |
C. | 16 bit |
D. | 20 bit |
Answer» D. 20 bit | |
1629. |
Choose the output for the following set of code.
static void Main(string[] args) { char c = 'g'; string s = c.ToString(); string s1 = "I am a human bein" + c; Console.WriteLine(s1); Console.ReadLine(); } |
A. | I am a human bein c |
B. | I am a human being |
C. | I am a human being c |
D. | I am a human bein |
Answer» C. I am a human being c | |
1630. |
Given is the code of days(example: MTWTFSS ) which i need to split and hence create a list of days of week in strings(example: Monday , Tuesday , Wednesday , Thursday , Friday , Saturday , Sunday ). A set of code is given for this purpose but there is error ocuring in that set of code related to conversion of char to strings.Hence,Select a code to solve the given error.
static void Main(string[] args) { var days = "MTWTFSS"; var daysArray = days.ToCharArray().Cast |
A. | Var daysArray = new List(); |
B. | Var daysArray = days.Select(c =>dayMapping[c]).ToArray(); |
C. | Var daysArray = days.ToCharArray().Select(c =>c.Tostring()).ToArray(); |
D. | None of above mentioned. |
Answer» D. None of above mentioned. | |
1631. |
Output for the following set of code is ?
static void Main(string[] args) { { var dayCode = "MTWFS"; var daysArray = new List |
A. | Monday ,Tuesday ,Wednesday ,Friday ,Saturday ,Sunday |
B. | Monday , Tuesday , Wednesday , Friday . Sunday |
C. | Monday , Tuesday , Wednesday , Friday , Saturday |
D. | Monday ,Tuesday ,Wednesday ,Friday ,Saturday |
Answer» D. Monday ,Tuesday ,Wednesday ,Friday ,Saturday | |
1632. |
Select the correct differences between char and varchar datatypes?1. varchar is non unicode and char is unicode character datatype |
A. | 1, 3, 4 |
B. | 2, 3, 4 |
C. | 1, 2, 4 |
D. | 3, 4 |
Answer» E. | |
1633. |
What does the following code display while execution?
class Program { static void Main(string[] args) { Uri obj = new Uri("https://www.mcqsmentor.com/Category/c-sharp-programming"); Console.WriteLine(obj.AbsoluteUri); Console.ReadLine(); } } |
A. | mcqsmentor |
B. | mcqsmentor.com |
C. | www.mcqsmentor.com |
D. | https://www.mcqsmentor.com/Category/c-sharp-programming |
Answer» E. | |
1634. |
Which of these statements is incorrect ? |
A. | By multithreading CPU s idle time is minimized, and we can take maximum use of it |
B. | By multitasking CPU s idle time is minimized, and we can take maximum use of it |
C. | Two thread in Csharp can have same priority |
D. | A thread can exist only in two states, running and blocked |
Answer» E. | |
1635. |
What will be the output of the given code snippet?
class MyClass { char[] chrs = { 'A', 'B', 'C', 'D' }; public System.Collections.IEnumerator GetEnumerator() { foreach (char ch in chrs) yield return ch; } } class Program { static void Main(string[] args) { MyClass mc = new MyClass(); foreach (char ch in mc) Console.Write(ch + " "); Console.WriteLine(); Console.ReadLine(); } } |
A. | Run time error |
B. | Compile time error |
C. | Code runs successfully prints nothing |
D. | Code runs successfully prints A, B, C, D |
Answer» E. | |
1636. |
What does the yield return statement specify in below code snippet?
public System.Collections.IEnumerator GetEnumerator() { foreach (char ch in chrs) yield return ch; } |
A. | Returns the output |
B. | Returns the next object in the collection |
C. | Both a & b |
D. | None of the mentioned |
Answer» C. Both a & b | |
1637. |
What does the given code snippet specify?
class MyClass { char chrs = 'A' ; public IEnumerator GetEnumerator() { for (int i = 20; i >=0; --i) yield return (char)((chrs + i)); } } class Program { static void Main(string[] args) { MyClass mc = new MyClass(); foreach (char ch in mc) Console.Write(ch + " "); Console.WriteLine(); Console.ReadLine(); } } |
A. | A B C D E F G H I J K L M N O P Q R S T U V |
B. | Run time error |
C. | U T S R Q P O N M L K J I H G F E D C B A |
D. | Compile successfully prints nothing |
Answer» D. Compile successfully prints nothing | |
1638. |
What will the given code snippet specify?
class MyClass { char chrs = 'A' ; public IEnumerator GetEnumerator() { for (int i = 20; i >=0; --i) if (i == 10) yield break; yield return (char)((chrs + i)); } } class Program { static void Main(string[] args) { MyClass mc = new MyClass(); foreach (char ch in mc) Console.Write(ch + " "); Console.WriteLine(); Console.ReadLine(); } } |
A. | Code run successfully prints nothing |
B. | A B C D E F G H I J K L M N O P Q R S T U V |
C. | U T S R Q P O N M L |
D. | Compile time error |
Answer» D. Compile time error | |
1639. |
What will be the output of the code snippet?
class MyClass { int[] a = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20}; public IEnumerator GetEnumerator() { for (int i = 0; i < 20; i++) { if (a[i] % 2 == 0) yield return (int)(a[i]); } } } class Program { static void Main(string[] args) { MyClass mc = new MyClass(); foreach (int i in mc) Console.Write(i + " "); Console.WriteLine(); Console.ReadLine(); } } |
A. | Prints nothing code run successfully |
B. | Run time error |
C. | Code runs successfully prints even number between 1 to 20 |
D. | Compile time error |
Answer» D. Compile time error | |
1640. |
What will be the output of the code snippet?
class MyClass { char ch = 'A'; int e = 4; int k = 9; int z = 6; public IEnumerator GetEnumerator() { for (int i = 0; i < 26; i++) { if (i == e*k /z) yield break; yield return (int)(ch + i); } } } class Program { static void Main(string[] args) { MyClass mc = new MyClass(); foreach(int ch in mc) Console.Write(ch + " "); Console.WriteLine(); Console.ReadLine(); } } |
A. | Compile time error |
B. | Run time error |
C. | 65 66 67 68 69 70 |
D. | Code run successfully prints nothing |
Answer» D. Code run successfully prints nothing | |
1641. |
What does the given code snippet specify?public Thread(ThreadStart start) |
A. | Defines a thread |
B. | Declaration of a thread constructor |
C. | Only a |
D. | Only a & b |
Answer» E. | |
1642. |
What will be the output of the given code snippet?
class A {} class B : A {} class CheckCast { static void Main() { A a = new A(); B b = new B(); b = a as B; b = null; if(b==null) Console.WriteLine("The cast in b = (B) a is NOT allowed."); else Console.WriteLine("The cast in b = (B) a is allowed"); } } |
A. | Run time error |
B. | The cast in b = (B) a is NOT allowed |
C. | The cast in b = (B) a is allowed |
D. | Compile time error |
Answer» C. The cast in b = (B) a is allowed | |
1643. |
Choose the class from which the namespace System.Type is derived: |
A. | System.Reflection |
B. | System.Reflection.MemberInfo |
C. | Both a & b |
D. | None of the mentioned |
Answer» C. Both a & b | |
1644. |
What does the following property signify?MemberTypes MemberType |
A. | Helps in distinguishing kinds of members |
B. | Property helps in determining if member is a field, method, property or event |
C. | Both a & b |
D. | None of the mentioned |
Answer» D. None of the mentioned | |
1645. |
The property signifies Obtains a Module object that represents the module (an executable file) in which the reflected type resides . Choose the property which specifies the following statement: |
A. | Type DeclaringType |
B. | Int MetadataToken |
C. | Module Module |
D. | Type ReflectedType |
Answer» D. Type ReflectedType | |
1646. |
What does the following declaration specify?MethodInfo[] GetMethods() |
A. | Returns an array of MethodInfo objects |
B. | Returns a list of the public methods supported by the type by using GetMethods() |
C. | Both a & b |
D. | None of the mentioned |
Answer» D. None of the mentioned | |
1647. |
What does the following method specify?Type[] GetGenericArguments() |
A. | A property defined by MemberInfo |
B. | Obtains a list of the type arguments bound to a closed constructed generic type |
C. | The list may contain both type arguments and type parameters |
D. | All of the mentioned |
Answer» E. | |
1648. |
What does the following code specify?object Invoke(object obj, object[] parameters) |
A. | Calling a type using invoke() |
B. | Any arguments that need to be passed to the method are specified in the array parameters |
C. | The value returned by the invoked method is returned by Invoke() |
D. | All of the mentioned |
Answer» E. | |
1649. |
What does the following form define?
|
A. | Protocol specifies the protocol being used, such as HTTP |
B. | HostName identifies a specific server, such as mhprofessional.com or www.google.com |
C. | FilePath specifies the path to a specific file |
D. | All of the mentioned |
Answer» E. | |
1650. |
What does the following method specify?public static WebRequest Create(string requestUriString) |
A. | Creates a WebRequest object for the URI specified by the string passed by requestUriString |
B. | The object returned will implement the protocol specified by the prefix of the URI |
C. | The object will be an instance of the class that inherits WebRequest |
D. | All of the mentioned |
Answer» E. | |