Vidyalelo
C# Programming · all questions

Functions and Methods in C Sharp
practice.

Practice every MCQ with options. Use Show answers when you want the correct option and solution.

54

Questions

2/3

Page

Pick an option on a question to see the right answer and solution.

What is the purpose of method parameters in C#?

Select an option to see the answer and solution.

What is the result of the expression Math.Round(4.5) in C#?

Select an option to see the answer and solution.

What is the correct syntax to declare a method named PrintMessage that prints a message to the console without returning any value in C#?

Select an option to see the answer and solution.

In C#, which keyword is used to define a method that cannot be overridden in derived classes?

Select an option to see the answer and solution.

What is the purpose of method overloading in C#?

Select an option to see the answer and solution.

What is the correct way to declare a method named GetAbsoluteValue that takes an integer parameter num and returns its absolute value in C#?

Select an option to see the answer and solution.

In C#, which method is used to convert a string representation of a number to its integer equivalent?

Select an option to see the answer and solution.

What is the correct syntax to define a method named CalculateArea that calculates the area of a rectangle with length and width parameters in C#?

Select an option to see the answer and solution.

In C#, which keyword is used to define a method that can be overridden in derived classes?

Select an option to see the answer and solution.

What is the correct way to call a method named PrintName with a string parameter name in C#?

Select an option to see the answer and solution.

What is the purpose of method parameters in C#?

Select an option to see the answer and solution.

Which of the following access modifiers allows a method to be accessed only within the same assembly in C#?

Select an option to see the answer and solution.

What is the result of the expression Math.Floor(4.6) in C#?

Select an option to see the answer and solution.

What is the correct way to define a method named IsEven that takes an integer parameter num and returns true if the number is even, otherwise false, in C#?

Select an option to see the answer and solution.

In C#, which keyword is used to define a method that is implemented in a derived class to provide a specific implementation for a method defined in the base class?

Select an option to see the answer and solution.

What is the correct way to declare a method named PrintMessage that prints a message to the console without taking any parameters or returning any value in C#?

Select an option to see the answer and solution.

In C#, which method is used to convert a string to its uppercase equivalent?

Select an option to see the answer and solution.

What is the purpose of method overloading in C#?

Select an option to see the answer and solution.

What is the correct syntax to define a method named CalculateAverage that calculates the average of an array of integers in C#?

Select an option to see the answer and solution.

In C#, which keyword is used to define a method that cannot be overridden in derived classes?

Select an option to see the answer and solution.