Question
Consider the following code snippet: public class Inventory implements Measurable { . . . double getMeasure(); { return onHandCount; } } The compiler complains that
Consider the following code snippet:
public class Inventory implements Measurable
{
. . .
double getMeasure();
{
return onHandCount;
}
}
The compiler complains that the getMeasure method has a weaker access level than the Measurable interface. Why?
a) All of the methods in a class have a default access level of package access, while the methods of an interface have a default access level of private.
b) All of the methods in a class have a default access level of package access, while the methods of an interface have a default access level of public.
c) The variable onHandCount was not declared with public access.
d) The getMeasure method was declared as private in the Measurable interface.
2.Under which of the following conditions would the public interface of a class be considered cohesive?
a) All of its features are public and none of its features are static.
b) The quality of the public interface is rated as moderate to high.
c) All of its features are related to the concept that the class represents.
d) It is obvious that the public interface refers to multiple concepts.
15. Determine the output of this program.
interface A
{
void myMethod();
}
class B
{
public void myMethod()
{
System.out.println("My Method");
}
}
class C extends B implements A
{
}
class MainClass
{
public static void main(String[] args)
{
A a = new C();
a.myMethod();
}
}
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