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
9.18 lab: even/odd values in a vector write a program that reads a list of integers, and outputs whether the list contains all e
lana66690 [7]

def is_list_even(my_list):

   for i in my_list:

       if(i%2 != 0):

           return False

   

   return True

   

   

def is_list_odd(my_list):

   for i in my_list:

       if(i%2 == 0):

           return False

   

   return True

   

def main():

   n = int(input())

   lst = []

   

   for i in range(n):

       lst.append(int(input()))

   

   if(is_list_even(lst)):

       print('all even')

   

   elif(is_list_odd(lst)):

       print('all odd')

   

   else:

       print('not even or odd')

       

       

if __name__ == '__main__':

   main()

6 0
2 years ago
If you want a user to actively participate in an online activity, create a web ______________.
elena-14-01-66 [18.8K]

If you want a user to actively participate in an online activity, create a web ______________.  

1. animation  

2. application  

<u>3. page  </u>

4. source

6 0
3 years ago
Read 2 more answers
QUESTIONS Which of the following use cases are suitable for compute-optimized cloud offering? ОА. None of the listed O B. Highly
Ede4ka [16]

Answer:

E. All of the listed ​

Explanation:

For compute-optimized cloud offerings like AWS, suitable use cases are - gaming, distributed analytics, and scientific modeling. Since all these are suitable, the correct answer is E.

4 0
3 years ago
Tfuuvj vjiibjoon Ghosh kpj
Nookie1986 [14]

Answer: A

Explanation: For any formal document you need your major points.

5 0
3 years ago
Read 2 more answers
To run a PHP application that has been deployed on your own computer you can enter a URL in the address bar of your browser that
svet-max [94.6K]

Answer:

You can enter a URL that (B) Uses localhost as the domain name

Explanation:

Localhost refers to your computer or the computer that is currently in use.

To run a PHP application that is deployed on your computer, the localhost (which has an IP address of 127.0.0.1) is used.

The IP address is called a "loopback" address because all data sent or received revolve around the local computer.

8 0
3 years ago
Other questions:
  • What was one of the main purposes of the first computer systems?
    11·1 answer
  • Your grandmother was an established artist and left you several original paintings after she died. Which of these statements is
    6·1 answer
  • A. True <br> b. False: variables represent storage locations in the computer's memory.
    13·1 answer
  • The ability of services to grow or shrink based on need is called __________.
    14·1 answer
  • Post as a reply your example of "data, which is processed into information" case - examples should not necessarily be related to
    13·1 answer
  • Which function in Excel tells how many
    6·1 answer
  • You are working on a ticketing system. A ticket costs $10. The office is running a discount campaign: each group of 5 people is
    5·1 answer
  • Convertbinary(111100)to decimal​​​​
    13·2 answers
  • What is the Cycle of Dependency?
    14·1 answer
  • PLEASE ANSWER! I NEED IN 30 MIN.
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!