1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
skad [1K]
3 years ago
13

Provide instance fields for title, month, and year (for example, "Scientific American", "April", 2020). Each of these should be

accessible only within the Magazine class.Create a constructor, which initializes the instance fieldsWrite a toString() method, modeled after the standard Java toString() method, to return a String representation of the Magazine.Write an equals() method, modeled after the standard Java equals() method. Two Magazines are equal if they have the same title, month, and year.HTML EditorKeyboard Shortcuts

Computers and Technology
1 answer:
miskamm [114]3 years ago
4 0

Answer:

Check the explanation

Explanation:

Note : check attached image for output and program and also note that you're to replace "at" with shift 2 as the brainly text editor can't take the symbol

Program : **************Magzine.java**********************

/*

* To change this license header, choose License Headers in Project Properties.

* To change this template file, choose Tools | Templates

* and open the template in the editor.

*/

public class Magzine {

 

//class variable private can not access outside class

private String title;

private String month;

private int year;

 

//parameterized constructor

public Magzine(String title,String month,int year)

{

this.title=title;

this.month=month;

this.year=year;

}

 

//override toString method

"at"Override

public String toString()

{

String detail=title+" "+month+" "+Integer.toString(year);

return detail;//return string of class variable

}

 

//get Magzine objecte

 

public boolean equals(Magzine obj)

{

//commented returm statement compare string by address so you can uncomment if

//we do not use same string object of String class

//return this.month==obj.month && this.title==obj.title && this.year==obj.year;

//compare two object element if matches return true else false

return (this.month.equals(obj.month)) &&(this.title.equals(obj.title)) && this.year==obj.year;

}

   

}

Program : *************************Main.java****************************

/*

* To change this license header, choose License Headers in Project Properties.

* To change this template file, choose Tools | Templates

* and open the template in the editor.

*/

public class Main {

/**

* "at"param args the command line arguments

*/

public static void main(String[] args) {

// TODO code application logic here

Magzine Obj =new Magzine("Scientific American ", "April", 2020); //object of class

Magzine Obj1 =new Magzine("Scientific American ", "April", 2020);//Obj and obj1 is same content data

Magzine Obj2 =new Magzine("Scientific American", "June", 2020); //obj and obj1 same but obj2 different

 

System.out.println(Obj.toString()); //print string of obj

System.out.println(Obj1.toString());//print string of obj1

System.out.println(Obj2.toString());//print string of obj2

 

 

System.out.println(Obj.equals(Obj1)); //obj and obj1 equal and return true

System.out.println(Obj.equals(Obj2)); // obj and obj2 not equal so return false

 

 

}

 

}

Output can be seen below:

You might be interested in
The documents created in ms-excel is call what?​
rosijanka [135]

Answer:

It is called a Spreadsheet

5 0
3 years ago
Read 2 more answers
Read the sentence. Piles of discarded trash litter the cobblestones of the quaint brick alley. Which image best shows a visualiz
Snezhnost [94]

Answer:

C

Explanation:

JUST DID IT

3 0
3 years ago
If the user enters 26 what is output? _____________
MArishka [77]

Please write the whole question, is it asking for the function that requests user input?

3 0
3 years ago
Which of these is a sign of healthy A)very high inflation B)A rise in consumers spending C)a shift supply of essential goods D)H
klemol [59]

im sorry i meant C 100%

6 0
3 years ago
Read 2 more answers
Carbon monoxide poisoning can result from breathing
Mamont248 [21]
The answer is the letter a
6 0
3 years ago
Other questions:
  • T<br> F<br> 5.<br> You can save presentations in PDF and XPS formats.
    14·1 answer
  • A user has requested to have an extra 4GB of memory installed on a laptop. During the Installation process, which of the followi
    6·1 answer
  • The narrative structure of the popular movies can be broken down into
    15·1 answer
  • A Security Policy is: a. How we implement security b. Corporate direction on behavior c. A statement of consequence for failure
    5·1 answer
  • Which of the following payment types require you to pay upfront?
    9·1 answer
  • Pass only _____ at a time.
    13·2 answers
  • Which tool determines whether or not applications, devices, and computers will work with a new operating system, while maintaini
    13·1 answer
  • Can someone answer this, I'll mark u the brialintest
    11·1 answer
  • Which symbol should you use for entering a formula in a cell?
    7·2 answers
  • How many Horizontal and Vertical Rods are there in Abacus
    15·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!