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}
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}
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
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
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 2 steps with 1 images
Recommended textbooks for you
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)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
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)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education