Hi I have some practice problems for an upcoming quiz. Can someone answer them correctly so I can use that as a reference to study? I would great appreciate it.

Write a program that will print multiples of 2. (0, 2, 4, 6, 8, ...) First complete the constructor and nextMultiple() method in following class, MultipleGenerator. MultipleGenerator can generate multiples of any integer, not just 2. Then write a class TwoMultipleGeneratorTester which will generate and print the first nine multiples of 2. Write this class so that you would only need to make one change to print the first 100 multiples rather than the first nine. Use constants where appropriate.

public class MultipleGenerator
{
    // instance variables
    private int multiplier;
    private int count;

    /**
     * Constructor for objects of class MultipleGenerator
     * @param the number to produce multiples of
     */
    public MultipleGenerator(int multiplier)
    {
       //your code here

    }
    
    /*
     * Computes the next multiple 
     * @return the next nultiple of this multiplier
     */
    public int nextMultiple()
    {
        //your code here
    }
}

2) Complete the class MyClass given below by coding the countOfLengths() method and the count() method.

countOfLengths() returns the number of students witrh names greater than the given integer.

count() returns the number of students in the class (the number of strings in the array)

public class MyClass
{
   String[] students = {"Sam", "Richard", "Allison", "Mary", "Bill", "Susan"};

   /**
    * Gets the number of students with names having more than the specified
    * number of characters
    * @param greaterThan the specified number of characters
    * @return the number of students with names having more than the specified
    * number of characters
    */
   public int countOfLengths(int greaterThan)
   {

   }

   /**
    * Gets the number of students in the class (the number of strings in the students array)
    * @return the number of students
    */
   public int count()
   {

   }
}

No one is going to answer quiz questions for you.

Formulate your own answers and if you have uncertainties, ask specific questions. Explain your reasoning or thoughts on the areas you doubt,

Demonstrate some effort in the process if you want others to take their own time to help you.

commented: Testify, brother. +1
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.