Xin a e chỉ giúp mấy câu lí thuyết java I này !

Đề 1:Question 1)
Which of the following lines will compile without warning or error.
1) float f=1.3;
2) char c="a"; (dap an minh chon)
3) byte b=257;
4) boolean b=null; (dap an minh chon)
5) int i=10; Question 2)
What will happen if you try to compile and run the following code
public class MyClass {

public static void main(String arguments[]) {

amethod(arguments);

}

public void amethod(String[] arguments) {

System.out.println(arguments);

System.out.println(arguments[1]);

}

}
1) error Can't make static reference to void amethod. ( dap an minh chon )
2) error method main not correct
3) error array must include parameter
4) amethod must be declared with String Question 3)
Which of the following will compile without error
1)
import java.awt.*;

package Mypackage;

class Myclass {}
2)
package MyPackage;

import java.awt.*; (dap an minh chon)

class MyClass{}
3)
/*This is a comment */

package MyPackage;

import java.awt.*;

class MyClass{}

Question 4)
A byte can be of what size
1) -128 to 127
2) (-2 power 8 )-1 to 2 power 8
3) -255 to 256
4)depends on the particular implementation of the Java Virtual machine Question 5)
What will be printed out if this code is run with the following command line?
java myprog good morning
public class myprog{

public static void main(String argv[])
{

System.out.println(argv[2])

}
}
1) myprog
2) good
3) morning
4) Exception raised: "java.lang.ArrayIndexOutOfBoundsException: 2" (dap an minh chon)Question 6)
Which of the following are keywords or reserved words in Java?
1) if (dap an minh chon)
2) then
3) goto
4) while
5) case (dap an minh chon)Question 7)
Which of the following are legal identifiers
1) 2variable
2) variable2
3) _whatavariable
4) _3_
5) $anothervar
6) #myvar Question 8)
What will happen when you compile and run the following code?

public class MyClass{

static int i;

public static void main(String argv[]){

System.out.println(i);

}

}
1) Error Variable i may not have been initialized
2) null
3) 1
4) 0 (dap an minh chon)

Question 9)
What will happen if you try to compile and run the following code?
public class Q {

Question 15)
Which of the following statements are true?
1) Methods cannot be overriden to be more private
2) Static methods cannot be overloaded
3) Private methods cannot be overloaded
4) An overloaded method cannot throw exceptions not checked in the base classQuestion 16)

What will happen if you attempt to compile and run the following code?
Integer ten=new Integer(10);

Long nine=new Long (9);
System.out.println(ten + nine);

int i=1;
System.out.println(i + ten);
1) 19 followed by 20
2) 19 followed by 11
3) Error: Can't convert java lang Integer
4) 10 followed by 1
Question 17)
What will happen if you attempt to compile and run the following code?
1) Compile and run without error
2) Compile time Exception
3) Runtime Exception
class Base {}

}
}Question 18)
Which of the following statements are true?
1) System.out.println( -1 >>> 2);will output a result larger than 10
2) System.out.println( -1 >>> 2); will output a positive number
3) System.out.println( 2 >> 1); will output the number 1
4) System.out.println( 1 <<< 2); will output the number 4
Question 19)

Which of the following methods can be legally inserted in place of the comment //Method Here ?
class Base{

if(args.length > 1)
System.out.println(i);
if(args.length > 0)
System.out.println(i - 1);
else
System.out.println(i - 2);
}
}
A. test (dap an minh chon)
B. test -1
C. 0
D. 1
E. 24. Which of the following is a Java keyword. Select the four correct answers.
A. extern (dap an minh chon)
B. synchronized
C. volatile
D. friend
E. friendly
F. transient
G. this (dap an minh chon)
H. then5. Is the following statement true or false. The constructor of a class must not have a return type.
A. true
B. false6. What is the number of bytes used by Java primitive long. Select the one correct answer.
A. The number of bytes is compiler dependent.
B. 2
C. 4
D. 8
E. 647. What is returned when the method substring(2, 4) of the String "Example".
A. “am”
B. “amp”
C. “ampl”
D. “xa”8. What is the result of evaluating the expression 14 | 13. Select the one correct answer.
A. 14
B. 13
C. 27
D. 15 9. Which of the following is true. Select the two correct answers.
A. A class that is abstract may not be instantiated.
B. The final keyword indicates that the body of a method is to be found elsewhere. The code is written in non-Java language, typically in C/C++.
C. A static variable indicates there is only one copy of that variable.
D. A method defined as private indicates that it is accessible to all other classes in the same package.10. What all gets printed when the following program is compiled and run. Select the two correct answers.
public class test {
public static void main(String args[]) {
int i, j=1;
i = (j>1)?2:1;
switch(i) {
case 0: System.out.println(0); break;
case 1: System.out.println(1);
case 2: System.out.println(2); break;
case 3: System.out.println(3); break;
}
}
}
A. 0
B. 1 (dap an minh chon)
C. 2 (dap an minh chon)
D. 3 11. What all gets printed when the following program is compiled and run. Select the one correct answer.
public class test {
public static void main(String args[]) {
int i=0, j=2;
do {
i=++i;
j--;
} while(j>0);
System.out.println(i);
}
}

B. The final keyword indicates that the body of a method is to be found elsewhere. The code is written in non-Java language, typically in C/C++.
C. A static variable indicates there is only one copy of that variable.

10. What all gets printed when the following program is compiled and run. Select the two correct answers.

B. 1 (dap an minh chon)
C. 2 (dap an minh chon)

11. What all gets printed when the following program is compiled and run. Select the one correct answer.

C. 2 (dap an minh chon)

12. What all gets printed when the following gets compiled and run. Select the three correct answers.

B. 1
D. 3 (dap an minh chon)
E. 4 (dap an minh chon)

13. What all gets printed when the following gets compiled and run. Select the two correct answers.

E. 4 (dap an minh chon)

14. What all gets printed when the following gets compiled and run. Select the two correct answers.

B. 2
C. 3 (dap an minh chon)

15. What all gets printed when the following gets compiled and run. Select the two correct answers.

B. 2 (dap an minh chon)
C. 3 (dap an minh chon)

16. Which of the following are legal array declarations. Select the three correct answers.
B. int i[][];
C. int []i[];
E. int[][] a;

17. What gets printed when the following code is compiled and run. Select the one correct answer.
A. 0 (dap an minh chon)

18. Which of the following are legal identifier names in Java. Select the two correct answers.

D. package

19. String s = new String("xyz");
Assuming the above declaration, which of the following statements would compile. Select the one correct answer.