1) Which of the following is the name of a local variable in the Strange class b
ID: 3819250 • Letter: 1
Question
1) Which of the following is the name of a local variable in the Strange class below?
public class Strange{
public static final int MAX = 5;
public static void unknown(){
int number = 0;
for (int i = MAX; i >= 1; i--)
number += i * i;
System.out.println(number);
}
public static void main(String[] a){
unknown();
}
}
a) Strange
2) Which of the following is NOT a method of the Graphics object?
3) Which of the following statements constructs an object?
4) What is the correct syntax for declaring a class constant named BET_LIMIT?
5) Which of the operators listed below has the highest precedence? (Be able to list all operators in order of precedence for the test.)
6) Which of the following are primitive data types in Java (mark all correct answers).
7) Which of the following is the name of a data type in Java? Mark all that apply. (Recall that every variable is declared using a data type to specify the kind of information that can be stored in the variable.)
8) Enter the index value (a number) that identifies the first character in a String object.
9) The abs() method in the Math class is an overloaded method. How many different versions are there?
10) What is the proper way to instantiate a DrawingPanel object?
b) intExplanation / Answer
1) Ans is: d - number
The variable 'number' is local variable which is accessible only in 'unknown()' method
2) Ans is: a - getGraphics
There is no such method called getGraphics is defined inside Graphics class
3) Ans is: e)All of the above statements construct objects.
4) Ans is: d)public static final int BET_LIMIT = 1000;
5) Ans is: d)() (parentheses)
Very first precedence is for () parenthesis and for rest the others are (% Modulus) then (+ Addition) and finaly (= assignment)
6) Ans are: int , boolean , double
7) Ans is: d)class
8) Ans is: 0
9) Ans is: c 4
10) Ans is: d)DrawingPanel dp = new DrawingPanel(500, 500);
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.