Submitted by c-admin on Mon, 05/27/2019 - 23:23
Which of the following is illegal?
Select 1 option
A. char c = 320;
B. float f = 320;
C. double d = 320;
D. byte b = 320;
E. None of the above is illegal.
Submitted by c-admin on Mon, 05/27/2019 - 23:21
Given:
class Square {
private double side = 0;
String color;
public Square(double length){
this.side = length;
}
public double getSide() { return side; }
public void setSide(double side) { this.side = side; }
}
public class TestClass {
public static void main(String[] args) throws Exception {
Square mysq = new Square(10);
mysq.color = "red"; //set mysq's side to 20
}
}
Which of the following statements will set mysq's side to 20?
Select 1 option
A. mysq.side = 20;
B. mysq = new Square(20);
C. mysq.setSide(20);
D. side = 20;
E. Square.mysql.side = 20;
Submitted by c-admin on Mon, 05/27/2019 - 23:11
Which line(s) of code in the following program will cause a compilation error?
public class TestClass{
static int value = 0; //1
public static void main(String args[]) //2
{
int 2ndArgument = Integer.parseInt(args[2]); //3
if( true == 2 > 10 ) //4
{
value = -10;
}
else{
value = 2ndArgument;
}
for( ; value>0; value--) System.out.println("A"); //5
}
}
Select 1 option
A. 1
B. 2
C. 3
D. 4
E. 5
Submitted by c-admin on Mon, 05/27/2019 - 23:07
Which of the following are valid declarations within a class?
Select 2 options
A. volatile int k;
B. abstract boolean bool;
C. native float radix;
D. friendly int ArrayList;
E. int friendly, ArrayList;
Submitted by c-admin on Mon, 05/27/2019 - 23:02
Which of the following declaration are valid:
1. bool b = null;
2. boolean b = 1;
3. boolean b = true|false;
4 bool b = (10<11);
5. boolean b = true||false;
Select 1 option
A. 1 and 4
B. 2, 3, and 5
C. 2 and 3
D. 3 and 5
E. 5
Pages