Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Consider the following interface. public interface TwoDshape 1 double getarea ( ) : double getperimeter ( ) ; s Which of these classes correctly implements

Consider the following interface.
public interface TwoDshape
1
double getarea():
double getperimeter();
s
Which of these classes correctly implements the interface?
I.
public class square implements TwoDshape
{
int sideLength;
public square(int sLen)
}
sideLength = sLen;
}
public int getarea()
{ return sideLength * sideLength; }
public int getperimeter()
}
{ return 4* sidelength; }
II.
public class square implements TwoDShape
1
int sideLength;
public square(int sLen)
q
sideLength = sLen;
}
public double getarea(int slen)
{ return sLen * sLen; }
public double getperimeter()
}
{ return 4* sideLength; }
III. public class Square implements TwoDShape
1
int sidelength;
public square (int sLen)
1
sideLength = sLen;
}
public double getarea(int sLen)
return sLen * sLen; }
public double getarea()
return sidelength * sidelengthi }
public double getperimeter()
}
{ return 4** sideLength; }
(A) I only
(B) II only
(C) III only
(D) I and II only
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions