q1) private static int num = 0; q2) num++; q3) System.out.println(Student.getNum());
ble and instance variable, and then use clas 4. Please discuss the difference between class variable...
Inheritance and Polymorphism (use Pet.java) You are given a class named Pet.java. Create two child classes named Cat.java and Dog.java. Cat.java should add attributes for color and breed. Dog.java should add attributes for breed and size (use String for small, medium, large). Add appropriate constructors, getter/setter methods and toString() methods. In a separate file named PetDriver.java, create a main. In the main, create an ArrayList of Pet. Add an instance of Cat and an instance of Dog to the ArrayList....
The method m() of class B overrides the m() method of class A, true or false? class A int i; public void maint i) { this.is } } class B extends A{ public void m(Strings) { 1 Select one: True False For the following code, which statement is correct? public class Test { public static void main(String[] args) { Object al = new AC: Object a2 = new Object(); System.out.println(al); System.out.println(a): } } class A intx @Override public String toString()...
Below are the Car class and Dealership class that I
created In the previous lab
import java.util.ArrayList;
class Car
{
private String make;
private String model;
private int year;
private double transmission;
private int seats;
private int maxSpeed;
private int wheels;
private String type;
public Car()
{
}
public Car(String make, String model, int year, double transmission, int seats, int maxSpeed, int wheels, String type) {
this.make = make;
this.model = model;
this.year = year;
this.transmission = transmission;
this.seats =...
A teacher wants to create a list of students in her class. Using the existing Student class in this exercise. Create a static ArrayList called classList that adds a student to the classList whenever a new Student is created. In the constructor, you will have to add that Student to the ArrayList. Coding below was given to edit and use public class ClassListTester { public static void main(String[] args) { //You don't need to change anything here, but feel free...
A teacher wants to create a list of students in her class. Using the existing Student class in this exercise. Create a static ArrayList called classList that adds a student to the classList whenever a new Student is created. In the constructor, you will have to add that Student to the ArrayList. Coding below was given to edit and use public class ClassListTester { public static void main(String[] args) { //You don't need to change anything here, but feel free...
Debugging exercise Programmer Began programming the following program, but made some mistakes. Please debug: class Student{ private int id; private String name; private String city; Student(String name, String city){ this.name = name; this.city = city; } Student(int id, String place){ this.id = id; this.place =name; } void Student(int id, String name, String city){ this.id = id; this.name = name; this.city =...
I need help in converting this into pseudo-code Student.java public class Student implements Comparable<Student>{ private String name, major, status; private int rank; public Student() { this.name = this.major = this.status = ""; this.rank = 0; } public Student(String name, String major, String status) { this.name = name; this.major = major; this.status = status; } public String getName() { return name; } public String getMajor() { return major; } public String getStatus() { return status; } public int...
JAVA help Create a class Individual, which has: Instance variables for name and phone number of individual. Add required constructors, accessor, mutator, toString() , and equals method. Use array to implement a simple phone book , by making an array of objects that stores the name and corresponding phone number. The program should allow searching in phone book for a record based on name, and displaying the record if the record is found. An appropriate message should be displayed if...
Provided code Animal.java:
public class Animal
{
private String type;
private double age;
public Animal(String aT, double anA)
{
this.type = aT;
if(anA >= 0)
{
this.age =
anA;
}
}
public String getType()
{
return this.type;
}
public double getAge()
{
return this.age;
}
}
Provided code Zoo.java:
public class Zoo {...
GIVEN CODES
*****Boat.java*****
import java.util.HashSet;
import java.util.Set;
public class Boat {
private String name; //private instance variable name of type String
private String boatClass; //private instance variable boatClass of type String
private int regNum; //private instance variable regNum of type int
private Set<String> crew = new HashSet<String>();
public void setName(String name) {
this.name = name;
}
public void setBoastClass(String boatClass) {
this.boatClass = boatClass;
}
public void setRegNum(int regNum) {
this.regNum = regNum;
}
public String getName() {
return name;...