You are on page 1of 15

1. Which statement is true about Java?

a) Java is a sequence-dependent programming language


b) Java is a code dependent programming language
c) Java is a platform-dependent programming language
d) Java is a platform-independent programming language

2. Which one of the following is not a Java feature?


a) Object-oriented
b) Use of pointers
c) Portable
d) Dynamic and Extensible

3. What is the extension of java code files?


a) .js
b) .txt
c) .class
d) .java

4. What will be the output of the following Java code?

a) 32
b) 33
c) 24
d) 25
5. What will be the output of the following Java program?

a) NaN
b) Infinity
c) 0.0
d) all of the mentioned

6. What is not the use of “this” keyword in Java?


a) Referring to the instance variable when a local variable has the same name
b) Passing itself to the method of the same class
c) Passing itself to another method
d) Calling another constructor in constructor chaining

7. What will be the output of the following Java program?


a) Compilation error
b) Runtime error
c) 5 6 5 6
d) 5 6 5

8. What will be the output of the following Java program?

a) 1 2 3 4 5
b) 1 2 3 4
c) 1 2
d) 1 2 3
9. What is the extension of compiled java classes?
a) .txt
b) .js
c) .class
d) .java

10. Which of these are selection statements in Java?


a) break
b) continue
c) for loop
d) if statement

11. What will be the output of the following Java program?

a) 14
b) 15
c) 1
d) None of the mentioned
12. Which of the following is a superclass of every class in Java?
a) ArrayList
b) Abstract class
c) Object class
d) String
13. Which one of the following is not an access modifier?
a) Protected
b) Void
c) Public
d) Private
14. What will be the output of the following Java program?

a) 4 6.4
b) 6.4 6
c) 6.4 6.4
d) 6 6

15. What will be the output of the following Java code?

a) 0 2 4 6 8
b) 1 3 5 7 9
c) 0 1 2 3 4 5 6 7 8 9
d) 1 2 3 4 5 6 7 8 9 10

16. What will be the output of the following Java code?


a) 3
b) 0
c) 6
d) 1

17. Which of these is necessary condition for automatic type conversion in Java?
a) The destination type is smaller than source type
b) The destination type is larger than source type
c) The destination type can be larger or smaller than source type
d) None of the mentioned
18. If an expression contains double, int, float, long, then the whole expression will be
promoted into which of these data types?
a) long
b) int
c) double
d) float
19. What is true about do statement?
a) do statement executes the code of a loop at least once
b) do statement does not get execute if condition is not matched in the first iteration
c) do statement checks the condition at the beginning of the loop
d) do statement executes the code more than once always
20. Which of these can not be used for a variable name in Java?
a) identifier
b) keyword
c) identifier & keyword
d) none of the mentioned
21. Which of the following can be operands of arithmetic operators?
a) Numeric
b) Boolean
c) Characters
d) Both Numeric & Characters
22. Modulus operator, %, can be applied to which of these?
a) Integers
b) Floating – point numbers
c) Both Integers and floating – point numbers
d) None of the mentioned
23. Decrement operator, −−, decreases the value of variable by what number?
a) 1
b) 2
c) 3
d) 4
24. With x = 0, which of the following are legal lines of Java code for changing the value
of x to 1?

a) 1, 2 & 3
b) 1 & 4
c) 1, 2, 3 & 4
d) 3 & 2
25. What will be the output of the following Java program?

a) 1 1
b) 0 1
c) 1.5 1
d) 1.5 1.0

26. What is the output of relational operators?


a) Integer
b) Boolean
c) Characters
d) Double
27. Which of the following is used with the switch statement?
a) Continue
b) Exit
c) break
d) do
28. What will be the output of the following Java code?
a) 10
b) 11
c) 12
d) 56

29. All of the following are correct expect :


a) Java is a object-oriented language
b) Java is platform-independent
c) Java is more secure then most language
d) Java syntax is similar to c++ syntax
e) All of the above are true
30. Which of the following aren’t a java feature:
a) automatic garbage collector
b) no direct access to memory (no pointers)
c) multi-threading
d) dynamic type checking
e) simplified network access
31. applet is designed to be run on a web server
a) True
b) False
32. Applet usually run in a sandbox with a lot of restrictions due to security reasons
a) True
b) False
33. Applet can’t do which of the following:
a) Run local executables
b) Read or write to local files
c) Communicate with ant server other than the original server
d) All of the above
34. when we start building java program first step is preparing the source file then
invoke the compiler after that we run the java interpreter
a) True
b) False
35. Which of the following is not a decision making statement?
a) if
b) if-else
c) switch
d) do-while
36. The compiler generate .java files which contain byte codes that will be executed by
the JVM(java virtual machine)
a) True
b) False
37. When Overloading does not occur?
a) More than one method with same name but different method signature and
different number or type of parameters
b) More than one method with same name, same signature but different number of
signature
c) More than one method with same name, same signature, same number of
parameters but different type
d) More than one method with same name, same number of parameters and type
but different signature
38. Which of these keywords is used to make a class?
a) class
b) struct
c) int
d) none of the mentioned
39. Which of the following is a valid declaration of an object of class Box?
a) Box obj = new Box();
b) Box obj = new Box;
c) obj = new Box();
d) new Box obj;
40. Which of the following is not a valid flow control statement?
a) exit()
b) break
c) continue
d) return
41. Which of these operators is used to allocate memory for an object?
a) malloc
b) alloc
c) new
d) give
42. What will be the output of the following Java program?

a) 12
b) 200
c) 400
d) 100
43. What will be the output of the following Java program?

a) 0
b) 1
c) Runtime error
d) classname@hashcode in hexadecimal form
44. Constructer is a special method or function that initializes a class instance (an object)
a) True
b) False

45. A class can’t have many constructors


a) True
b) False
46. The keyword “this” refer to the current object
a) True
b) False
47. Which of these statements are incorrect:
a) Classes can inherit the methods and variables of other classes
b) The keywor0d “extends” creates a subclass of another subclass
c) Inheritance allows reusing the variables and methods of existing classes
d) Usually the default constructor of any class is the one with zero parameters
48. What is false about constructor?
a) Constructors cannot be synchronized in Java
b) Java does not provide default copy constructor
c) Constructor can have a return type
d) “this” and “super” can be used in a constructor
49. Which of these can be overloaded?
a) Methods
b) Constructors
c) All of the mentioned
d) None of the mentioned
50. What will be the output of the following Java code?
a) int float method
b) float int method
c) compile time error
d) run time error
51. What is the process of defining a method in a subclass having same name & type
signature and same parameter types as a method in its superclass?
a) Method overloading
b) Method overriding
c) Method hiding
d) None of the mentioned
52. Overriding is Useful to customize a generic method defined in the superclass to
the subclass
a) True
b) False
53. Which of these are true about arrays
a) Array is list of similar things
b) Array have a fixed name , type and length (size)
c) Array elements are accessed by their index
d) An array start at 0th position instead of 1st position
e) All of the above are true
54. to make an array we follow these 3 steps first is declaring the array like this {int
array[]; } then create it like this { array[] = new int[4] } last step is initialize like this
{array[0] = 1; array[1] = 5; array[3] = 25; etc}
a) True
b) False
55. What is the steps to create an array of object
a) Declare array and create it
b) Declare array and create object
c) Declare array, create it and initialize
d) Declare array, create it, create objects and add the objects to array

You might also like