wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Preliminary Examination - OOP

Total questions: 40

Worksheet time: 40mins

Name
Class
Date
1.

What part is not considered in a method’s signature for overloading purposes?

a)

Name

b)

Parameter types/order

c)

Return type

d)

Access modifier

2.

Which keyword indicates a method belongs to the class, not an instance?

a)

abstract

b)

static

c)

virtual

d)

override

3.

Empty parentheses in a method declaration mean:

a)

It's abstract

b)

It takes no parameters

c)

It's optional

d)

It's static

4.

Which is true about the ref parameter?

a)

Caller need not initialize the variable

b)

The method must assign it before returning

c)

Caller must initialize it; method can modify it

d)

Equivalent to passing by value

5.

out parameters require that:

a)

The argument is initialized before call

b)

The method assigns a value before returning

c)

Neither the caller nor method needs initialization

d)

Only reference types can use out

6.

What is in used for?

a)

Modify the argument inside the method

b)

Pass as read-only reference

c)

Drop the argument after use

d)

Same as out

7.

Can you overload two methods that differ only by ref vs out?

a)

Yes

b)

No

8.

Overloading is allowed if one method has ref/out and the other has no modifiers.

a)

True

b)

False

9.

Which modifier allows passing by reference without modification?

a)

ref

b)

out

c)

in

d)

none of the above

10.

Are async methods allowed to have ref, out, or in parameters?

a)

All allowed

b)

Only ref allowed

c)

None are allowed

d)

Only in allowed

11.

Why can’t properties be passed via ref or out?

a)

They’re methods, not variables

b)

Properties create copies

c)

It's allowed—no restriction

d)

Only allowed with in

12.

Which of these is a valid overload pair?

a)

void M(out int x) and void M(ref int x)

b)

void M(int x) and void M(ref int x)

c)

void M(in int x) and void M(out int x)

d)

void M(ref int x) and void M(in int x)

13.

What error occurs if overload conflicts with only ref vs out difference?

a)

CS0012

b)

CS0663

c)

CS1001

d)

No error

14.

You must use the same modifier (ref/out/in) at the call site as in the method’s signature (except in optional).

a)

True

b)

False

15.

Is the return type relevant when invoking overloaded methods?

a)

Yes

b)

No

16.

For ref readonly, at the call site you can use:

a)

only ref

b)

only in

c)

either ref or in

d)

no modifier

17.

Which of the following is not allowed in extension methods?

a)

out on the first argument

b)

ref on the first argument when not struct

c)

in on the first argument unless struct

d)

in on any generic type—even constrained to struct

18.

Method parameters are always separated by:

a)

Semicolons

b)

Commas

c)

Spaces

d)

Colons

19.

A method defined with => x * x; is known as:

a)

Lambda method

b)

Expression-bodied method

c)

Inline method

d)

Anonymous method

20.

Instance methods require:

a)

static keyword

b)

Creating an object instance

c)

virtual modifier

d)

Abstract class

21.

Return type is part of the signature when overloading methods.

a)

True

b)

False

22.

A static method can't access instance members without an object.

a)

True

b)

False

23.

Caller must initialize an out variable before calling the method.

a)

True

b)

False

24.

in prevents modification of the argument inside the method.

a)

True

b)

False

25.

You can overload methods that differ only by ref vs. out.

a)

True

b)

False

26.

Overloading is possible if one method uses ref and another has no modifiers.

a)

True

b)

False

27.

Async methods cannot have ref, out, or in parameters.

a)

True

b)

False

28.

ref readonly parameters cannot be read inside the method.

a)

True

b)

False

29.

You must use ref, out, or in at the call site exactly as in the definition (except optional in).

a)

True

b)

False

30.

Properties can be passed to methods via ref or out.

a)

True

b)

False

31.

out parameters can be declared inline at the call site starting C# 7.0.

a)

True

b)

False

32.

The in modifier may allow the compiler to pass by value via temporary variable.

a)

True

b)

False

33.

Named arguments must come after positional arguments when mixing.

a)

True

b)

False

34.

A method with no parameters uses empty parentheses.

a)

True

b)

False

35.

Extension methods can use out on the first parameter.

a)

True

b)

False

36.

Overload resolution considers only parameter types and modifiers, not return type.

a)

True

b)

False

37.

Using too many overloads can confuse which is called.

a)

True

b)

False

38.

ref readonly makes an argument immutable within the method.

a)

True

b)

False

39.

Generic method constraints are part of the method signature for overloading.

a)

True

b)

False

40.

Multiple constructors provide better extensibility than optional parameters.

a)

True

b)

False