Question
21-Given the following code snippet: for(Circle c:circles) { System.out.println(c.toString()); } Select one: a. The compiler will report an error if the toString( ) method is
21-Given the following code snippet:
for(Circle c:circles)
{
System.out.println(c.toString());
}
Select one:
a. The compiler will report an error if the toString( ) method is not defined in the Circle class
b. All of these
c. The compiler will report an error if the toString( ) method is not overridden in the Circle class
d. The compiler will call the toString( ) method of the parent class of class Circle if it is not defined in the Circle class
22-In the following code:
public interface Lambdas extends Shape{
void print();
void printOdds(int n);
}
Select one:
a. Both Lambdas and Shape are interfaces
b. None of these
c. Lambdas is and interface but Shape is a class
d. Both Lambdas and Shape are classes
23-Java allows extending multiple classes through a single class declaration statement such as:
public class Student extends Person, Human {
//code goes here
} Select one: True False
24-Overloaded methods are differentiated by:
Select one:
a. Number of arguments
b. Data type of arguments
c. Number and the Data type of the arguments
d. None of the these
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started