Question: 4G 5:24 ...ythos.s3-ap-southeast-2.amazonaws.com 4. What is the default value of: An object that has not been initialized? (1 mark) An int? (1 mark) For a

 4G 5:24 ...ythos.s3-ap-southeast-2.amazonaws.com 4. What is the default value of: An
object that has not been initialized? (1 mark) An int? (1 mark)

4G 5:24 ...ythos.s3-ap-southeast-2.amazonaws.com 4. What is the default value of: An object that has not been initialized? (1 mark) An int? (1 mark) For a class named Car: Create the class and add 2 (two) instance variables that will hold the car's colour (String) and number of doors (int) (2 marks) .Write a constructor which initializes the instance variables you created in the section above. (2 marks) .Write an accessor method and a mutator method for the field that will hold the car's colour. (2 marks) 6. For the class you created in the question above: .Write the code to create an instance of a Car. (2 marks) Declare and initialise an HashSet and insert the Car you created. (4 marks) 7. What is the scope of a constructor parameter? (2 marks) x Given the following array: intl numbers = {1, 3.2.4. 2): Write a for loop to loop through the array and print out cach number on a separate line. (2 marks) Write a for each loop to loop through the array and print out each number on a separate line. (2 marks) . What keyword is used to call a superclass constructor? (2 marks) 10 What is an overloaded constructor? (2 marks) 11. Given the code below: ArrayList list = new ArrayListo: list.add(7): list.add(1): list.add(5) 5:24 .46 o...ythos.s3-ap-southeast-2.amazonaws.com 11. Given the code below: ArrayList list = new ArrayList(): list.add(7); list.add(1): list.add(5): list.add(1): list.remove(1): System.out.println(list.get(1)): . What will be the output of the printin statement? (2 marks) b. Write the code to loop through the ArrayList using the java.util.Iterator class. (2 marks) 12. What will be the output of the following program segment? (2 marks) int blueint, greenInt, yellowint; blueInt = 20; yellowInt=blueInt/6; greenInt=blueint + yellowint; if (yellowInt > 3) System.out.println("vellowInt = " + yellowint): } else { if (greenInt > 20) System.out.println("greenInt = " + greenInt): } else System.out.println("blueint = "+blueint)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!