Question
1. public static void main(String[] args) { Pizza p1 = new Pizza(); String[] toppings = p1.getToppings(); } Which of the following is true? a. p1
1. public static void main(String[] args)
{ Pizza p1 = new Pizza();
String[] toppings = p1.getToppings(); }
Which of the following is true?
a. p1 is static
b. getToppings() is an instance method
c. getToppings() is a constructor
d. p1 is a class definition
2. A class variable does not belong to a particular object. It belongs to the entire class. Which field below is an example of a class variable?
public class Pizza { private static int numPizzas; private static int numRestaurants; private static double reheatTemperature; private static String foodGroup; private String name; private String[] toppings; private double calories; private double price; }
a. name
b. price
c. calories
d. foodGroup
3. You need to calculate the execution time of your program. You recall a function that returns the number of milliseconds since UNIX Epoch. You can use that function to stamp the start and end of your program. Then you can calculate the elapsed time. That function is in which class?
a. Point2D
b. Random
c. Date
d. Scanner
4. Which of the following is most like the array concept?
a. a power strip
b. a car
c. airplane seats
d. a glass
5. Given this array:
String[] colors = {"red","orange","yellow","green","blue","indigo","violet"};
What is the index of yellow?
a. 3
b. 2
c. 4
d. 1
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started