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
Which of these is a Microsoft certification for system engineers?
Fiesta28 [93]

MCSE is a Microsoft certification for system engineers

<u>Explanation:</u>

The MCSE Certification is a certification to enhance a system engineer. They are a set of exams that examine a person’s proficiency with various Microsoft technologies similar to Windows Server, SQL Server, System Center and Office 365. MSCE has different qualities and with various specifications. One can learn all the features in our Microsoft certification guide on the official MCSE page.

Becoming approved as a Microsoft Certified Software Engineer is not inferior, so it’s deserving is often questioned. However, getting the MCSE, like any other Microsoft Certification, is deserving of the payment.

6 0
3 years ago
What Is the Purpose of a Web Browser? *<br><br>​
Aneli [31]
A web browser takes you anywhere on the internet. It retrieves information from other parts of the web and displays it on your desktop or mobile device. The information is transferred using the Hypertext Transfer Protocol, which defines how text, images and video are transmitted on the web.
6 0
2 years ago
Read 2 more answers
What dose AUP stand for??????????
kipiarov [429]

Answer:

Acceptable Use Policy

Explanation:

A: Acceptable

U:Use

P:Policy

3 0
3 years ago
Read 2 more answers
What social impact did the gunpowder have on society?
olga2289 [7]
It had a huge impact people could use other things than bows and arrows to fight in wars.
8 0
3 years ago
How many categories of bitmap images are there?
seraphim [82]

Answer:

Bitmap images can contain any number of colors but there are four main categories: Line-art. These are images that only contain two colors, usually black and white.

6 0
3 years ago
Other questions:
  • What is a directory server?
    5·1 answer
  • What is the part of the browser window that displays the content of the web page such as pictures and text called?
    10·1 answer
  • The device used to connect a network to the internet is called a
    7·1 answer
  • What's the name of this apex legend hero​
    13·2 answers
  • Componets of computer
    5·1 answer
  • The parameter passing mechanisn used in C is
    5·2 answers
  • Python
    6·1 answer
  • How does a programmer use digital waves to transfer sound?
    11·1 answer
  • Create a static method that: - is called appendPosSum - returns an ArrayList - takes one parameter: an ArrayList of Integers Thi
    6·1 answer
  • In java I need help on this specific code for this lab.
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!