C# Programming Trivia: Quiz!

Reviewed by Editorial Team
The ProProfs editorial team is comprised of experienced subject matter experts. They've collectively created over 10,000 quizzes and lessons, serving over 100 million users. Our team includes in-house content moderators and subject matter experts, as well as a global network of rigorously trained contributors. All adhere to our comprehensive editorial guidelines, ensuring the delivery of high-quality content.
Learn about Our Editorial Process
| By Anitha
A
Anitha
Community Contributor
Quizzes Created: 2 | Total Attempts: 2,629
| Attempts: 231 | Questions: 9
Please wait...
Question 1 / 9
0 %
0/100
Score 0/100
1. A=(5>6)?8:10 Consol.Writeline(a); what would be the output of this statement is a conditional statement.

Explanation

The given statement is a conditional statement. It checks if the condition "5>6" is true or false. Since the condition is false, the value after the colon (10) is assigned to the variable A. Therefore, the output of the statement would be 10.

Submit
Please wait...
About This Quiz
C# Programming Trivia: Quiz! - Quiz

Dive into the intricacies of C# with our engaging C# Programming Trivia Quiz! Test your understanding of exception handling, conditional statements, code management, JIT compilation, and object-oriented programming. Perfect for learners looking to refine their C# skills.

Personalize your quiz and earn a certificate with your name on it!
2. Using System; class program { static void Main(string[] args) { int num = 2; fun1 (ref num); Console.WriteLine(num); Console.ReadLine(); } static void fun1(ref int num) { num = num * num * num; } }

Explanation

The code provided defines a class called "program" with a method called "fun1" that takes an integer parameter by reference. In the Main method, an integer variable "num" is initialized with the value 2. The fun1 method is then called, passing the "num" variable as a reference. Inside the fun1 method, the value of "num" is updated by multiplying it by itself three times (2 * 2 * 2 = 8). Finally, the updated value of "num" is printed, which is 8.

Submit
3. Using System; class sample { public static void first() { Console.WriteLine("first method"); } public void second() { first(); Console.WriteLine("second method"); } public void second(int i) { Console.WriteLine(i); second(); } } class program { public static void Main() { sample obj = new sample(); sample.first(); obj.second(10); } }

Explanation

The correct answer is "first method 10 first method second method".

In the given code, there is a class called "sample" with two methods: "first" and "second". The "first" method is a static method, meaning it can be called without creating an object of the class. The "second" method is an instance method, meaning it can only be called using an object of the class.

In the "Main" method, an object of the "sample" class is created and assigned to the variable "obj". Then, the "first" method is called using the class name directly, which prints "first method" to the console.

Next, the "second" method is called on the object "obj" with an argument of 10. This calls the second overload of the "second" method, which prints the value of the argument (10) and then calls the first overload of the "second" method. The first overload of the "second" method calls the "first" method again and then prints "second method" to the console.

Therefore, the output is "first method 10 first method second method".

Submit
4. Can multiple catch blocks be executed?

Explanation

No, Multiple catch blocks can’t be executed. Once the proper catch code executed, the control is transferred to the final block and then the code that follows the final block gets executed.

Submit
5. Using System; class emp { public string name; public string address; public void display() { Console.WriteLine("{0} is in city {1}", name, address); } } class Program { static void Main(string[] args) { emp obj = new emp(); obj.name = "Akshay"; obj.address = "new delhi"; obj.display(); Console.ReadLine(); } }

Explanation

The given code defines a class "emp" with two public string variables "name" and "address" and a public method "display" that prints the name and address of an object of the "emp" class. In the Main method, an object "obj" of the "emp" class is created, its name and address are assigned, and the display method is called. The display method uses string formatting to print the name and address. The correct answer "Akshay is in city new delhi" is the correct output of the display method, as it correctly formats the name and address.

Submit
6. Shape obj; obj = new shape();

Explanation

The code "shape obj; obj = new shape();" creates a reference variable "obj" of the class "shape" and then creates an object of type "shape" on the heap using the "new" keyword. This means that the object is dynamically allocated in memory and can be accessed through the reference variable "obj". This is why the correct answer is "create a reference obj of the class shape and an object of type shape on the heap."

Submit
7. Using System; class program { static void Main(string[] args) { int x = 8; int b = 16; int c = 64; x /= c /= b; Console.WriteLine(x + " " + b+ " " +c); Console.ReadLine(); } }

Explanation

The given code snippet demonstrates the use of compound assignment operators. The expression "x /= c /= b" is evaluated from right to left. First, "c /= b" is evaluated, which means "c = c / b", resulting in c = 4. Then, "x /= c" is evaluated, which means "x = x / c", resulting in x = 2. Therefore, the output of the code will be "2 16 4".

Submit
8. Just-in-Time (JIT) Compilation: This is the term for the process of performing the ___ stage of compilation from IL into native machine code.

Explanation

The correct answer is INTERMEDIATE because JIT compilation is the process of converting Intermediate Language (IL) code into native machine code at runtime. This means that the compilation happens just before the code is executed, allowing for optimizations based on the current state of the system. Therefore, the intermediate stage refers to the step where IL code is transformed into native machine code.

Submit
9. What actually manages your code?

Explanation

The Common Type System (CTS) is responsible for managing code in the .NET framework. It defines how types are declared, used, and managed in the runtime environment. The CTS ensures type safety and interoperability between different languages in the .NET framework. It also provides metadata about types, which is used by the Common Language Runtime (CLR) for various purposes such as memory management and security. Therefore, the CTS is the correct answer as it is the component that actually manages code in the .NET framework.

Submit
View My Results

Quiz Review Timeline (Updated): Mar 19, 2023 +

Our quizzes are rigorously reviewed, monitored and continuously updated by our expert board to maintain accuracy, relevance, and timeliness.

  • Current Version
  • Mar 19, 2023
    Quiz Edited by
    ProProfs Editorial Team
  • Dec 18, 2017
    Quiz Created by
    Anitha
Cancel
  • All
    All (9)
  • Unanswered
    Unanswered ()
  • Answered
    Answered ()
A=(5>6)?8:10...
Using System; class program { static void Main(string[] args) { int...
Using System; class sample { public static void first() {...
Can multiple catch blocks be executed?
Using System; class emp { public string name; public string address;...
Shape obj; obj = new shape();
Using System; class program { static void Main(string[] args) { int x...
Just-in-Time (JIT) Compilation: This is the term for the process of...
What actually manages your code?
Alert!

Advertisement