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

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 14:50
Drag each label to the correct location on the image list the do’s and don’ts of safeguarding your password. a. keep yourself logged in when you leave your computer.b. don’t write your password down and leave it where others can find it.c. share your password with your friends.d.each time you visit a website,retain the cookies on your computer.e. use a long password with mixed characters.1. do's 2. don'ts
Answers: 2
question
Computers and Technology, 23.06.2019 15:10
What role did women fill during world war ii?
Answers: 1
question
Computers and Technology, 24.06.2019 00:20
Describe a data structures that supports the stack push and pop operations and a third operation findmin, which returns the smallest element in the data structure, all in o(1) worst-case time.
Answers: 2
question
Computers and Technology, 24.06.2019 19:50
Which is a characteristic of free and open-source software licenses? a. the source code is unavailable to everyone b. the source code is available only to the government c. the source code is available to all users d. the source code is constantly modified
Answers: 1
You know the right answer?
9. consider the following code.
int x = 2;
switch (x) {
case 1: x += 3;
...
Questions
question
Mathematics, 13.09.2019 01:30
question
Mathematics, 13.09.2019 01:30
question
Mathematics, 13.09.2019 01:30
question
Geography, 13.09.2019 01:30
Questions on the website: 13722363