Database System Concepts
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
Bartleby Related Questions Icon

Related questions

Question
Don't use ai to answer I will report your answer. Class with public instance variable: step by step and solve with java
Required Skills Inventory
• Declare an instance variable in a Java class
Initialize an instance variable in a Java class
• Implement an attribute as an instance variable in a Java class
Problem Description and Given Info
You must complete the Bunny class (in the bunny.java file) you are given below. To complete this simple class, you must declare the
following public instance variables (fields):
1. a public field named name of type String
2. a public field named age of type int
NOTE
In general, fields (instance variables) should be declared to be private. However, for this Challenge you are being asked to declare the the
fields as public.
1234567000122
8
9
Current file: Main.java
1 public class Main {
Main.java
public static void main(String[] args)
Bunny myBunny = new Bunny();
Bunny.java
Bunny yourBunny = new Bunny();
14 }
myBunny.setName("Flopsy");
myBunny.setAge(3);
yourBunny.setName("Mopsy");
yourBunny.setAge(5);
myBunny.print();
yourBunny.print();
15}
Load default template...
expand button
Transcribed Image Text:Required Skills Inventory • Declare an instance variable in a Java class Initialize an instance variable in a Java class • Implement an attribute as an instance variable in a Java class Problem Description and Given Info You must complete the Bunny class (in the bunny.java file) you are given below. To complete this simple class, you must declare the following public instance variables (fields): 1. a public field named name of type String 2. a public field named age of type int NOTE In general, fields (instance variables) should be declared to be private. However, for this Challenge you are being asked to declare the the fields as public. 1234567000122 8 9 Current file: Main.java 1 public class Main { Main.java public static void main(String[] args) Bunny myBunny = new Bunny(); Bunny.java Bunny yourBunny = new Bunny(); 14 } myBunny.setName("Flopsy"); myBunny.setAge(3); yourBunny.setName("Mopsy"); yourBunny.setAge(5); myBunny.print(); yourBunny.print(); 15} Load default template...
Current file: Bunny.java❤
Load default template...
Main.java
Bunny.java
1 class Bunny {
2
// declare required fileds below
3
456782
//make no other changes to this code
public void print() {
System.out.println(" (\\\\\\\ ");
System.out.println(" (--)
");
System.out.println(" 0_(\")(\") ");
System.out.printf("%s is %d years old. \n", this.name, this.age);
9
10
11
}
12}
expand button
Transcribed Image Text:Current file: Bunny.java❤ Load default template... Main.java Bunny.java 1 class Bunny { 2 // declare required fileds below 3 456782 //make no other changes to this code public void print() { System.out.println(" (\\\\\\\ "); System.out.println(" (--) "); System.out.println(" 0_(\")(\") "); System.out.printf("%s is %d years old. \n", this.name, this.age); 9 10 11 } 12}
Expert Solution
Check Mark
Knowledge Booster
Background pattern image
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education