Question: 1. What is the output of the following Java program? public class Food { static int count; private String flavor = sweet; Food(String s) {

1. 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 = new Food("spicy"); System.out.println(pepper == chile); } }

Select one:

a.

spicy

b.

true

c.

sweet

d.

smoky

e.

false

2.

What is the output of the following Java program?

class Food { String flavor = "bland"; } class Pepper extends Food { String flavor = "spicy"; } public class Lunch { public static void main(String[] args) { Food lunch = new Pepper(); System.out.println(lunch.flavor); } }

Select one:

a.

no output

b.

spicy

c.

the program does not compile

d.

bland

spicy

e.

bland

3.

Considering the following Java sample program, what are the x and y values?

public void mouseDragged(MouseEvent evt) {

if ( dragging == false )

return;

int x = evt.getX();

int y = evt.getY();

.

. .

prevX = x;

prevY = y;

}

a.

Next position of Mouse

b.

Position of Mouse when clicking

c.

Current position of Mouse

d.

Position of Mouse after dragging

e.

Position of Mouse during the drag

4. 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(chile.getFlavor()); } }

Select one:

a.

smoky

b.

sweet

c.

false

d.

spicy

e.

true

5.

What is the JavaFX application thread?

a.

When the main() routine is executed, the JavaFX application thread can invoke

b.

JavaFX application thread is used for running Java applications.

c.

When the main() routine is executed, the launch() method creates a new thread, called the JavaFX application thread

d.

JavaFX application thread is one of the GUI library components

e.

JavaFX application thread is a virtual thread to control GUI applications.

6.

What is the output of the following Java program?

class Food { String flavor = "bland"; } class Pepper extends Food { String flavor = "spicy"; Pepper(String flavor) { this.flavor = flavor; } } public class Lunch { public static void main(String[] args) { Pepper pepper = new Pepper("sweet"); System.out.println(pepper.flavor); } }

Select one:

a.

bland

b.

sweet

c.

spicy

d.

the program does not compile

e.

no output

7.

An object that registers listener objects does which of the following?

Select one:

a.

It generates events.

b.

It runs an event loop.

c.

It records audio.

d.

It maintains an object directory.

e.

It handles events.

8. What is the output of the following Java program?

abstract class Food { void printFlavor() {} } class Pepper extends Food {} public class Lunch { public static void main(String[] args) { Food lunch = new Pepper(); lunch.printFlavor(); } }

Select one:

a.

no output

b.

bland

c.

spicy

d.

the program does not compile

e.

bland

spicy

9.

What is the output of the following Java program?

class Food { void flavor() { System.out.println("bland"); } } class Pepper extends Food { void flavor() { System.out.println("spicy"); } } public class Lunch { public static void main(String[] args) { Pepper lunch = new Food(); lunch.flavor(); } }

Select one:

a.

bland

spicy

b.

the program does not compile

c.

no output

d.

bland

e.

spicy

10.

What is the output of the following Java program?

interface Food { public void printFlavor(); } class Pepper implements Food { public void printFlavor() { System.out.println("spicy"); } } public class Lunch { public static void main(String[] args) { Food pepper = new Pepper(); pepper.printFlavor(); } }

Select one:

a.

bland

spicy

b.

bland

c.

the program does not compile

d.

spicy

e.

no output

11.

Considering the following Java code, what is the a parameter?

Color myColor = Color.color(r, g, b, a);

a.

It defines the Opaque value

b.

It defines the Brightness value

c.

It defines the fourth color value

d.

Its a wrong parameter and the Color can be defined with only (r, g, b)

e.

It defines the Gama value

12.

What is the output of the following Java program?

class Food { String flavor = "bland"; void printFlavor() { System.out.println(flavor); } } class Pepper extends Food { String flavor = "spicy"; } public class Lunch { public static void main(String[] args) { Food lunch = new Pepper(); lunch.printFlavor(); } }

Select one:

a.

spicy

b.

the program does not compile

c.

bland

spicy

d.

bland

e.

no output

13.

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"); System.out.println(pepper.getFlavor()); } }

Select one:

a.

1

b.

2

c.

sweet

d.

spicy

e.

The program does not compile.

14.

A subclass method can _____ a superclass method with the same name and parameter types.

Select one:

a.

override

b.

inherit

c.

abstract

d.

extend

e.

implement

15.

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

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 method

b.

a public method

c.

gets executed when the program runs

d.

a setter method

e.

a static method

16.

What is the output of the following Java program?

class Food { Food() { System.out.println("bland"); } Food(String flavor) { System.out.println(flavor); } } class Pepper extends Food { Pepper() { super("spicy"); } } public class Lunch { public static void main(String[] args) { Food lunch = new Pepper(); } }

Select one:

a.

bland

b.

no output

c.

the program does not compile

d.

bland

spicy

e.

spicy

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!