subject
Computers and Technology, 13.10.2019 08:10 ur4286

9. consider the following code.
int x = 2;
switch (x) {
case 1: x += 3;
case 2: x += 5;
case 3: x += 7;
default: x += 10;
}
which syntax correctly prints an array?
for (int n = 1; n < = x. length; n++) {
system. out. println(x[n]);
}
for (int n=0; n < = x. length; n++) {
system. out. println(x[n]);
}
for (int n = 1; n < x. length; n++) {
system. out. println(x[n]);
}
for (int n=0; n < x. length; n++) {
system. out. println(x[n]);
}
10. consider the following declaration.
int[] two = {{1,2,3}, {4,5}};
which arithmetic expression evaluates to a value of 8?
two[3] + two[2]
two[2] + two[1]
two[1][3] + two[2][2]
two[0][2] + two[1][1]
11. consider the following method.
public static void print (int a, int b) {
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?
system. out. println(print(2,3));
system. out. println(print(2 + 3));
print(2, 3);
print(2 + 3);

12. which of the following expressions correctly and most accurately calculates the area of a circle with radius r?
math. pow(r, 2) * math. pi
math. power(r,2) * math. pi
math. pow(2, r) * math. pi
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?
amazing a = new amazing;
amazing a = new amazing();
amazing a = amazing();
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 that will be assigned to its instance variables?
public employee() {
firstname = "fred";
lastname = "jones";
empid = 101;
}
public employee(string a, string b, int c) {
firstname = a;
lastname = b;
empid = c;
}
public employee("fred", "jones", 101) {
firstname = a;
lastname = b;
empid = c;
}
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);
true, true
true, false
false, true
false, false

ansver
Answers: 1

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 15:00, taylorsamodell3217
Who is the first president to use social media as part of his campaign strategy
Answers: 1
image
Computers and Technology, 22.06.2019 18:30, smariedegray
All of the following are characteristics that must be contained in any knowledge representation scheme except
Answers: 3
image
Computers and Technology, 22.06.2019 19:10, sammigrace5820
How might the success of your campaign be affected if you haven’t carefully completed all field data or if you accidentally insert the wrong merge field in the document?
Answers: 1
image
Computers and Technology, 24.06.2019 00:00, miguelturner
Which tool could be used to display only rows containing presidents who served two terms
Answers: 3
You know the right answer?
9. consider the following code.
int x = 2;
switch (x) {
case 1: x += 3;
...

Questions in other subjects:

Konu
Mathematics, 11.01.2022 22:50
Konu
Mathematics, 11.01.2022 22:50
Konu
Mathematics, 11.01.2022 22:50
Konu
French, 11.01.2022 22:50