c#

Pataasin ang iyong marka sa homework at exams ngayon gamit ang Quizwiz!

Which of the following expressions is the odd one out?

!(-10<0 or 10>-10) !(-8<0 or 8==10) -8>=0 and 0<=8 (X)!(-8>8 or-8==8)

What will be the output of the following C# program? 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();}

Not Known The value of j is 45 The value of j is 25 (X)The value of j is 35

Which of the following statements are true regarding the Main() function? Each correct answer represents a complete solution. Choose all that apply.

The args parameter of Main() helps to include the .NET libraries. (X)The Main() function in a console application can receive command line parameters. (X)The Main() function can return either void or int. (X)Any value returned from the Main() function is stored in an environment variable.

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); }}

The code will be executed successfully and print the following output:33.0 A compile time error for implicit conversion from double to int will occur. (X)A compile time error will occur because the method Add() has the same parameter types. The code will be executed successfully and print the following output:33

Which of the following return statements correctly returns the output?

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

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

|| < && < != < & < % (X)|| < && < & < != < % && < || < != < % < & && < || < != < & < %

What will be the output of the following 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 (X)5 25 5 30

What will be the output of the following code? 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(); }

2 3 4 5 3 4 Compile time error (X)1 3 1

Which of the following are the bitwise operators in C#?

&&, ||, and != (X)&, |, and ^ <= and >= += and =

What will be the output of the following C# program? 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(); }}

(X)1, 6, 10, 11 2, 6, 7, 8 2, 6, 10, 11 1, 6, 10, 8

Question 13 :What will be the output of the following code?static void Main(string[] args) { float s = 0.1f; while (s <= 0.5f) { ++s; Console.WriteLine(s); } Console.ReadLine();}

(X)1.1 0.1 0.2 0.3 0.4 0.5 0.1 No output

What will be the output of the following C# program? 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();}

(X)5 5 12 12 5 5 5 12 12 5 12 5

Which of the following are correct statements for Parameters? Each correct answer represents a complete solution. Choose all that apply.

(X)Each of the parameter is accessible from code within the function as a variable. (X)These are defined as part of a function definition. These are passed to a function by calling code. (X)These are separated using commas.

What will be the output of the following C# program? 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); } }

(X)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 -> I am a CSharp expert

What are delegates in C#? Each correct answer represents a complete solution. Choose all that apply.

(X)The declaration of a delegate and the signature of the method that we intend to call should be the same. (X)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. Only one method can be called using a delegate.

Which of the following are correct about explicit conversion? Each correct answer represents a complete solution. Choose all that apply.

(X)The rules for conversion are complicated enough to merit additional processing of some kind. (X)Conversion from type A to type B is possible only in certain circumstances. Conversion from type A to type B is possible in all circumstances. The rules for performing the conversion are simple enough for a user to trust in the compiler.

Which of the following statements are true regarding the following code snippet? var a = 90;function f1() { var x = 9; function f2() { var y = 10; }} Each correct answer represents a complete solution. Choose all that apply.

(X)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. (X)The variable a is global.

What will be the output of the following code? bool x = true; bool y = false; x |= y; Console.WriteLine(x); Console.ReadLine();

(X)True 1 0 False

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

(X)Tuple Delegate Array Parameter

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 }}

(X)delegate int d (int a, double b); delegate void d (int a, double b); delegate void (int a, double b); delegate double d (int a, double b);

Which of the following cannot be used as a data type for an enum in C#?

(X)double None of these int short

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

(X)i = (int) d; i = double (d) d = (int) i; int i = (double) d

Which of the following strings will be the correct output of the given C# program? 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 (X)Iwant*******Iwant toLearnCSHARP *******want toLearnCSHARP CSHARP*******want toLearn

What will be the output of the given code? class Program { static void Main(string[] args) { int number = 10; while (number) { number--; Console.WriteLine(number); Console.ReadLine(); } }}

0 10 9 (X)The code will not compile.

What is the output of the following C# program? 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 0 5 10 15 20 0 2 4 6 8 (X)A compile time error occurs

What will be the output of the following code? class Example { 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 2 4 6 8 (X)A compile time error occurs 0 1 2 3 4 0 5 10 15 20

What will be the output of the following code? enum cal { a, b, c, d, } cal.a = 10; Console.writeline(cal.b);

1 11 (X)Compile time error 2

What will be the output of the following C# program? static void Main(string[] args) { int i = 1, j = 1; while (++i <= 10) { j++; } Console.WriteLine(i + " " + j); Console.ReadLine();}

10 11 10 10 11 11 (X)11 10

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();}

