You are on page 1of 2

1. Which of the following is syntactically wrong c.

Import and package statement apply to all


a. Int a; classes in source code file
b. Int b; d. All of the above
c. Int_a
d. None of the above 9. Which of the following is correct syntax of
2. Which of the following is syntactically correct declaring enum
a. Int d2 a. Enum Days {MON, TUE, WED}
b. Int emp b. Enum Days {MON, TUE, WED};
c. Int $student c. Both
d. All of the above d. None of the above
3. Which of the following is true regarding source 10. Which of the following is true about enum
code file? a. An enum can be declared inside or
a. It can have more than one public class outside a class
b. It can have more than one nonpublic class b. An enum cant be declared inside a
and one public class method
c. It can not have nonpublic class c. Enum constructor can have arguments
d. None of the above and can be
4. What is true regarding following code in d. None of the above
Student.java 11. How many access modifiers are there is java?
Public class Student {} a. 2
Public class ABC {} b. 3
a. Compilation Error c. 4
b. Runtime Error d. 1
c. No Error 12. How many access levels are there is java
d. None of the above a. 2
5. Which of the following is true regarding source b. 3
code file c. 4
a. File name must match with public class d. 1
name 13. Which of the following class will not compile]
b. File name can be anything a. Class A {}
c. File name must match with nonpublic file b. Public class B{}
d. None of the Above c. Protected Class B{}
6. What is true regarding following code in d. All of the above will compile
Emp.java 14. Which of the following class will be accessible in
Class Emp {} same package but not outside
Public class ABC {} a. Class X {}
b. Public class Y {}
a. Compilation Error c. Private class Z {}
b. Runtime Error d. All of the above
c. No Error 15. Which of the following method will not compile
d. None of the above a. Public void show () { int a=10; }
7. What is true regarding following code in b. Public void show () { final int b=10; }
ABC.java c. Public void show () { private int c=10; }
Class Student {} d. All of the above will compile
Class Emp {} 16. Which of the following method will not compile
a. Public void aMethod () { int a; int b=a;}
a. Compilation Error b. Public void aMethod () { final int b=10;}
b. Runtime Error c. Public void aMethod () { int a; }
c. No Error d. All of the above will compile
d. None of the above
17. Which of the following is true about static
8. Which of the following is true? a. There is only one copy of static variables
a. Package statement must be first in a source b. Static methods cannot access non-static
code file members
b. File can have multiple import statements but c. Static variable is accessed using class
only one package statement name
d. All of the above {
18. Which of the following method name does not Public static void main(String[] args)
follow Javabeans standard {
a. getData Long l=23432l;
b. setData Int I =l;
c. putData System.out.println(i);
d. isValid }
19. What is incorrect of syntax for using variable- }
arguments (var-args) in method a. 23432
a. Void doSomething (int.a){} b. Compile time error
b. Void doSomething (int a, int.b){} c. Unexpected
c. Void doSomething (int.a, int b){} d. None of the above
d. None of the above 28. What is output of following program?
20. What is correct of syntax for using variable-
arguments (var-args) in method Class Data Types
a. Void doSomething (int a.){} {
b. Void doSomething (int a, int.b, int.a){} Public static void main(String[] args)
c. Void doSomething (int. a, int b.{} {
d. None of the above Long l=2345334456;
21. What is correct of syntax of creating object of Int i=(int)l;
class XYZ System.out.println(i);
a. XYZ object=new XYZ; }
b. XYZ object=new XYZ(); }
c. XYZ object=new XYZ[];
d. None of the above a. 2345334456
22. Instance variable can have b. Compile time error
a. Only public access modifier c. Unexpected
b. Only public or private access modifier d. None of the above
c. Only public or private or protected access 29. What is ouput of following program?
modifier
d. Public or private or protected or default Class Data Types
access {
23. What is the range of byte' data type in Java? Public static void main(String[]args)
a. -32768 to 32767 {
b. -128 to 127 Long l=2343223345l; System.output.println; }
c. 1.7e-308 }
d. None of the above a. 2343223345
24. What is the range of int data type in Java? b. Compile time error
a. -32768 to 32767 c. Runtime error
b. -2,147,483,648 to 2,147,483,647 d. None of the above
c. 1.7e-308 30. What is the range of char data type in Java?
d. None of the above a. -32768 to 32767
25. What is the range of short data type in Java? b. 0 to 65,535
a. -32768 to 32767 c. 1.73-308
b. -128 to 127 d. None of the above
c. 1.7e-308
d. None of the above
26. What is the range of long data type in Java?
a. -32768 to 32767
b. -2,147,483,648 to 2,147,483,647
c. -9,223,372,036,854,775,808 to
9,223,372,036,854,775,807
d. None of the above
27. What is output of following program?

Class DataTypes

You might also like