Question
Answered step-by-step

Consider the following Java program, which one of the following best describes "setFlavor"?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

Clear my choice

Question 2

Not yet answered

Marked out of 1.00

Flag question

Question text

Which one of the following values can a Java variable NOT have?

Select one:

a. a floating-point number

b. an integer

c. an object

d. the memory location of an object

e. true or false

Clear my choice

Question 3

Not yet answered

Marked out of 1.00

Flag question

Question text

Consider the following Java program, which one of the following best describes "count"?

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

Clear my choice

Question 4

Not yet answered

Marked out of 1.00

Flag question

Question text

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

Clear my choice

Question 5

Not yet answered

Marked out of 1.00

Flag question

Question text

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; }

   static public void main(String[] args) {

       Food pepper = new Food("spicy");

       Food chile = pepper;

       pepper.setFlavor("smoky");

       System.out.println(pepper == chile);

   }

}

Select one:

a. true

b. false

c. smoky

d. spicy

e. sweet

Answer & Explanation
Verified Solved by verified expert

icitur la

Donec aliquet. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam laci

usce dui

et, consectetur a

m ipsum

m ipsum dolor sit ame

nec fa

or nec facilisis. Pell

dictum v

, dictum

s a molestie consequat, ultrices ac magna. Fusce dui lectus, congue

Unlock full access to Course Hero

Explore over 16 million step-by-step answers from our library

Subscribe to view answer
Step-by-step explanation

ia pulvinar tortor ne


lestie consequat, ultrices acfficitur laoreet. Nam risus ante, dapibus a molestie consequat, ultrices ac magna. Fusce

ipsum dolor sit amet, consectetur adipiscing elit. Nam lacinia pulvinar tortor nec facilisis. Pellentesque dapibus efficitur laoreet. N


a. Fusce dui lectus, congue vel laoreet ac, dictum vitae odio. Donec aliquet. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam lacinia pulvinar tor


consectetur adipiscing elit. Nam lacinia pulvinar tortor nec facilisis. Pellentesque dapibus efficitur laoreet. Nam risus ante, dapibus a molestie consequat, ultrices

Student reviews
50% (4 ratings)