Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
11th Edition
ISBN: 9780134670942
Author: Y. Daniel Liang
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Question
Chapter 13.5, Problem 13.5.4CP
Program Plan Intro
Given Code:
//interface definition
interface A
{
//function declaration
void m1();
//close class
}
//class declaration to implement interface
class B implements A
{
//function call
void m1()
{
//print m1
System.out.println("m1");
}
}
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Modify the given codes to remove the compilation errors.
1. public interface Carnivore {
int pieces = 10;
public static void eatGrass();
public int chew() {
return 13;
}
}
2. Interface HasWings {
public int getNumberOfWings();
}
abstract class Insect implements HasWings {
abstract int getNumberOfLegs();
}
public class Dragonfly extends Insect {
int getNumberOfLegs() {
return 6;
}
}
PLZ help with the following
IN JAVA
Any constant variables defined in an interface must be defined as:
public
private
protected
package access
Subject : object Orieted Programming
Q: Find the error in the following given codes and rewrite.
a). public interface intt
{
public void P1 (String p)
{
System.out.println ("figure is " + p );
}
public double p2 ( ) ;
}
b). class B
{
final void r()
{
System.out.println("run");}
}
class H implements B
{
void r()
{
System.out.println("run run");
}
public static void main(String args[])
{
H h= new H();
h.r();
}
}
Chapter 13 Solutions
Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
Ch. 13.2 - Prob. 13.2.1CPCh. 13.2 - The getArea() and getPerimeter() methods may be...Ch. 13.2 - True or false? a.An abstract class can be used...Ch. 13.3 - Prob. 13.3.1CPCh. 13.3 - Prob. 13.3.2CPCh. 13.3 - Prob. 13.3.3CPCh. 13.3 - What is wrong in the following code? (Note the...Ch. 13.3 - What is wrong in the following code? public class...Ch. 13.4 - Can you create a Calendar object using the...Ch. 13.4 - Prob. 13.4.2CP
Ch. 13.4 - How do you create a Calendar object for the...Ch. 13.4 - For a Calendar object c, how do you get its year,...Ch. 13.5 - Prob. 13.5.1CPCh. 13.5 - Prob. 13.5.2CPCh. 13.5 - Prob. 13.5.3CPCh. 13.5 - Prob. 13.5.4CPCh. 13.6 - Prob. 13.6.1CPCh. 13.6 - Prob. 13.6.2CPCh. 13.6 - Can the following code be compiled? Why? Integer...Ch. 13.6 - Prob. 13.6.4CPCh. 13.6 - What is wrong in the following code? public class...Ch. 13.6 - Prob. 13.6.6CPCh. 13.6 - Listing 13.5 has an error. If you add list.add...Ch. 13.7 - Can a class invoke the super.clone() when...Ch. 13.7 - Prob. 13.7.2CPCh. 13.7 - Show the output of the following code:...Ch. 13.7 - Prob. 13.7.4CPCh. 13.7 - What is wrong in the following code? public class...Ch. 13.7 - Show the output of the following code: public...Ch. 13.8 - Prob. 13.8.1CPCh. 13.8 - Prob. 13.8.2CPCh. 13.8 - Prob. 13.8.3CPCh. 13.9 - Show the output of the following code: Rational r1...Ch. 13.9 - Prob. 13.9.2CPCh. 13.9 - Prob. 13.9.3CPCh. 13.9 - Simplify the code in lines 8285 in Listing 13.13...Ch. 13.9 - Prob. 13.9.5CPCh. 13.9 - The preceding question shows a bug in the toString...Ch. 13.10 - Describe class-design guidelines.Ch. 13 - (Triangle class) Design a new Triangle class that...Ch. 13 - (Shuffle ArrayList) Write the following method...Ch. 13 - (Sort ArrayList) Write the following method that...Ch. 13 - (Display calendars) Rewrite the PrintCalendar...Ch. 13 - (Enable GeometricObject comparable) Modify the...Ch. 13 - Prob. 13.6PECh. 13 - (The Colorable interface) Design an interface...Ch. 13 - (Revise the MyStack class) Rewrite the MyStack...Ch. 13 - Prob. 13.9PECh. 13 - Prob. 13.10PECh. 13 - (The Octagon class) Write a class named Octagon...Ch. 13 - Prob. 13.12PECh. 13 - Prob. 13.13PECh. 13 - (Demonstrate the benefits of encapsulation)...Ch. 13 - Prob. 13.15PECh. 13 - (Math: The Complex class) A complex number is a...Ch. 13 - (Use the Rational class) Write a program that...Ch. 13 - (Convert decimals to fractious) Write a program...Ch. 13 - (Algebra: solve quadratic equations) Rewrite...Ch. 13 - (Algebra: vertex form equations) The equation of a...
Knowledge Booster
Similar questions
- only in java not in java c++ 1. Define an interface named Shape with a single method named area that calculates the area of the geometric shape: public double area(); 2. Implement the Shape interface for Rectangle, Circle and Triangle class. 3. Implement a class CalculateAreas that has a function that takes shape type array of objects and builds an array of (double values) values for each corresponding shapesarrow_forwardExplain the following Java Interface code in details.interface A{public void m1();}abstract class B{public B(){System.out.println("Inside the Constructor of class B");}abstract public void m2();}class C extends B implements A{public C(){System.out.println("Inside the Constructor of class C");}public void m1(){System.out.println("Inside m1 method");}public void m2(){System.out.println("Inside m2 method");}}public class InterafceAbstractTest{public static void main(String args[]){C c = new C();c.m1();c.m2();//A a = new A();B b;b=c;//b.m1();b.m2();A a;a=c;a.m1();//a.m2();}}arrow_forwardIn java an interface with no fields or methods is known as a ______. A. Runnable Interface B. Marker Interface C. Abstract Interface D. CharSequence Interfacearrow_forward
- Create a class Reverse with one data member called num of type int and a static method find to return reverse of num. Create a subclass ReverseR from Reverse which overrides member of its super class. Write a main() method that tests in same class ReverseR. method find()) and this override method uses recursion to find and returns reverse of dataarrow_forwardJAVA public interface Interf1 { public void repeat(String s1); } Write a program to implement the above interface using lambda to accept hello world and print 10 times write a program to implement the above interface using inner class to accept hello world and print 10 timesarrow_forwardDoes it make sense to implement each and every method of an interface while doing so?arrow_forward
- Create the class DynamicArrayOfStrings that implements the following two interfacesarrow_forwardPLZ help with the following IN JAVA When defining an inner class to be a helper class for an outer class, the inner classes access should be marked as: Public Private Protected Package accessarrow_forwardWhat is included in the method private void buildLetterTable() { implemented in the class Anagramsarrow_forward
- PLZ help with the following in java TRUE OR FALSE An interface can contain defined constants as well as method headings or instead of method headings.arrow_forwardJAVA public interface Interf1 { public void repeat(String s1); } Implement the above interface using lambda to accept hello world and print ten times and implement the above interface using inner class to accept hello world and print ten timesarrow_forwardWrite in Java code. define instance variables for the class, a constructor to initialize those variables, one or more mutators to modify the variables, one or more accesssorsarrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education