Modern Programming Languages MCQs with Answers
Practice important Modern Programming Languages MCQs with answers and explanations.
Chapter: 31
Q621:
In C#, structs cannot have _______.
A. constructors
B. methods
C. fields
D. events
Correct Answer:
A
Chapter: 31
Q622:
Which of the following does NOT belong to the C# data types?
A. struct
B. class
C. array
D. table
Correct Answer:
D
Chapter: 31
Q623:
What would be the output of the following code: string s1 = "hello"; s1 = "world";
A. hello
B. world
C. both hello and world
D. Error
Correct Answer:
B
Chapter: 31
Q624:
Which of the following is true about C# properties?
A. They are like fields
B. They can be accessed like variables
C. They are equivalent to methods
D. They cannot have both get and set methods
Correct Answer:
B
Chapter: 31
Q625:
In C#, which data type is used to store Unicode characters?
A. char
B. string
C. int
D. bool
Correct Answer:
A
Chapter: 31
Q626:
What is the range of an int in C#?
A. -32768 to 32767
B. -2147483648 to 2147483647
C. 0 to 255
D. 0 to 65535
Correct Answer:
B
Chapter: 32
Q627:
In C#, which type of code is executed under the control of the Common Language Runtime (CLR)?
A. Managed code
B. Unmanaged code
C. Unsafe code
D. Native code
Correct Answer:
A
Chapter: 32
Q628:
What is the primary purpose of using pointers in C#?
A. Accessing memory locations
B. Writing cleaner code
C. Allocating dynamic memory
D. Managing string operations
Correct Answer:
A
Chapter: 32
Q629:
Which of the following is true about C# pointers?
A. They can point to reference types
B. They are used in unsafe code only
C. They work in both managed and unmanaged code
D. They work with Java data types
Correct Answer:
B
Chapter: 32
Q630:
What is the role of the garbage collector in C#?
A. To handle explicit memory allocation
B. To automatically free unused memory
C. To track memory errors
D. To optimize the use of pointers
Correct Answer:
B
Chapter: 32
Q631:
The 'unsafe' keyword in C# is used to declare code that works with _______.
A. Managed code
B. Unmanaged code
C. Arrays
D. Strings
Correct Answer:
B
Chapter: 32
Q632:
Which of the following can be a disadvantage of using unsafe code in C#?
A. Easier debugging
B. Stack overflow
C. Automatic memory management
D. Simplified syntax
Correct Answer:
B
Chapter: 32
Q633:
What does the 'fixed' keyword in C# prevent?
A. Memory leaks
B. Stack overflow
C. The garbage collector from moving objects
D. Syntax errors
Correct Answer:
C
Chapter: 32
Q634:
What is the purpose of the '->' operator in C#?
A. Dereference pointers to structs
B. Declare arrays
C. Access array elements
D. Access private methods
Correct Answer:
A
Chapter: 32
Q635:
How are arrays in C# similar to arrays in Java?
A. Both use the 'new' operator for declaration
B. Both allow fixed-size arrays
C. Both are reference types
D. Both require manual garbage collection
Correct Answer:
A
Chapter: 32
Q636:
What is a rectangular array in C#?
A. An array with a fixed size for each dimension
B. An array with irregular dimensions
C. An array of arrays
D. An array containing elements of different types
Correct Answer:
A
Chapter: 32
Q637:
Which of the following is true about jagged arrays in C#?
A. They are multidimensional arrays with fixed sizes
B. They can hold arrays of different lengths
C. They are stored as single-dimensional arrays
D. They cannot hold references to other arrays
Correct Answer:
B
Chapter: 32
Q638:
In C#, which type of array is declared as an array of arrays?
A. Rectangular array
B. Jagged array
C. Dynamic array
D. Multidimensional array
Correct Answer:
B
Chapter: 32
Q639:
How are enumerations used in C#?
A. They define constant values
B. They define functions
C. They store user input
D. They are used for dynamic memory allocation
Correct Answer:
A
Chapter: 32
Q640:
What is the default data type for C# enumerations?
A. String
B. Integer
C. Char
D. Long
Correct Answer:
B