NEW
Font size
WorksheetsPreliminary Examination - OOP
Total questions: 40
Worksheet time: 40mins
What part is not considered in a method’s signature for overloading purposes?
Name
Parameter types/order
Return type
Access modifier
Which keyword indicates a method belongs to the class, not an instance?
abstract
static
virtual
override
Empty parentheses in a method declaration mean:
It's abstract
It takes no parameters
It's optional
It's static
Which is true about the ref parameter?
Caller need not initialize the variable
The method must assign it before returning
Caller must initialize it; method can modify it
Equivalent to passing by value
out parameters require that:
The argument is initialized before call
The method assigns a value before returning
Neither the caller nor method needs initialization
Only reference types can use out
What is in used for?
Modify the argument inside the method
Pass as read-only reference
Drop the argument after use
Same as out
Can you overload two methods that differ only by ref vs out?
Yes
No
Overloading is allowed if one method has ref/out and the other has no modifiers.
True
False
Which modifier allows passing by reference without modification?
ref
out
in
none of the above
Are async methods allowed to have ref, out, or in parameters?
All allowed
Only ref allowed
None are allowed
Only in allowed
Why can’t properties be passed via ref or out?
They’re methods, not variables
Properties create copies
It's allowed—no restriction
Only allowed with in
Which of these is a valid overload pair?
void M(out int x) and void M(ref int x)
void M(int x) and void M(ref int x)
void M(in int x) and void M(out int x)
void M(ref int x) and void M(in int x)
What error occurs if overload conflicts with only ref vs out difference?
CS0012
CS0663
CS1001
No error
You must use the same modifier (ref/out/in) at the call site as in the method’s signature (except in optional).
True
False
Is the return type relevant when invoking overloaded methods?
Yes
No
For ref readonly, at the call site you can use:
only ref
only in
either ref or in
no modifier
Which of the following is not allowed in extension methods?
out on the first argument
ref on the first argument when not struct
in on the first argument unless struct
in on any generic type—even constrained to struct
Method parameters are always separated by:
Semicolons
Commas
Spaces
Colons
A method defined with => x * x; is known as:
Lambda method
Expression-bodied method
Inline method
Anonymous method
Instance methods require:
static keyword
Creating an object instance
virtual modifier
Abstract class
Return type is part of the signature when overloading methods.
True
False
A static method can't access instance members without an object.
True
False
Caller must initialize an out variable before calling the method.
True
False
in prevents modification of the argument inside the method.
True
False
You can overload methods that differ only by ref vs. out.
True
False
Overloading is possible if one method uses ref and another has no modifiers.
True
False
Async methods cannot have ref, out, or in parameters.
True
False
ref readonly parameters cannot be read inside the method.
True
False
You must use ref, out, or in at the call site exactly as in the definition (except optional in).
True
False
Properties can be passed to methods via ref or out.
True
False
out parameters can be declared inline at the call site starting C# 7.0.
True
False
The in modifier may allow the compiler to pass by value via temporary variable.
True
False
Named arguments must come after positional arguments when mixing.
True
False
A method with no parameters uses empty parentheses.
True
False
Extension methods can use out on the first parameter.
True
False
Overload resolution considers only parameter types and modifiers, not return type.
True
False
Using too many overloads can confuse which is called.
True
False
ref readonly makes an argument immutable within the method.
True
False
Generic method constraints are part of the method signature for overloading.
True
False
Multiple constructors provide better extensibility than optional parameters.
True
False
