질문 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 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

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

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 attack() {

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

    }

   

    public void train() {

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

    }

   

    public String toString() {

        return "shera!";  

    }

}

public class BattleCat extends HeMan {

    public void attack() {

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

    }

    public void train() {

        attack();

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

    }

}

public class Skeletor 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
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
Transcribed Image 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
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
Transcribed Image 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
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Encryption and Decryption
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
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)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education