Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. Write a statement that will declare a two dimensional Integer array with 7 rows and 5 columns (10 pts). 2. Using the array above,

1. Write a statement that will declare a two dimensional Integer array with 7 rows and 5 columns (10 pts).

2. Using the array above, write the code fragment that will initialize your array row by row from left to right beginning with the number 1 (1, 2, 3, 4, 5,6,7,8,9,10. etc). Use nested for loop. Do not hard code values nor loop control variable (20 pts).

public static void main(String[] args) { }

3. Write a java method called avgArray which takes as its parameters an int array and its size and returns the average of all the array elements and returns the same. (20 pts)

4. Mark the statements as TRUE or FALSE (5 pts)

  1. The methods of a class must be public.

  1. A constructor can have a value of int type.

  1. A class can have more than one constructor.

  1. Method definitions can be nested.

  1. A method of a class that modifies the values of the data members is called Accessor method.

5. Write the default constructor for the below class (15 pts)

class Student { private String name; private int age; private String address;

}

6. Given the following code (10 pts)

public class Mystery { private int x; private double y;

public void print()

{

System.out.println(x+ +y););

}

public int sum()

{

return x+y;

}

}

  1. What is the name of the class?

  1. What are the instance variables?

  1. What are the methods?

  1. what are the private members?

  1. what are the public members?

7. Using the class described in question6, Mystery (20 pts)

a. Write a java statement to instantiate an object called unknown.

b. Write a java statements to access methods using the object that was created in 7a.

1. Write a statement that will declare a two dimensional Integer array with 7 rows and 5 columns (10 pts).

2. Using the array above, write the code fragment that will initialize your array row by row from left to right beginning with the number 1 (1, 2, 3, 4, 5,6,7,8,9,10. etc). Use nested for loop. Do not hard code values nor loop control variable (20 pts).

public static void main(String[] args) {

}

3. Write a java method called avgArray which takes as its parameters an int array and its size and returns the average of all the array elements and returns the same. (20 pts)

4. Mark the statements as TRUE or FALSE (5 pts)

  1. The methods of a class must be public.

  1. A constructor can have a value of int type.

  1. A class can have more than one constructor.

  1. Method definitions can be nested.

  1. A method of a class that modifies the values of the data members is called Accessor method.
  2. 5. Write the default constructor for the below class (15 pts)

class Student { private String name; private int age; private String address;

}

6. Given the following code (10 pts)

public class Mystery { private int x; private double y;

public void print()

{

System.out.println(x+ +y););

}

public int sum()

{

return x+y;

}

}

  1. What is the name of the class?

  1. What are the instance variables?

  1. What are the methods?

  1. what are the private members?

  1. what are the public members?

7. Using the class described in question6, Mystery (20 pts)

a. Write a java statement to instantiate an object called unknown.

b. Write a java statements to access methods using the object that was created in 7a.

1. Write a statement that will declare a two dimensional Integer array with 7 rows and 5 columns (10 pts).

2. Using the array above, write the code fragment that will initialize your array row by row from left to right beginning with the number 1 (1, 2, 3, 4, 5,6,7,8,9,10. etc). Use nested for loop. Do not hard code values nor loop control variable (20 pts).

public static void main(String[] args) {

}

3. Write a java method called avgArray which takes as its parameters an int array and its size and returns the average of all the array elements and returns the same. (20 pts)

4. Mark the statements as TRUE or FALSE (5 pts)

  1. The methods of a class must be public.

  1. A constructor can have a value of int type.

  1. A class can have more than one constructor.

  1. Method definitions can be nested.

  1. A method of a class that modifies the values of the data members is called Accessor method.

5. Write the default constructor for the below class (15 pts)

class Student { private String name; private int age; private String address;

}

6. Given the following code (10 pts)

public class Mystery { private int x; private double y;

public void print()

{

System.out.println(x+ +y););

}

public int sum()

{

return x+y;

}

}

  1. What is the name of the class?

  1. What are the instance variables?

  1. What are the methods?

  1. what are the private members?

  1. what are the public members?

7. Using the class described in question6, Mystery (20 pts)

a. Write a java statement to instantiate an object called unknown.

b. Write a java statements to access methods using the object that was created in 7a.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Learning MySQL Get A Handle On Your Data

Authors: Seyed M M Tahaghoghi

1st Edition

0596529465, 9780596529468

More Books

Students also viewed these Databases questions