JAVA public class HeMan extends Skeletor { public void attack() { super.attack(); System.out.print("heman-A "); } public String toString() { return "heman!"; } } public class SheRa { public void...






JAVA










public classHeMan extends Skeletor {


    public void attack() {


        super.attack();


        System.out.print("heman-A    ");


    }



    public String toString() {


        return "heman!";


    }


}


public classSheRa {


    public void attack() {


        System.out.print("shera-A    ");


    }



    public void train() {


        System.out.print("shera-T    ");


    }



    public String toString() {


        return "shera!";


    }


}



public classBattleCat extends HeMan {


    public void attack() {


        System.out.print("battlecat-A    ");


    }


    public void train() {


        attack();


        System.out.print("battlecat-T    ");


    }


}


public classSkeletor extends SheRa {


    public void train() {


        System.out.print("skeletor-T    ");


        attack();


    }


}



Given the classes above, what output is produced by the following code?


SheRa[] superheros = {new Skeletor(),new HeMan(),new SheRa(),new BattleCat() };


for (int i = 0; i < superheros.length;="" i++)="">


superheros[i].train();


    System.out.println();


superheros[i].attack();


    System.out.println();


    System.out.println(superheros[i]);


    System.out.println();


}


Provide your answers in the following blanks in the same order:


train():


attack():


superheros:


train():


attack():


superheros:


train():


attack():


superheros:


train():


attack():


superheros:






질문 3<br>5점<br>In the following program, make the scanner receive its input from a file named temperature.txt. You<br>may assume that this file is available in the default working path.<br>import java.util.

Extracted text: 질문 3 5점 In the following program, make the scanner receive its input from a file named temperature.txt. You may assume that this file is available in the default working path. import java.util."; public class Read { public static void main(String[] args) throws FileNotFoundException{ llyour goes here Scanner con=new Scanner(fp); 질문4 2점 Which of the following categories of methods can be used for setting values to the field variables of an object? toString() Constructors All of the above Setters and Constructors getters
질문5<br>3점<br>Which of the following statements about Object oriented programming are true?<br>(i) The name of the object should match with the name of the class that defines the object.<br>(ii) A constructor is a method that must accept at least one parameter and must be written every time<br>you define a class.<br>(iii) A constructor must have the same name as the object and has no return value.<br>(iv) If you do not write the toString() method for the Object class nothing prints when you print the<br>object in the test class.<br>All of the above<br>II<br>I and III<br>IV<br>

Extracted text: 질문5 3점 Which of the following statements about Object oriented programming are true? (i) The name of the object should match with the name of the class that defines the object. (ii) A constructor is a method that must accept at least one parameter and must be written every time you define a class. (iii) A constructor must have the same name as the object and has no return value. (iv) If you do not write the toString() method for the Object class nothing prints when you print the object in the test class. All of the above II I and III IV
Jun 10, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here