Online Test | Technical MCQ Test 9 Instruction:Total number of questions : 20Time allotted : 20 minutes.Each question carry 1 mark, no negative marks.C # Quiz - Part -01 Instruction:Total number of questions : 20Time allotted : 20 minutes.Each question carry 1 mark, no negative marks.C # Quiz - Part -01 C Sharp C # Quiz -1 C Sharp Quizzes for Freshers 1 / 20 Category: Data Types, Variables and Operators Choose “.NET class” name from which data type “UInt” is derived? System.UInt64 System.UInt32 System.UInt16 System.Int16 2 / 20 Category: Data Types, Variables and Operators Which Conversion function of ‘Convert.TOInt32()’ and ‘Int32.Parse()’ is efficient?i) Int32.Parse() is only used for strings and throws argument exception for null stringii) Convert.Int32() used for data types and returns directly '0' for null string i None of the mentioned ii Both i, ii 3 / 20 Category: Data Types, Variables and Operators Correct Declaration of Values to variables ‘a’ and ‘b’? int a = 32; int b = 40; int a = b = 42; int a = 32, b = 40.6; int a = 42; b = 40; 4 / 20 Category: Data Types, Variables and Operators How many Bytes are stored by ‘Long’ Data type in C# .net? 2 1 8 4 5 / 20 Category: Initialization of Variables in C# What will be the output of the following C# code?static void Main(string[] args){int a = 5;int b = 10;int c;Console.WriteLine(c = ++ a + b ++);Console.WriteLine(b);Console.ReadLine();} 15, 11 16, 11 16, 10 11, 10 6 / 20 Category: Initialization of Variables in C# What will be the output of the following C# 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();} 25, 30 Compile time error 600, 720 5, 6 7 / 20 Category: Initialization of Variables in C# What will be the output of the following C# code?static void Main(string[] args){int a = 5;int b = 10;int c;Console.WriteLine(c = a-- - ++b);Console.WriteLine(b);Console.ReadLine();} -5, 11 15, 11 -7, 10 -6, 11 8 / 20 Category: Initialization of Variables in C# The following C# codes are?i) Myclass class;Myclass class2 = null;ii) int i;int j = 0; True for (1);False for (2) Both (1) and (2) are not equivalents True for (2);False for (1) Both (1) and (2) are equivalents 9 / 20 Category: Floating and Decimal Data Types in C# Minimum and Maximum range of values supported by ‘float’ data type are? 1.5 * 10^-45 to 3.4 * 10^37 1.5 * 10^-40 to 3.4 * 10^38 1.5 * 10^-45 to 3.4 * 10^30 1.5 * 10^-45 to 3.4 * 10^38 10 / 20 Category: Floating and Decimal Data Types in C# Valid Size of float data type is? 10 Bytes 6 Bytes 4 Bytes 8 Bytes 11 / 20 Category: Floating and Decimal Data Types in C# Correct way to define a value 6.28 in a variable ‘pi’ where value cannot be modified? #define pi 6.28F const float pi ; pi = 6.28F pi = 6.28F const float pi = 6.28F 12 / 20 Category: Floating and Decimal Data Types in C# Why does a float variable stop incrementing at number ‘16777216’ in the following C# code?float a = 0 ;while (true){a++;if (a > 16777216)break;} Mantissa is different for ‘16777216’ and ‘16777217’ Sign and Exponent for ‘16777217’ is different from ‘16777216’ None of the mentioned Sign and Exponent for ‘16777217’ is same as for ‘16777216’ 13 / 20 Category: Floating and Decimal Data Types in C# The Default value of Boolean Data Type is? 0 1 False True 14 / 20 Category: Uncategorized Default Type of number without decimal is? Unsigned Int Int Long Int Unsigned Long 15 / 20 Category: Char Types and String Literals in C# Why strings are of reference type in C#.NET? To reduce the size of string None of the mentioned To overcome problem of stackoverflow To create string on stack 16 / 20 Category: Scope and Lifetime of Variables in C# What will be the output of the following C# code?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();} 0, 1, 5, 20, 30 0, 1, 6, 18, 40 0, 1, 2, 3, 4, 5 Compile time error 17 / 20 Category: Scope and Lifetime of Variables in C# What will be the output of the following C# code?class Program{public static void Main(string[] args){int i, j;i = (j = 5) + 10;Console. WriteLine(i);Console. WriteLine(j);Console. ReadLine();}} 15, 5 10, 15 10, 5 15, 15 18 / 20 Category: Scope and Lifetime of Variables in C# Select differences between reference type and value type:i. Memory allocated to ‘Value type’ is from heap and reference type is from ‘System. ValueType’ii. Memory allocated to ‘Value type’ is from ‘System. ValueType’ and reference type is from ‘Heap’iii. Structures, enumerated types derived from ‘System. ValueType’ are created on stack, hence known as ValueType and all ‘classes’ are reference type because values are stored on heap i, iii i, ii, iii i ii, iii 19 / 20 Category: Scope and Lifetime of Variables in C# What will be the output of the following C# code?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();} 456, 123 123, 123 456, 456 123, 456 20 / 20 Category: Scope and Lifetime of Variables in C# What will be the output of the following C# code?class Program{static void Main(string[] args){int i ;for (i = 0; i < 5; i++){Console.WriteLine(i);}Console.ReadLine();}} 0, 1, 2, 3, 4 0, 1, 2, 3 0, 1, 2, 3, 4, 5 0, 0, 0, 0, 0 Your score is The average score is 31% LinkedIn Facebook Twitter VKontakte 0% Restart quiz 0 Instruction:Total number of questions : 20Time allotted : 20 minutes.Each question carry 1 mark, no negative marks.C # Quiz Part -02 Instruction:Total number of questions : 20Time allotted : 20 minutes.Each question carry 1 mark, no negative marks.C # Quiz Part -02 C Sharp C # Quiz -2 C Sharp Quizzes for Freshers 1 / 20 Category: Scope and Lifetime of Variables in C# Choose the correct type of variable scope for the following C# defined variables.class ABC{static int m;int n;void fun (int x , ref int y, out int z, int[] a){int j = 10;}} m = static variable, n = instance variable, x = reference parameter, y = value parameter, j = local variable, z = output parameter, a[0] = array element m = static variable, n = local variable, x = output parameter, y = reference parameter, j = instance variable, z = output parameter, a[0] = array element m = static variable, n = instance variable, x = value parameter, y = reference parameter, j = local variable, z = output parameter , a[0] = array element m = local variable, n = instance variable, x = reference parameter, y = value parameter, j = static variable, z = output parameter, a[0] = array element 2 / 20 Category: Scope and Lifetime of Variables in C# What will be the output of the following C# code?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();} 546, 0 546, 546 546, 70 70, 546 3 / 20 Category: Floating and Decimal Data Types in C# What will be the output of the following C# code?static void Main(string[] args){int x = 1;float y = 2. 4f;short z = 1;Console. WriteLine((float) x + y * z - (x + = (short) y) );Console. ReadLine();} 0.4000001 0.0400021 0.4000023 0.4000004 4 / 20 Category: Floating and Decimal Data Types in C# Select a convenient declaration and initialization of a floating point number float somevariable = 12.502D float somevariable = (float) 12.502D float somevariable = (Double) 12.502D float somevariable = (Decimal)12.502D 5 / 20 Category: Floating and Decimal Data Types in C# A float occupies 4 bytes. If the hexadecimal equivalent of these 4 bytes are A, B, C and D, then when this float is stored in memory in which of the following order do these bytes gets stored? Depends on big endian or little endian architecture DCBA 0 * ABCD ABCD 6 / 20 Category: Floating and Decimal Data Types in C# The Default value of Boolean Data Type is? 1 False True 0 7 / 20 Category: Data Types, Variables and Operators What will be the output of the following C# code? static void Main(string[] args){float a = 10.553f;long b = 12L;int c;c = Convert.ToInt32(a + b);Console.WriteLine(c);} 23 22.453 22 23.453 8 / 20 Category: Data Types, Variables and Operators Which Conversion function of ‘Convert.TOInt32()’ and ‘Int32.Parse()’ is efficient?i) Int32.Parse() is only used for strings and throws argument exception for null stringii) Convert.Int32() used for data types and returns directly '0' for null string Both i, ii ii None of the mentioned i 9 / 20 Category: Char Types and String Literals in C# What will be the output of the following C# string? (Enter a String : BOMBAY).static void Main(string[] args){string Str, Revstr = " ";int Length;Console.Write("Enter A String : ");Str = Console.ReadLine();Length = Str.Length - 1;while (Length >= 0){Revstr = Revstr + Str[Length];Length --;}Console.WriteLine("Reverse String Is {0}", Revstr);Console.ReadLine();} YABMOB BOMBA YABMO BOMAYB 10 / 20 Category: Char Types and String Literals in C# Correct statement about strings are? a string is created on the stack a string created on heap created of string on a stack or on a heap depends on the length of the string a string is primitive in nature 11 / 20 Category: Char Types and String Literals in C# What will be the output of the following C# code?static void Main(string[] args){string s1 = "Delhi";string s2;s2 = s1.Insert (6, "Jaipur");Console.WriteLine(s2);} Delhi Jaipur DelhiJaipur DelhJaipuri Delhi 12 / 20 Category: Char Types and String Literals in C# 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 the error occurring in that set of code related to the conversion of char to strings. Hence, Select a C# code to solve the given error. static void Main(string[] args){var days = "MTWTFSS";var daysArray = days.ToCharArray().Cast<string>().ToArray();for (var i = 0; i < daysArray.Length; i++){switch (daysArray[i]){case "M":daysArray[i] = "Monday";break;case "T":daysArray[i] = "Tuesday";break;case "W":daysArray[i] = "Wednesday";break;case "R":daysArray[i] = "Thursday";break;case "F":daysArray[i] = "Friday";break;case "S":daysArray[i] = "Saturday";break;case "U":daysArray[i] = "Sunday";break;}}daysArray[daysArray.Length - 1] = "and " + daysArray[daysArray.Length - 1];Console.WriteLine(string.Join(", ", daysArray));} var daysArray = new List(); var daysArray = days.ToCharArray().Select(c =>c.Tostring()).ToArray(); var daysArray = days.Select(); var daysArray = days.Select(c =>dayMapping[c]).ToArray(); 13 / 20 Category: Char Types and String Literals in C# What is the Size of ‘Char’ datatype? 8 bit 16 bit 20 bit 12 bit 14 / 20 Category: Char Types and String Literals in C# For two strings s1 and s2 to be equal, which is the correct way to find if the contents of two strings are equal? if(strcmp(s1, s2)) if(s1 = s2) if (s1 is s2) int c; c = s1.CompareTo(s2); 15 / 20 Category: Initialization of Variables in C# What will be the output of the following C# code?static void Main(string[] args){int a = 5;int b = 10;int c;Console.WriteLine(c = a-- - ++b);Console.WriteLine(b);Console.ReadLine();} -5, 11 -6, 11 -7, 10 15, 11 16 / 20 Category: Initialization of Variables in C# DIFFERENCE BETWEEN KEYWORDS ‘VAR’ AND ‘DYNAMIC’? For ‘Var’ Error is caught at compile time and for ‘Dynamic’ Error is caught at runtime All of the mentioned ‘Var’ is introduced in C# (3.0) and ‘Dynamic’ is introduced in C# (4.0) ‘Var’ is a type of variable where declaration is done at compile time by compiler while ‘Dynamic’ declaration is achieved at runtime by compiler 17 / 20 Category: Initialization of Variables in C# What will be the output of the following C# code?static void Main(string[] args){int a = 5;int b = 10;int c;Console.WriteLine(c = ++ a + b ++);Console.WriteLine(b);Console.ReadLine();} 11, 10 16, 11 16, 10 15, 11 18 / 20 Category: Initialization of Variables in C# What will be the output of the following C# 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();} 5, 6 25, 30 600, 720 Compile time error 19 / 20 Category: Initialization of Variables in C# What will be the output of the following C# code?static void Main(string[] args){String name = "Dr.Gupta";Console.WriteLine("Good Morning" + name);} Good Morning Good Morning Dr.Gupta Good Morning name Dr.Gupta 20 / 20 Category: Initialization of Variables in C# What will be the output of the following C# code?int a,b;a = (b = 10) + 5; b = 10, a = 5 a = 15, b = 10 a = 10, b = 10 b = 15, a = 5 Your score is The average score is 0% LinkedIn Facebook Twitter VKontakte 0% Restart quiz 1 Instruction:Total number of questions : 20Time allotted : 20 minutes.Each question carry 1 mark, no negative marks.C # Quiz Part -03 Instruction:Total number of questions : 20Time allotted : 20 minutes.Each question carry 1 mark, no negative marks.C # Quiz Part -03 C Sharp C # Quiz -3 C Sharp Quizzes for Freshers 1 / 20 Category: Char Types and String Literals in C# What will be the output of the following C# string? (Enter a String : BOMBAY).static void Main(string[] args){string Str, Revstr = " ";int Length;Console.Write("Enter A String : ");Str = Console.ReadLine();Length = Str.Length - 1;while (Length >= 0){Revstr = Revstr + Str[Length];Length --;}Console.WriteLine("Reverse String Is {0}", Revstr);Console.ReadLine();} BOMBA YABMOB BOMAYB YABMO 2 / 20 Category: Char Types and String Literals in C# Verbatim string literal is better used for? To embed a quotation mark by using double quotation marks inside a verbatim string Used to initialize multi-line strings All of the mentioned Convenience and better readability of strings when string text consist of backlash characters 3 / 20 Category: Char Types and String Literals in C# What will be the output of the following C# code?static void Main(string[] args){string s1 = "Delhi";string s2;s2 = s1.Insert (6, "Jaipur");Console.WriteLine(s2);} Delhi DelhiJaipur DelhJaipuri Delhi Jaipur 4 / 20 Category: Char Types and String Literals in C# Which is the String method used to compare two strings with each other? ConCat() Compare() Compare To() Copy() 5 / 20 Category: Char Types and String Literals in C# What will be the output of the following C# code?static void Main(string[] args){char c = 'g';string s = c.ToString();string s1 = "I am a human being" + c;Console.WriteLine(s1);Console.ReadLine();} I am a human bein I am a human being I am a human bein c I am a human being c 6 / 20 Category: Char Types and String Literals in C# What will be the output of the following C# code? string s1 = " I AM BEST ";string s2;s2 = s1.substring (5, 4);Console.WriteLine (s2); AM BEST I AM BES BEST I AM 7 / 20 Category: Initialization of Variables in C# Storage location used by computer memory to store data for usage by an application is? Variable None of the mentioned Constants Pointers 8 / 20 Category: Initialization of Variables in C# What will be the output of the following C# code?static void Main(string[] args){int a = 5;int b = 10;int c;Console.WriteLine(c = a-- - ++b);Console.WriteLine(b);Console.ReadLine();} -6, 11 -5, 11 -7, 10 15, 11 9 / 20 Category: Floating and Decimal Data Types in C# A float occupies 4 bytes. If the hexadecimal equivalent of these 4 bytes are A, B, C and D, then when this float is stored in memory in which of the following order do these bytes gets stored? DCBA ABCD 0 * ABCD Depends on big endian or little endian architecture 10 / 20 Category: Floating and Decimal Data Types in C# Select a convenient declaration and initialization of a floating point number float somevariable = (Double) 12.502D float somevariable = (float) 12.502D float somevariable = 12.502D float somevariable = (Decimal)12.502D 11 / 20 Category: Floating and Decimal Data Types in C# What will be the output of the following C# code?static void Main(string[] args){int x = 1;float y = 2. 4f;short z = 1;Console. WriteLine((float) x + y * z - (x + = (short) y) );Console. ReadLine();} 0.4000001 0.4000004 0.4000023 0.0400021 12 / 20 Category: Floating and Decimal Data Types in C# The Default value of Boolean Data Type is? 1 True False 0 13 / 20 Category: Scope and Lifetime of Variables in C# Select differences between reference type and value type:i. Memory allocated to ‘Value type’ is from heap and reference type is from ‘System. ValueType’ii. Memory allocated to ‘Value type’ is from ‘System. ValueType’ and reference type is from ‘Heap’iii. Structures, enumerated types derived from ‘System. ValueType’ are created on stack, hence known as ValueType and all ‘classes’ are reference type because values are stored on heap ii, iii i, ii, iii i i, iii 14 / 20 Category: Scope and Lifetime of Variables in C# What will be the output of the following C# 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();}} 0, 1, 2, 3, 4 Compile time error 5, 10, 15, 20 0, 5, 10, 20 15 / 20 Category: Scope and Lifetime of Variables in C# What will be the output of the following C# code?class Program{static void Main(string[] args){int i ;for (i = 0; i < 5; i++){Console.WriteLine(i);}Console.ReadLine();}} 0, 1, 2, 3 0, 1, 2, 3, 4 0, 0, 0, 0, 0 0, 1, 2, 3, 4, 5 16 / 20 Category: Scope and Lifetime of Variables in C# What will be the output of the following C# code?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();} 0, 1, 5, 20, 30 0, 1, 2, 3, 4, 5 0, 1, 6, 18, 40 Compile time error 17 / 20 Category: Scope and Lifetime of Variables in C# Choose effective differences between ‘Boxing’ and ‘Unboxing’. ‘Boxing’ is the process of converting a reference type to value type and ‘Unboxing’ is the process of converting value type to reference type In ‘Boxing’ we need explicit conversion and in ‘Unboxing’ we need implicit conversion ‘Boxing’ is the process of converting a value type to the reference type and ‘Unboxing’ is the process of converting reference to value type Both ‘Boxing’ and ‘Unboxing’ we need implicit conversion 18 / 20 Category: Scope and Lifetime of Variables in C# What will be the output of the following C# code?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();} 123, 123 456, 456 123, 456 456, 123 19 / 20 Category: Data Types, Variables and Operators Choose “.NET class” name from which data type “UInt” is derived? System.UInt16 System.UInt32 System.UInt64 System.Int16 20 / 20 Category: Data Types, Variables and Operators Correct Declaration of Values to variables ‘a’ and ‘b’? int a = 32; int b = 40; int a = b = 42; int a = 32, b = 40.6; int a = 42; b = 40; Your score is The average score is 35% LinkedIn Facebook Twitter VKontakte 0% Restart quiz