Add two static methods to the class Cat: int getCatCount() and setCatCount(int) using which you can get / change the number of cats (the variable catCount).

Can someone please post the solution to this question. Please help!!

asked 19 Aug '15, 07:22

Harshita%20Das's gravatar image

Harshita Das
accept rate: 0%

In the Method "public static int getCatCount()" you just have to return your static variable And in the method "public static void setCatCount(int catCount)" you have to set your static variable to catCount! Thats it!


answered 01 Jun '16, 09:51

Joschi's gravatar image

accept rate: 0%

public class Cat {
    private static int catCount = 0;
    public Cat() {
    public static int getCatCount() {
        return catCount;
    public static void setCatCount(int catCount) {
        Cat.catCount = catCount;

answered 19 May '17, 12:46

Igor's gravatar image

accept rate: 0%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "Title")
  • image?![alt text](/path/img.jpg "Title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported



Asked: 19 Aug '15, 07:22

Seen: 877 times

Last updated: 19 May '17, 12:46

Related questions