CS 1102 - AY2020-T3 Self-Quiz Unit 4 c.docx - Question 1 Correct Mark 1.00 out of 1.00 Consider the following Java program which one of the following

CS 1102 - AY2020-T3 Self-Quiz Unit 4 c.docx - Question 1...

This preview shows page 1 - 2 out of 3 pages.

Question 1 Correct Mark 1.00 out of 1.00 Consider the following Java program, which one of the following best describes "Food()"? public class Food { static int count; private String flavor = "sweet"; Food() { count++; } void setFlavor(String s) { flavor = s; } String getFlavor() { return flavor; } static public void main(String[] args) { Food pepper = new Food(); System.out.println(pepper.getFlavor()); } } Select one: a. a class variable b. a constructor c. a local object variable d. an instance variable e. a method Your answer is correct. See Section 5.2.2 of Eck (2014). Question 2 Correct Mark 1.00 out of 1.00 Which one of the following Java technologies eliminates memory leaks? Select one: a. garbage collection b. just-in-time compilers c. object-oriented analysis and design d. software engineering e. virtual machines Question 3 Correct Mark 1.00 out of 1.00 What is the output of the following Java program? public class Food { static int count; private String flavor = "sweet"; Food(String s) { flavor = s; } void setFlavor(String s) { flavor = s; } String getFlavor() { return flavor; }

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture