Homework Help Question & Answers

Java Question 4 3 pts Briefly answer these questions about interfaces on an example code segment....

Java

Question 4 3 pts Briefly answer these questions about interfaces on an example code segment. • What is an interface? • How is
Question 4 3 pts Briefly answer these questions about interfaces on an example code segment. • What is an interface? • How is extending a class different from implementing an interface?
0 0
Add a comment
Answer #1

Sign Up to Unlock the answer FREE

Already have an account? Log in

Interface: In a class, we have the variable, method and we can define method there and also we can initialize variable. But In the interface we can only give method signature means we can say Interface is a blueprint of a class. In java, we use Interface to get an abstraction and multiple inheritances.

eg:

interface findShape{

string getShape();

}

* we use interface keyword before any interface.

--------------------------

class A extends B => Here B is a class

Here extends means class A will inherit all the methods and properties of class B.

class A implements C => Here C is an interface.

Here class A has to implement all the methods of interface C else it has to declare abstract.

So in general, extends means getting all the methods and properties from the parent class and Implements means defining all the method signatures of Interface.

Add a comment
Know the answer?
Add Answer to:
Java Question 4 3 pts Briefly answer these questions about interfaces on an example code segment....
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coin

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Topic Threads Posts Last Post Interfaces  Locked after Sunday, February 3, 2019 11:30 PM EST. 1....

    Topic Threads Posts Last Post Interfaces  Locked after Sunday, February 3, 2019 11:30 PM EST. 1. Explain Java interface and its use in a few sentences.  2. Write the code of one Java interface with one method. 3. Also write two Java classes that will implement the method of this interface, but each class will implement this method from the interface differently. Simply put System.out.println inside each method with different output to demonstrate different implementation. 4. Write a few sentences...

  • 1.     When a sub class object is created, when is the call to the super class...

    1.     When a sub class object is created, when is the call to the super class constructor made? How does a programmer call the super class constructor from the sub class? What do all classes indirectly extend? What methods does every class inherit from the Object class? 2.     When writing methods in a sub class, how can those methods call the methods from the parent class? 3.     Which class is more specific, a super class or a sub class? 4.    ...

  • In this lab you will work with abstract classes/interfaces. (Java Program) You will be implementing a...

    In this lab you will work with abstract classes/interfaces. (Java Program) You will be implementing a basic employee schema within a company. The Employee class will be an abstract class that will contain methods applicable to all employees. You will then create 2 classes called SoftwareEngineer and ProductManager. Both are different employee types based on occupation. You will create an interface called Developer which will consist of specific methods that apply to only Developers (e.g. SoftwareEngineer class will implement this,...

  • object oriented programming java homework question about abstracting and interfaces 2. Definition of a hierarchy of...

    object oriented programming java homework question about abstracting and interfaces 2. Definition of a hierarchy of fruits is given below. • Fruit contains an abstract method getVitamin() that returns String. Fruit contains a String field color. Fruits are Apple, Banana, Strawberry and Blackberry. Apples are green, bananas are yellow, strawberries are red, blackberries are black. All these classes have zero parameter constructors. O Apple's vitamins are "A B12". 0 Banana's vitamins are "CD". O Strawberry's vitamins are “B5 E". 0...

  • Please answer the questions below about the following code segment in C: int x, y, z...

    Please answer the questions below about the following code segment in C: int x, y, z int *ix, *iy, *iz; char *c "Hello"; x10; ?- 20; z=30; iz = &z; x = z + *IZ; 200 t 30?130 2200; 1. What is the value of "ix? 2, What is the value of *iy? 3. What is the value of *iz? 4. What is the value of c[0]? 5. What is the value of c[strlen(c) - 1]?

  • Question 60.1 pts Which of the following is true about a concrete class? A concrete class...

    Question 60.1 pts Which of the following is true about a concrete class? A concrete class may be extended. A concrete class may be instantiated. A concrete may NOT contain abstract methods. All of the above. None of the above. Flag this Question Question 70.1 pts Which of the following is true? A class extends exactly one other class and may implement any number of interfaces. A class may extend at most one concrete class, may extend any number of...

  • Can someone please help me with this JAVA problem about Abstract classes and Interfaces? They are...

    Can someone please help me with this JAVA problem about Abstract classes and Interfaces? They are asking me to explain how the following class SortRectangle works. What is the output of the problem? The program is: public class SortRectangles { public static void main(String[] args) { new ComparableRectangle(3.4, 5.4); new ComparableRectangle(13.24, 55.4); new ComparableRectangle(7.4, 35.4); new ComparableRectangle(1.4, 25.4); java.util.Arrays.sort(rectangles); for (Rectangle rectangle: rectangles){ System.out.print(rectangle + " "); System.out.println(); } }    } ============================================================================= public class ComparableRectangle extends Rectangle implements Comparable<ComparableRectangle>{...

  • JAVA 3 PLEASE ANSWER AS MANY QUESTIONS AS POSSIBLE! ONLY 2 QUESTIONS LEFT THIS MONTH!!! Question...

    JAVA 3 PLEASE ANSWER AS MANY QUESTIONS AS POSSIBLE! ONLY 2 QUESTIONS LEFT THIS MONTH!!! Question 12 pts Which is a valid constructor for Thread? Thread ( Runnable r, int priority ); Thread ( Runnable r, String name ); Thread ( int priority ); Thread ( Runnable r, ThreadGroup g ); Flag this Question Question 22 pts What method in the Thread class is responsible for pausing a thread for a specific amount of milliseconds? pause(). sleep(). hang(). kill(). Flag...

  • Java: please ignore my answer, do question 3. Question 3. 15 pts. The equalsO method of...

    Java: please ignore my answer, do question 3. Question 3. 15 pts. The equalsO method of the ArrayList<E> class takes another list as a parameter and returns true if the two lists contain the same elements in the same order, and false otherwise middle section of the code below so that the output is truetrue . Remember that add (int index, E element), and set (int index, E element). you can put elements into an ArrayList with the methods add(E...

  • java questions , help me and answer them please ! 6. Which of the following classes...

    java questions , help me and answer them please ! 6. Which of the following classes define a legal abstract class? 1: class A 2: abstract void unfinished 4: 1: public class abstract A 2: abstract void unfinished 1: class A 2: abstract void unfinished 3: 1: abstract class A 2: protected void unfinished 3: 1: abstract class A 2: abstract void unfinished 3: 1: class A 2: abstract int unfinished 3: 7. Suppose A is an interface. Can you...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
Active Questions
ADVERTISEMENT