Apflication Afplication Applicationff (X)Afflication

Question 9 :What will be the output of the following code?static void Main(string[] args) { String y = "C#"; String x = y + "Language"; Console.WriteLine(x); Console.ReadLine();}

C# Language "C#Language" "C# Language" (X)C#Language

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 (X)true

What will be the output of the following code? static void Main(string&lsqb;] args) {String c = " Hello uCertify ";String a = c.Trim();Console.WriteLine("\"" + a + "\"");}

Hello uCertify "HellouCertify" " Hello uCertify" (X)"Hello uCertify"

What is the output of the following C# program? 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. (X)Hello!!Learn CSharp Programming Language. A compile time error will occur. Welcome to uCertify.Learn CSharp Programming Language.

What will be the output of the following C# program? 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); Console.ReadKey(); }

I am a CSharp expert-> I am a CSharp expert I am a CSharp expertI AM A CSHARP EXPERTI ->AM A CSHARP EXPERT (X)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

Consider the following C# program: 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 = 1First Name = BillLast Name = Gates Which of the following lines of code will be placed on Line 1 to print the required output?

Info (Tuple <int, string, string> record) Info (record, Tuple <1, "Bill", "Gates">) Tuple <int, string, string> -> Info () (X)Tuple <int, string, string> Info ()

Which of the following statements are true of a jagged array? Each correct answer represents a complete solution. Choose all that apply.

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

Consider the following C# program: 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? Each correct answer represents a complete solution. Choose all that apply.

Line 4 will print the value of variable 'a' as 1. (X)Line 6 will print the value of variable 'b' as 2. The error "Multiple declaration of 'value' variable" will occur during compilation. (X)The error "Use of unassigned local variable 'a'" will appear during compilation.

Consider the following code: 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; } Which of the following is true regarding the given code?

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. (X)The error "Use of unassigned local variable a" will appear during compilation.

Which of the following statements is true about delegates?

They are type safe. (X)They are reference types. They are declared within a function body. Multiple methods can be called using a delegate.

What are delegates in C#? Each correct answer represents a complete solution. Choose all that apply.

We can call only one method using a delegate. (X)The declaration of a delegate and the signature of the method that we intend to call should be the same. (X)It allows the programmer to encapsulate a reference to a method inside an object. We cannot pass a delegate variable to a function as a parameter.

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 void (int a, double b); delegate void d (int a, double b); (X)delegate int d (int a, double b); delegate double d (int a, double b);

Which of the following for statements will not produce any output?

for (var count = 0; count <= 10; count++) { Console.WriteLine(count); Console.ReadKey();} (X)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 = 5; count >= 5; count++) { Console.WriteLine(count); Console.ReadKey();}

Consider the given C# program: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:MangoAppleCherryWhich of the following code snippets are appropriate to complete the given code for producing the required output?Each correct answer represents a complete solution. Choose all that apply.

int i;while(i<=3) { Console.WriteLine(fruits[i]);} int i;if (i <= 0) { Console.WriteLine(fruits[i]);} else i++; (X)foreach(string basket in fruits) { Console.WriteLine(basket);} (X)int i;for (i = 0; i < fruits.Length; i++) { Console.WriteLine(fruits[i]);}

Consider the following C# program:static void Main(string[] args) { { m(); Console.ReadLine(); } //Enter code}Which of the following return functions m() will print the output as 3? This task contains the radio buttons and checkboxes for options. Press the enter key to select the option. optionA int m(int d) {

int m(int d) { d = 3; return d;} void m(int d) { d = 3; Console.WriteLine(d);} (X)void m() { Console.WriteLine("3");} int m(int d)d = 3;return d;

Refer the following code snippet: student st;st.name="John";st.age=25;st.rollno=10234;Console.WriteLine(st.Detail()); 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?

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

Which of the following are the correct ways to define a variable of type struct student? struct student { public string name; public int age; public int rollno;} Each correct answer represents a complete solution. Choose all that apply.

student(); (X)student s; student new = s(); (X)student s = new student();

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"; break; default: "b is greater than a";} (X)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"; 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";

Which of the following methods of class is used to remove the leading and backward whitespaces?

trim() doTrim() startsWith() (X)Trim()


Kaugnay na mga set ng pag-aaral

Cell Cycle Intro and DNA Replication + PCR and Genome Variation

View Set

Chapter 10- Essential Peripherals

View Set

HY 136 Cooke | Test 1 Study Guide Multiple Choice

View Set