Let's begin by discussing how an interface class differs from a concrete class, how interface classes are defined, and what does implementing an interface class mean!
Interfaces means 100% abstraction. Interfaces doesn't implement any method. If we want to implement the methods in the interface then we have to create a class that implements the interface. Then in this class we should have to implement all the methods mentioned in the iterface. Example (Java): --------------- interface shape{ void printShape(); } class circle implements shape{ void printShape(){ System.out.println("Circle") } }
Let's begin by discussing how an interface class differs from a concrete class, how interface classes...
Java Lab
In this lab, you will be implementing the following class hierarchy. Your concrete classes must call the superclass constructor with the proper number of sides (which is constant for each concrete shape). The perimeter method is implemented in the superclass as it does not change based on the number of sides. The area method must be overridden in each subclass as the area is dependent on the type of polygon. The areas of an equilateral triangle, square, and...
Write an interface and two classes which will implements the interface. 1. Interface - StringVerification - will have the abstract method defined - boolean verifyInput( String input ); 2. class EmailVerification implements StringVerification - implement the verifyInput() method in EmailVerification class. The method should validate a user input String, character by character and see the input string has a dot (.) and an at the rate (@) character in it. If any of the condition wrong the verifyInput method will...
Write an abstract class “Student” and three concrete classes, “UnderGrad” and “Graduate” both inherit from Student and “PostGraduate” that inherits form “Graduate”. Write the class definition for the abstract class “Student”. The class definition should include private instance variables of type String to hold the student’s first name, a string for his/her major and an int to hold the number of units taken. Getter and setter methods for each of the variables should be included in the class definition. Also...
Abstract classes and Interfaces problems 10. Explain one similarity and one difference between abstract classes and interfaces. 11. Consider the following declarations. public interface Shape{ int someFunction(Shape other); //other functions not shown } public class Square implements Shape {/*implementation not shown*/} Which of the following function headings of someFunction must be added to the declaration of the Square class such that it will satisfy the Shape interface? public int someFunction (Shape other) public int someFunction (Square other) public boolean someFunction(Object...
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. ...
Select all correct options in the list below about concrete and abstract classes Select one or more: a. Concrete classes can be instantiated b. Abstract classes must contain at least one abstract method c. Only concrete classes can be super classes d. Abstract classes (using the "abc" library) can be instantiated e. Concrete classes often contain abstract methods f. Both concrete and abstract classes can be super classes that other classes inherit from g. Only abstract classes can be super...
Interfaces 1. What is inside an interface definition? What does a class do to an interface and what keyword is involved? How does a class do this to an interface (what should we find in the class)? Can an interface have a generic parameter? How do you instantiate an interface as an object? What methods can’t you use on an interface type? Abstract Data Types 2. What does an ADT define? Does an ADT specify programming language and/or data structures...
Collect/finish the Java code (interface and the complete working
classes) from lecture slides for the for the following ADT:
3) Queue ADT that uses an array internally (call it AQueue)
Make sure you keep the same method names as in the slides
(automatic testing will be performed)! Make sure your classes
implement the corresponding interfaces. Put your classes in a
package called cse11. Try to make the code robust and try to use
generics.
The Queue ADT The Queue ADT...
Implement the classes in the following class diagram. The Book class implements the Comparable interface. Use implements Comparable<Book> in the class definition. Now, all book objects are instances of the java.lang.Comparable interface. Write a test program that creates an array of ten books. 1. Use Arrays.sort( Book[]l books) from the java.util package to sort the array. The order of objects in the array is determined using compareTo...) method. 2. Write a method that returns the most expensive book in the...
#1) If a concrete (non-abstract class is using an interface, it must do which of the following? contain the same methods as the interface inherit the properties of the interface create an interface object all of the above #2) Can multiple catch blocks be executed for a single try statement? Yes No #3) Which of the following is the default access specifier of a class member variable? Private Public Protected Internal #4) Which of the following keyword is used for...