Simulado Java


Simulado JAVA.

Questions on Language Fundamentals
1. Which of these are legal identifiers. Select the three correct answers.
1. number_1
2. number_a
3. $1234
4. -volatile
2. Which of these are not legal identifiers. Select the four correct answers.
1. 1alpha
2. _abcd
3. xy+abc
4. transient
5. account-num
6. very_long_name
3. Which of the following are keywords in Java. Select the two correct answers.
1. friend
2. NULL
3. implement
4. synchronized
5. throws
4. Which of the following are Java keywords. Select the four correct answers.
1. super
2. strictfp
3. void
4. synchronize
5. instanceof

5. Which of these are Java keywords. Select the five correct answers
1. TRUE
2. volatile
3. transient
4. native
5. interface
6. then
7. new

6. Using up to four characters, write the Java representation of octal literal 6.

7. Using up to four characters, write the Java representation of integer literal 3 in hexadecimal.

8. Using up to four characters, write the Java representation of integer literal 10 in hexadecimal.

9. What is the minimum value of char type. Select the one correct answer.
1. 0
2. -2 15
3. -2 8
4. -2 15 - 1
5. -2 16
6. -2 16 - 1

10. How many bytes are used to represent the primitive data type int in Java. Select the one correct answer.
1. 2
2. 4
3. 8
4. 1
5. The number of bytes to represent an int is compiler dependent.

11. What is the legal range of values for a variable declared as a byte. Select the one correct answer.
1. 0 to 256
2. 0 to 255
3. -128 to 127
4. -128 to 128
5. -127 to 128
6. -2 15 to 2 15 - 1


12. The width in bits of double primitive type in Java is --. Select the one correct answer.
1. The width of double is platform dependent
2. 64
3. 128
4. 8
5. 4

13. What would happen when the following is compiled and executed. Select the one correct answer.
public class Compare { public static void main(String args[]) { int x = 10, y; if(x < 10) y = 1; if(x>=10) y = 2; System.out.println("y is " + y); } }
1. The program compiles and prints y is 0 when executed.
2. The program compiles and prints y is 1 when executed.
3. The program compiles and prints y is 2 when executed.
4. The program does not compile complaining about y not being initialized.
5. The program throws a runtime exception.

14. What would happen when the following is compiled and executed. Select the one correct answer.
class example { int x; int y; String name; public static void main(String args[]) { example pnt = new
example(); System.out.println("pnt is " + pnt.name + " " + pnt.x + " " + pnt.y); } }
1. The program does not compile because x, y and name are not initialized.
2. The program throws a runtime exception as x, y, and name are used before initialization.
3. The program prints pnt is 0 0.
4. The program prints pnt is null 0 0.
5. The program prints pnt is NULL false false


15. The initial value of an instance variable of type String that is not explicitly initialized in the program is --. Select the one correct answer.
1. null
2. ""
3. NULL
4. 0
5. The instance variable must be explicitly assigned.

16. The initial value of a local variable of type String that is not explicitly initialized and which is defined in a member function of a class. Select the one correct answer.
1. null
2. ""
3. NULL
4. 0
5. The local variable must be explicitly assigned.
17. Which of the following are legal Java programs. Select the four correct answers.
1. // The comments come before the package
package pkg;
import java.awt.*;
class C{}
2. package pkg;
import java.awt.*;
class C{}
3. package pkg1;
package pkg2;
import java.awt.*;
class C{}
4. package pkg;
import java.awt.*;
5. import java.awt.*;
class C{}
6. import java.awt.*;
package pkg;
class C {}
18. Which of the following statements are correct. Select the four correct answers.
1. A Java program must have a package statement.
2. A package statement if present must be the first statement of the program (barring any
comments).
3. If a Java program defines both a package and import statement, then the import statement
must come before the package statement.
4. An empty file is a valid source file.
5. A Java file without any class or interface definitions can also be compiled.
6. If an import statement is present, it must appear before any class or interface definitions.
19. What would be the results of compiling and running the following class. Select the one correct
answer. class test { public static void main() { System.out.println("test"); } }
1. The program does not compile as there is no main method defined.
2. The program compiles and runs generating an output of "test"
3. The program compiles and runs but does not generate any output.
4. The program compiles but does not run.
20. Which of these are valid declarations for the main method? Select the one correct answer.
1. public void main();
2. public static void main(String args[]);
3. static public void main(String);
4. public static void main(String );
5. public static int main(String args[]);

Comentários

Anônimo disse…
Poderia colocar o gabarito do simulado, em um arquivo para download no post?

Postagens mais visitadas deste blog

Redação Ti Nota 10 - Klauss

Prova Discursiva nota 10 - Banca Cespe

Portugues - Orações