Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed
image text in transcribed
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

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

Database Administration The Complete Guide To Dba Practices And Procedures

Authors: Craig S. Mullins

2nd Edition

0321822943, 978-0321822949

More Books

Students also viewed these Databases questions

Question

WHAT IS AUTOMATION TESTING?

Answered: 1 week ago

Question

What is Selenium? What are the advantages of Selenium?

Answered: 1 week ago

Question

Explain the various collection policies in receivables management.

Answered: 1 week ago