EXAM

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

Output of: static void Main(string[] args) { String y = "C#"; String x = y + "Language"; Console.WriteLine(x); Console.ReadLine(); } ◈ "C# Language" ◈ C#Language ◈ C# Language ◈ "C#Language"

C#Language

Output of: enum cal { a, b, c, d, } cal.a = 10; Console.writeline(cal.b); ◈ 11 ◈ 1 ◈ 2 ◈ Compile time error

Compile time error

Output of: static void Main(string[] args) { int i = 30; int j = 2 * 25; if (i < j) { Console.WriteLine("Hello!!"); } else { Console.WriteLine("Welcome to uCertify."); } Console.WriteLine("Learn CSharp Programming Language."); Console.ReadLine(); } ◈ Hello!! Welcome to uCertify. ◈ Welcome to uCertify. Learn CSharp Programming Language. ◈ A compile time error will occur. ◈ Hello!! Learn CSharp Programming Language.

Hello!! Learn CSharp Programming Language.

Output of: using System; public class MyProgram { public static void Main(string[] args) { string name = " I am a CSharp expert "; string sub = name.Trim(); Console.WriteLine(sub); sub = name.ToUpper(); Console.WriteLine(sub); sub = name.Insert(2, "->"); Console.WriteLine(sub); } } ◈ I am a CSharp expert -> I am a CSharp expert ◈ I AM A CSHARP EXPERT -> I am a CSharp expert ◈ I am a CSharp expert I AM A CSHARP EXPERT -> I am a CSharp expert ◈ I am a CSharp expert I AM A CSHARP EXPERTI ->AM A CSHARP EXPERT

I am a CSharp expert I AM A CSHARP EXPERT -> I am a CSharp expert

Output of: String a = "Iwant"; String b = "toLearn"; String c = "CSHARP"; b = string.Concat(a, ' ', b); string d = b.PadLeft(20, '*'); Console.WriteLine(a + d + c); Console.ReadLine(); ◈ *******Iwant toLearn ◈ Iwant*******Iwant toLearnCSHARP ◈ *******want toLearnCSHARP ◈ CSHARP*******want toLearn

Iwant*******Iwant toLearnCSHARP

*Output of: static void Main(string[] args) { int a; Sample1(ref a); Console.WriteLine(a); Sample2(out int b); Console.WriteLine(b); } static void Sample1(ref int value) { value = 2; } static void Sample2(out int value) { value = 4; } ◈ The error "Use of unassigned local variable a" will appear during compilation. ◈ Line 4 will print the value of variable a as 2. ◈ Line 6 will print the value of variable b as 2. ◈ The error "Multiple declaration of the value variable" will occur during compilation.

The error "Use of unassigned local variable a" will appear during compilation.

Output of: static void Main(string[] args){ int i = 2, j = 5; switch (i) { case 1: j += 10; Console.WriteLine("The value of j is {0}", j); break; case 2: j += 20; goto case 1; case 3: j += 10; goto case 1; default: Console.WriteLine("Not Known"); break; } Console.ReadLine(); } ◈ The value of j is 25 ◈ The value of j is 35 ◈ Not Known ◈ The value of j is 45

The value of j is 35

*Which of the following statements is true about delegates? ◈ They are declared within a function body. ◈ Multiple methods can be called using a delegate. ◈ They are type safe. ◈ They are reference types.

They are reference types.

Which of the following methods of class is used to remove the leading and backward whitespaces? ◈ startsWith() ◈ doTrim() ◈ trim() ◈ Trim()

Trim()

*Output of: bool x = true; bool y = false; x |= y; Console.WriteLine(x); Console.ReadLine(); ◈ 1 ◈ 0 ◈ False ◈ True

True

Which of the following provides a very convenient and direct approach to return more than a single value from a function? ◈ Array ◈ Delegate ◈ Tuple ◈ Parameter

Tuple

