1. What is Java SE?

A. Java Standard Edition
B. Java Software Editor
C. Java Scientific Edition
D. Java Software Emulator

2. Which of the following is the correct header for the main method of a Java program?

A. public static void main(String args)
B. public abstract void main(String[] args )
C. public static void main(String[] args )
D. public static int main(String[] args )

3. Which of the following statements creates a constant in Java?

A. int const = 5;
B. const int x = 5;
C. final int x = 5;
D. const x = 5;

4. Which of the following statements displays 17?

A. System.out.println (2*4+3*2+1);
B. System.out.println ((2*4+3)*2+1);
C. System.out.println (2*4+(3*(2+1)));
D. System.out.println (2*(4+3*2)+1);

If x is an int and the original value of x is 5, which of the following statements assigns an even value to x?

5.

A. x += 2;
B. x /= 3;
C. x %= 3;
D. x *= 3;

6. If x is an int, Which expression will always evaluate to true if x is evenly divisible by 5

A. x == 5
B. x % 2 == 5
C. x % 2 == 0
D. x % 5 == 0

7. Consider the following directions.

int y = 5;
int z = 10;

Which of the following expressions evaluates to true?

A. y > 5 && z >= 10
B. z / y >= 2 && y * 2 > z
C. y - z >0 || y * 4 == z * 2
D. y + z == z + y && z - y == y - z

8. Consider the following code.

int x = 2.
switch (x) {
case 1: x += 3;
case 2: x += 5;
case 3: x += 7;
default: x += 10;
}

After the switch statement, what is the value of x?

A. 2
B. 5
C. 7
D. 24

9. If y refers to an array of int values with seven elements, and all of those elements have been given a value of 5, which statement would change the last element of a 2?

A. y {7] = 2
B. y [6] = 2
C. y [2] = 6
D. y [2] = 7

10. Consider the following declaration.

int [] two = {{1, 2, 3}, {4, 5}};

Which arithmetic expression evaluates to a value of 8?

A. two[3] + two[2]
B. two[2] + two [1]
C. two[1] [3] + two[2] [2]
D. two[0] [2] + two[1] [1]

11. Consider the following method.

public static void print (int a, int ) {
System.out.println ("The sum is" + (a+b));
}

If the print method is in the same class as the main method and there are no other methods named print, which of the following statements, called from the main method, will not cause a compiler error?

A. System.out.println (print (2, 3));
B. System.out.println (print (2 + 3));
C. print (2, 3);
D. print (2 + 3);

12. Which of the following expressions correctly and most accurately calculates the area of a circle with radius r?

A. Math.pow (r, 2) * Math.PI
B. Math.power (r, 2) * Math.PI
C. Math.pow (2, r) * Math.PI
D. Math.exp (r, 2) * Math.PI

13. Consider the following code.

public class Amazing {
int x;
int y;
}

Which of the following shows a statement that will create an instance of class Amazing and assign its reference to a reference variable?

A. Amazing a = new Amazing;
B. Amazing a = new Amazing ();
C. Amazing a = Amazing ();
D. It is not possible to create an instance of class Amazing. It does not have a constructor.

14. Consider the following code.

public class Employee () {
private String firstName;
private String lastName;
private int empId;
}
Which of the following shows a constructor that, if added to class Employee, would allow a caller to create an object and pass in values from the call that will be assigned to its instance variables?

A. public Employee () {
firstName = “Fred”;
lastName = “Jones”;
empId = 101;
}

B. public Employee (String a, String b, int c) {
firstName = a;
lastName = b;
empId = c;
}

C. public Employee (“Fred”, “Jones”, 101) {
firstName = a;
lastName = b;
empId = c;
}

D. public Employee (String a, String b, int c) {
firstName = “Fred”;
lastName = “Jones”;
empId = 101;
}

15. What is the output of the following code?

String name1 = “Chris”;
String name2 = “Christine”;
boolean b = name1 . startsWith (name2);
boolean c = name1 . charAt (4) == name2 . CharAt (7);
System.out.println (b + “, ” + c);

A. true, true
B. true, false
C. false, true
D. false, false

Respuesta :

Answer:

1. What is Java SE?

A. Java Standard Edition

2. Which of the following is the correct header for the main method of a Java program?

C. public static void main(String[] args )

3. Which of the following statements creates a constant in Java?

B. const int x = 5;

4. Which of the following statements displays 17?

C. System.out.println (2*4+(3*(2+1)));

If x is an int and the original value of x is 5, which of the following statements assigns an even value to x?

5.

C. x %= 3;

6. If x is an int, Which expression will always evaluate to true if x is evenly divisible by 5

C. x % 2 == 0

D. x % 5 == 0

7. Consider the following directions.

int y = 5;

int z = 10;

Which of the following expressions evaluates to true?

C. y - z >0 || y * 4 == z * 2

8. Consider the following code.

int x = 2.

switch (x) {

case 1: x += 3;

case 2: x += 5;

case 3: x += 7;

default: x += 10;

}

After the switch statement, what is the value of x?

D. 24

9. If y refers to an array of int values with seven elements, and all of those elements have been given a value of 5, which statement would change the last element of a 2?

B. y [6] = 2

10. Consider the following declaration.

int [] two = {{1, 2, 3}, {4, 5}};

Which arithmetic expression evaluates to a value of 8?

D. two[0] [2] + two[1] [1]

11. Consider the following method.

public static void print (int a, int ) {

System.out.println ("The sum is" + (a+b));

}

If the print method is in the same class as the main method and there are no other methods named print, which of the following statements, called from the main method, will not cause a compiler error?

C. print (2, 3);

12. Which of the following expressions correctly and most accurately calculates the area of a circle with radius r?

A. Math.pow (r, 2) * Math.PI

13. Consider the following code.

public class Amazing {

int x;

int y;

}

Which of the following shows a statement that will create an instance of class Amazing and assign its reference to a reference variable?

B. Amazing a = new Amazing ();

14. Consider the following code.

public class Employee () {

private String firstName;

private String lastName;

private int empId;

}

Which of the following shows a constructor that, if added to class Employee, would allow a caller to create an object and pass in values from the call that will be assigned to its instance variables?

B. public Employee (String a, String b, int c) {

firstName = a;

lastName = b;

empId = c;

}

15. What is the output of the following code?

String name1 = “Chris”;

String name2 = “Christine”;

boolean b = name1 . startsWith (name2);

boolean c = name1 . charAt (4) == name2 . CharAt (7);

System.out.println (b + “, ” + c);

A. true, true

Explanation:

The questions in the answer section are being followed by answer. Some explanation is necessary. Regarding which, the cases are executed from the case that is accepted by expression in switch, and continue execution till last if break keyword is not mentioned. And default can come anywhere, and hence since its after case 2 here, it will be executed as well. And hence that answer. Also if a class does not have an explicit super class, it has an implicit super class (object), and this has the zero args constructor. And hence when we do not mention constructor in a class, a default constructor is created automatically, and hence an object can be created, and hence the above answer. However, format must be correct. Rest are self explanatory.

Answer:

1. What is Java SE?

A. Java Standard Edition

Good luck

Explanation: