Skip to main content

Modern Programming Languages MCQs with Answers

Practice important Modern Programming Languages MCQs with answers and explanations.

Multiple Choice Questions

Q661: In C#, which statement is used to break out of a loop or switch statement?
  • A: return
  • B: continue
  • C: goto
  • D: break
View Answer
D

Q662: What will be the output of the following switch statement if a = 2?switch(a){ case 2: Console.WriteLine("a>1"); goto case 1; case 1: Console.WriteLine("a>0"); break; default: Console.WriteLine("a is not set"); break; }
  • A: a>1
  • B: a>0
  • C: a is not set
  • D: No output
View Answer
A

Q663: Which keyword in C# is used to indicate that a class cannot be inherited from?
  • A: public
  • B: sealed
  • C: abstract
  • D: internal
View Answer
B

Q664: In C#, the 'new' keyword is used for which of the following?
  • A: Static classes
  • B: Nested classes
  • C: Inheritance Methods
  • D: Access Modifiers
View Answer
B

Q665: Which loop type is similar to the 'do-while' loop but is executed at least once before checking the condition?
  • A: for
  • B: while
  • C: do-while
  • D: None of the above
View Answer
C

Q666: What will be the result of the following C# expression: a=5; x=a++ + --a; if evaluated right-to-left?
  • A: 8
  • B: 10
  • C: 5
  • D: 6
View Answer
B

Q667: In C#, the switch statement's expression can be of which types?
  • A: Integer or string
  • B: Boolean or integer
  • C: Boolean or character
  • D: Integer or float
View Answer
A

Q668: In C#, which class modifier is used to specify a class that cannot be instantiated directly?
  • A: abstract
  • B: sealed
  • C: public
  • D: protected
View Answer
A

Q669: What happens if a case statement in a switch expression does not contain a jump statement in C#?
  • A: No compilation error
  • B: Compilation error
  • C: Program crashes
  • D: None of the above
View Answer
B

Q670: Which control flow statement in C# is used to immediately exit from the switch, loop, or method?
  • A: break
  • B: continue
  • C: return
  • D: goto
View Answer
A

Test Your Knowledge

Take a timed quiz on Modern Programming Languages

🚀 Start Quiz Now