static void Main(string[] args) { { var record = Info(); Console.WriteLine($ "Id = {record.Item1}"); Console.WriteLine($ "First Name = {record.Item2}"); Console.WriteLine($ "Last Name = {record.Item3}"); Console.ReadKey(); } //Line 1 { return Tuple.Create(1, "Bill", "Gates"); } } Required output: Id = 1 First Name = Bill Last Name = Gates Which of the following lines of code will be placed on Line 1 to print the required output? ◈ Info (record, Tuple <1, "Bill", "Gates">) ◈ Tuple <int, string, string> -> Info () ◈ Tuple <int, string, string> Info () ◈ Info (Tuple <int, string, string> record)

Tuple <int, string, string> Info ()

*Which of the following is the correct way to declare a delegate for calling the function f() defined in the given program? class Example { public int f(int a, double b) { //Enter code } } ◈ delegate double d (int a, double b); ◈ delegate void (inta, double b); ◈ delegate void d (int a, double b); ◈ delegate int d (int a, double b);

delegate int d (int a, double b);

Which of the following CANNOT be used as a data type for an enum in C#? ◈ double ◈ None of these ◈ int ◈ short

double

Which of the following for statements will not produce any output? ◈ for (var count = 5; count >= 5; count++) { Console.WriteLine(count); Console.ReadKey(); } ◈ for (var count = 10; count >= 0; count--) { Console.WriteLine(count); Console.ReadKey(); } ◈ for (var count = 10; count <= 0; count++) { Console.WriteLine(count); Console.ReadKey(); } ◈ for (var count = 0; count <= 10; count++) { Console.WriteLine(count); Console.ReadKey(); }

for (var count = 10; count <= 0; count++) { Console.WriteLine(count); Console.ReadKey(); }

Which of the following lines of code is required to compile the given code successfully? double d = 8773.87; int i; //Enter code Console.WriteLine(i); Console.ReadKey(); ◈ d = (int) i; ◈ int i = (double) d ◈ i = (int) d ◈ i = double (d)

i = (int) d;

Which of the following return statements correctly returns the output? ◈ public int sum(int a) { return (a + a) } ◈ public int sum(int a) return sum; ◈ public int sum(int a) { return sum; } ◈ public int sum(int a) { return a + a; }

public int sum(int a) { return a + a; }

*Which of the following code snippets is equivalent to the given if-else statement? if (a > b) { result = "a is greater than b"; } else if (a < b) { result = "b is greater than a"; } else { result = "a is equal to b"; } ◈ switch (a > b) { case 1: "a is greater than b"; case 2: "b is greater than a"; default: "a is equal to b"; } ◈ result = a > b | "a is greater than b" : a < b | "b is greater than a" ? "a is equal to b"; ◈ switch (a > b) { case 1: "a is greater than b"; break; default: "b is greater than a"; } ◈ result = a > b ? "a is greater than b" : a < b ? "b is greater than a" : "a is equal to b";

result = a > b ? "a is greater than b" : a < b ? "b is greater than a" : "a is equal to b";

Which of the following is the correct way to create a structure with the function to print the variables name, age, and rollno in a single line? student st; st.name="John"; st.age=25; st.rollno=10234; Console.WriteLine(st.Detail()); ◈ struct student { public string name; public int age; public int rollno; public string Detail() => name + " " + age + " " + rollno; } ◈ struct student { public string Detail() => name + " " + age + " " + rollno; } ◈ struct student { Detail() => st.name; Detail() => st.age; Detail() => st.rollno; public string st => name + " " + age + " " + rollno; } ◈ struct student { public string name; public int age; public int rollno; public string Detail() => st.name + " " + st.age + " " + st.rollno; }

struct student { public string name; public int age; public int rollno; public string Detail() => name + " " + age + " " + rollno; }

*What will be the value of the Boolean variable result if a = true and b = false for the following expression? result = (a != (b == a)) && ((a = b) || (!b)); ◈ false ◈ 0 ◈ 1 ◈ true

true

*Which of the following return functions m() will print the output as 3? static void Main(string[] args) { { m(); Console.ReadLine(); } //Enter code } ◈ void m() { Console.WriteLine("3"); } ◈ void m(int d) { d = 3; Console.WriteLine(d); } ◈ int m(int d) { d = 3; return d; } ◈ int m(int d) d = 3; return d;

void m() { Console.WriteLine("3");}

Which of the following is the correct order of the given operators in C#? !=, ||, &, %, && ◈ || < && < & < != < % ◈ || < && < != < & < % ◈ && < || < != < & < % ◈ && < || < != < % < &

|| < && < & < != < %

*Which of the following are correct statements for Parameters? (choose all) ◈ These are defined as part of a function definition. ◈ These are passed to a function by calling code. ◈ These are separated using commas. ◈ Each of the parameter is accessible from code within the function as a variable.

◈ *These are defined as part of a function definition. ◈ These are separated using commas. ◈ Each of the parameter is accessible from code within the function as a variable.

Which of the following statements are true regarding the Main() function? (choose all) ◈ Any value returned from the Main() function is stored in an environment variable. ◈ The Main() function can return either void or int ◈ The Main() function in a console application can receive command line parameters. ◈ The args parameter of Main() helps to include the .NET libraries.

◈ Any value returned from the Main() function is stored in an environment variable. ◈ The Main() function can return either void or int ◈ The Main() function in a console application can receive command line parameters.

static void Main(string[] args) { int a; Example1(ref a); Console.WriteLine(a); Example2(out int b); Console.WriteLine(b); } static void Example1(ref int value) { value = 1; } static void Example2(out int value) { value = 2; } Which of the following conclusions are true regarding the given code? (choose all) ◈ Line 4 will print the value of variable 'a' as 1. ◈ Line 6 will print the value of variable 'b' as 2 ◈ The error "Multiple declaration of 'value' variable" will occur during compilation. ◈ The error "Use of unassigned local variable 'a'" will appear during compilation.

◈ Line 6 will print the value of variable 'b' as 2 ◈Line 4 will print the value of variable 'a' as 1

Which of the following statements are true of a jagged array? (choose all) ◈ Jagged arrays are easier to use as compared to a rectangular array. ◈ Number of rows are fixed in a jagged array, but the number of columns can vary. ◈ Length of each array should be the same in a jagged array. ◈ Non-adjacent memory locations are required to store a jagged array.

◈ Number of rows are fixed in a jagged array, but the number of columns can vary. ◈ Non-adjacent memory locations are required to store a jagged array.

What are delegates in C#? (choose all) ◈ Only one method can be called using a delegate ◈ The declaration of a delegate and the signature of the method that we intend to call should be the same ◈ It allows the programmer to encapsulate a reference to a method inside an object ◈ A delegate variable cannot be passed as a parameter to a function.

◈ The declaration of a delegate and the signature of the method that we intend to call should be the same ◈ It allows the programmer to encapsulate a reference to a method inside an object

Which of the following are correct about explicit conversion? ◈ The rules for conversion are complicated enough to merit additional processing of some kind. ◈ The rules for performing the conversion are simple enough for a user to trust in the compiler. ◈ Conversion from type A to type B is possible in all circumstances. ◈ Conversion from type A to type B is possible only in certain circumstances.

◈ The rules for conversion are complicated enough to merit additional processing of some kind. ◈Conversion from type A to type B is possible only in certain circumstances.

Which of the following statements are true regarding the following code snippet? (choose all) var a = 90; function f1() { var x = 9; function f2() { var y = 10; } } ◈ The variable y is local to the f2 function. ◈ The scope of the variable x is for the f1 function only ◈ The variable x is local to the f2 function. ◈ The variable a is global.

◈ The variable y is local to the f2 function. ◈ The variable a is global.

static void Main(string[] args) { string[] fruits = {"Mango","Apple","Cherry"}; // Enter code Console.WriteLine($ "Here are {fruits.Length} in my basket:"); Console.ReadKey(); } Required output: Here are 3 fruits in my basket: Mango Apple Cherry Which of the following code snippets are appropriate to complete the given code for producing the required output? (choose all) ◈ int i; for (i = 0; i < fruits.Length; i++) { Console.WriteLine(fruits[i]); } ◈ int i; while(i<=3) { Console.WriteLine(fruits[i]); } ◈ int i; if (i <= 0) { Console.WriteLine(fruits[i]); } else i++; ◈ foreach(string basket in fruits) { Console.WriteLine(basket); }

◈ int i; for (i = 0; i < fruits.Length; i++) { Console.WriteLine(fruits[i]); } ◈ foreach(string basket in fruits) { Console.WriteLine(basket); }

*Which of the following are the correct ways to define a variable of type struct student? (choose all) struct student { public string name; public int age; public int rollno; } ◈ student(); ◈ student s; ◈ student new = s(); ◈ student s = new student();

◈ student s; ◈ student s = new student();

*Output of code: static void Main(string[] args) { int x = 1, y = 5; do { Console.WriteLine(x = x++ * y); } while (x <= 10); Console.ReadLine(); } ◈ 5 11 16 21 26 31 36 41 46 51 ◈ 5 10 15 20 25 30 35 40 45 50 ◈ 5 25 ◈ 5 30

5 25

Output of: static void Main(string[] args) { int x = 4, y = 5, z = 7; switch (x + y - z) { case 0: case 2: ++x; z += y; break; case 1: --x; z -= y; break; default: x += y; break; } Console.WriteLine(x + "\t" + y + "\t" + z); Console.ReadLine(); } ◈ 12 5 5 ◈ 5 12 12 ◈ 5 12 5 ◈ 5 5 12

5 5 12

Output of: class Program { public static void Main(string[] args) { int i = 1; for (int a = 0; a < 5; a++) { int i = 2; Console.WriteLine(a * i); } Console.ReadLine(); } } ◈ 0 1 2 3 4 ◈ A compile time error occurs ◈ 0 2 4 6 8 ◈ 0 5 10 15 20

A compile time error occurs

*Which of the following statements is true regarding the given C# program? class Program { public int Add(int a, int b) { int x = a + b; return x; } public double Add(int a, int b) { double y = a + b + 0.0; return y; } public static void Main(String[] args) { Program p = new Program(); int x = p.Add(1, 2); Console.WriteLine(x); double y = p.Add(1, 2); Console.WriteLine(y); } } ◈ output: 3, 3 ◈ output: 3, 3.0 ◈A compile time error will occur because the method Add() has the same parameter types. ◈ A compile time error for implicit conversion from double to int will occur.

A compile time error will occur because the method Add() has the same parameter types.

What will be the output of the following code? static void Main(string&lsqb;] args) {String x = "Application";String a;y = x.Replace('p', 'f');Console.WriteLine(y);Console.ReadLine(); } ◈ Afplication ◈ Apflication ◈ Afflication ◈ Applicationff

Afflication

#Which of the following expressions is the odd one out? ◈ !(-8<0 or 8==10) ◈ !(-10<0 or 10>-10) ◈ !(-8>8 or-8==8) ◈ -8>=0 and 0<=8

!(-8>8 or-8==8)

*Output of: static void Main(string&lsqb;] args) { String c = " Hello uCertify "; String a = c.Trim(); Console.WriteLine("\"" + a + "\""); } ◈ "Hello uCertify" ◈ " Hello uCertify" ◈ "HellouCertify" ◈ Hello uCertify

"Hello uCertify"

*Which of the following are the bitwise operators in C#? ◈ <= and >= ◈ += and = ◈ &&, ||, and != ◈ &, |, and ^

&, |, and ^

*Output of: static void Main(string[] args) { int i = 1, j = 1; while (++i <= 10) { j++; } Console.WriteLine(i + " " + j); Console.ReadLine(); } ◈ 10 10 ◈ 11 11 ◈ 11 10 ◈ 10 11

11 10

Output of: static void Main(string[] args) { int i = 2, j = 3, k = 4; switch (i + j - k) { case 0: case 2: case 4: ++i; k += j; break; case 1: case 3: case 5 : --i; k -= j; break; default: i += j; break; } Console.WriteLine(i + "\n" + j + "\n" + k); Console.ReadLine(); } ◈ 1 3 1 ◈ Compile time error ◈ 5 3 4 ◈ 2 3 4

1 3 1

#Output of: class Program { enum emp: int { John, Maria, Mary = 5, Peter, Jack = 10, Zoe } static void Main(string[] args) { Console.Write((int) emp.Maria + ", "); Console.Write((int) emp.Peter + ", "); Console.Write((int) emp.Jack + ", "); Console.Write((int) emp.Zoe); Console.ReadKey(); } } ◈ 2, 6, 10, 11 ◈ 1, 6, 10, 8 ◈ 1, 6, 10, 11 ◈ 2, 6, 7, 8

1, 6, 10, 11

Output of: static void Main(string[] args) { float s = 0.1f; while (s <= 0.5f) { ++s; Console.WriteLine(s); } Console.ReadLine(); } ◈ No output ◈ 1.1 ◈ 0.1 0.2 0.3 0.4 0.5 ◈ 0.1

1.1

Output of: class Program { static void Main(string[] args) { int number = 10; while (number) { number--; Console.WriteLine(number); Console.ReadLine(); } } } ◈ 0 ◈ 10 ◈ 9 ◈ The code will not compile

The code will not compile


संबंधित स्टडी सेट्स

us government - unit 1: the history of civics and government

View Set

Simple Interest and Simple Discount

View Set

Common benign conditions of the skin

View Set