Levels Tought:
Elementary,Middle School,High School,College,University,PHD
Teaching Since: | Apr 2017 |
Last Sign in: | 10 Weeks Ago, 5 Days Ago |
Questions Answered: | 4870 |
Tutorials Posted: | 4863 |
MBA IT, Mater in Science and Technology
Devry
Jul-1996 - Jul-2000
Professor
Devry University
Mar-2010 - Oct-2016
Q1.Â
Q1. Write the syntax for
Â
Â
Â
Q2. Use a for loop to fill an Arraylist with the square of the numbers 1 to 10. The output should be ( 1, 4, 9, 16, ..100): [3 Points]
Â
Q3. Rewrite the following loops, using the "for each" construct. Here data is an array of double values. [1 point]
for (int i = 0; i < data.length; i++)
sum = sum + data[i];
Â
Â
Â
Q4. Write preconditions for the following methods. Do not implement the methods. [3 point]
a. public static double sqrt(double x)
b. public static String romanNumeral(int n)
c.
public static String weekday(int day)
Â
Â
Â
Â
Q5. Define class cohesion and class coupling. [1 Points]
Â
Q6. What is a static method ? What is a static variable ? Explain and provide examples. [2 Points]
Â
Q7. What is an Immutable Class ? [1 Point]
Â
Q8. Draw a memory diagram that shows why the following method can't swap two BankAccount objects. [3 point]
public static void falseSwap(BankAccount a, BankAccount b)
{
   BankAccount temp = a;
   a = b;
   b = temp;
}
Â
Â
Â
Q2. Use a for loop to fill an Arraylist with the square of the numbers 1 to 10. The output should be ( 1, 4, 9, 16, ..100): [3 Points]
Â
Q3. Rewrite the following loops, using the "for each" construct. Here data is an array of double values. [1 point]
for (int i = 0; i < data.length; i++)
sum = sum + data[i];
Â
Â
Â
Q4. Write preconditions for the following methods. Do not implement the methods. [3 point]
a. public static double sqrt(double x)
b. public static String romanNumeral(int n)
c.
public static String weekday(int day)
Â
Â
Â
Â
Q5. Define class cohesion and class coupling. [1 Points]
Â
Q6. What is a static method ? What is a static variable ? Explain and provide examples. [2 Points]
Â
Q7. What is an Immutable Class ? [1 Point]
Â
Q8. Draw a memory diagram that shows why the following method can't swap two BankAccount objects. [3 point]
public static void falseSwap(BankAccount a, BankAccount b)
{
   BankAccount temp = a;
   a = b;
   b = temp;
}