• Create a java program named Final.java. Within the program, implement a class named Employee and a subclass named HourlyEmployee. Employee has fields First, Last and SSN. HourlyEmployee has fields Wage and HoursWorked. Create methods to obtain data for each field. Override toString for each class so that Employee returns the First + Last + SSN and the HourlyEmployee returns the Wage + HoursWorked. Space appropriately. In the main method, construct an instance of each class and fill with your name, a fictitious SSN, wage and hours worked. Call the toString methods from each class to print the information you entered.
  • Suppose s1 and s2 are two strings. Which of the following statements or expressions is(are) incorrect?
  • Suppose array a is int[] a = {1, 2, 3}, what is a[0] - a[2]?
  • Given the following statement: int[] list = new int[10]; Which of the following statements is(are) correct?
  • In the following code, suppose that f is an instance of Foo. class Foo { int i; static int s; void imethod() { } static void smethod() { } }
  • In the following code, suppose that f is an instance of Foo. class Foo { int i; static int s; void imethod() { } static void smethod() { } } Which of the following statements is(are) incorrect?
  • In the following code, suppose that f is an instance of Foo.
  • Analyze the following code: class Test { public static void main(String[] args) { Count myCount = new Count(); int times = 1; for (int i = 0; i < 10; i++) increment(myCount, times); System.out.println("myCount.count = " + myCount.count); } public static void increment(Count c, int times) { c.count += times++; } } class Count { public int count; public Count(int c) { count = c; } public Count() { count = 1; } } What is the value of myCount.count displayed?
  • Analyze the following code: class Test { public static void main(String[] args) { A a = new A("test"); a.print(); } } class A { String s; public A(String s) { this.s = s; } private void print() { System.out.println(s); } } Which of the following statements is(are) correct?
  • Analyze the following code: class Test { public static void main(String[] args) { double radius = 5; final static double PI = 3.15169; double area = radius * radius * PI; System.out.println("Area is " + area); } } Which of the following statements is(are) correct?
  • In the following code, what will be printed out? class Test { public static void main(String[] args) { int[] list1 = {3, 2, 1}; int[] list2 = {1, 2, 3}; list2 = list1; list1[0] = 0; list1[1] = 1; list2[2] = 2; for (int i = list2.length - 1; i >= 0; i--) System.out.print(list2[i] + " "); } } }
  • Consider the following code fragment: int[] list = new int[10]; for (int i = 0; i <= list.length; i++) { list[i] = (int)(Math.random() * 10); } Which of the following statements is(are) correct?
  • Given the following declaration: int[ ][ ] m = new int[5][6]; Which of the following statements is(are) correct?
  • Analyze the following code: public class Test { public static void main(String args[]) { Test nc = new Test(); nc.t = nc.t++; } protected int t; Test() { } } Which of the following statements is(are) correct?
  • Analyse the following code : public class Test { public static void main(String[] args) { int[] a = {1, 2}; swap(a[0], a[1]); System.out.println("a[0] = " + a[0] + " a[1] = " + a[1]); } public static void swap(int n1, int n2) { int temp = n1; n1 = n2; n2 = temp; } } Which of the following shows correct printout?
Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.