21. What is the purpose of method parameters in C#? A. To define the name of the method B. To specify the return type of the method C. To define the access modifier of the method D. To pass data to the method Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option D No explanation is given for this question Let's Discuss on Board
22. What is the result of the expression Math.Round(4.5) in C#? A. 4 B. 5 C. 4.5 D. 5.4 Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option B No explanation is given for this question Let's Discuss on Board
23. What is the correct syntax to declare a method named PrintMessage that prints a message to the console without returning any value in C#? A. PrintMessage: { Console.WriteLine("Message"); } B. void PrintMessage { Console.WriteLine("Message"); } C. PrintMessage() { Console.WriteLine("Message"); } D. void PrintMessage() { Console.WriteLine("Message"); } Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option D No explanation is given for this question Let's Discuss on Board
24. In C#, which keyword is used to define a method that cannot be overridden in derived classes? A. final B. static C. sealed D. const Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option C No explanation is given for this question Let's Discuss on Board
25. What is the purpose of method overloading in C#? A. To allow methods with the same name and signature B. To override existing methods C. To allow methods with the same name but different signatures D. To restrict access to methods Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option C No explanation is given for this question Let's Discuss on Board
26. What is the correct way to declare a method named GetAbsoluteValue that takes an integer parameter num and returns its absolute value in C#? A. GetAbsoluteValue(num) { return Math.Abs(num); } B. int GetAbsoluteValue(int num) { return Math.Abs(num); } C. GetAbsoluteValue { return Math.Abs(num); } D. None of the above Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option B No explanation is given for this question Let's Discuss on Board
27. In C#, which method is used to convert a string representation of a number to its integer equivalent? A. string.ToInt() B. Math.ToInt() C. int.Parse() D. Convert.ToInt32() Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option C No explanation is given for this question Let's Discuss on Board
28. 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#? A. double CalculateArea(double length, double width) { return length * width; } B. CalculateArea(double length, double width) { return length * width; } C. double CalculateArea(length, width) { return length * width; } D. CalculateArea { double length * double width; } Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option B No explanation is given for this question Let's Discuss on Board
29. In C#, which keyword is used to define a method that can be overridden in derived classes? A. virtual B. overridable C. extendable D. override Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option D No explanation is given for this question Let's Discuss on Board
30. What is the correct way to call a method named PrintName with a string parameter name in C#? A. PrintName("John"); B. PrintName(name: "John"); C. PrintName = "John"; D. PrintName(name); Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option B No explanation is given for this question Let's Discuss on Board