Core Java Test Paper

Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

1. What is Java? b.

A way to create a new object


a. A type of coffee c. A way to override a method in a
b. A programming language subclass
c. A type of bird d. A way to overload a method in a class
d. A type of car 9. What is an interface in Java?
2. What is the main difference between Java a. A type of variable
and other programming languages? b. A blueprint for a class
a. Java is object-oriented c. A type of method
b. Java is a compiled language d. A way to create a new object
c. Java is interpreted 10. What is a constructor in Java?
d. All of the above a. A way to create a new object
3. What is a Java Virtual Machine? b. A way to initialize an object
a. A type of coffee maker c. A way to define a new method
b. A software that allows Java code to be d. A way to define a new variable
executed on different operating systems 11. What is a package in Java?
c. A device used for virtual reality gaming a. A way to group related classes and
d. None of the above interfaces
4. Which of the following is a primitive data b. A way to create a new object
type in Java? c. A way to define a new method
a. String d. A way to define a new variable
b. Integer 12. What is a static method in Java?
c. Float a. A method that can only be accessed by
d. Boolean an instance of a class
5. What is an object in Java? b. A method that can only be accessed by
a. A type of variable the class itself
b. An instance of a class c. A method that can be accessed by any
c. A method object
d. A reserved keyword d. None of the above
6. What is inheritance in Java? 13. What is a static variable in Java?
a. A way to define a new class based on a. A variable that can only be accessed by
an existing class an instance of a class
b. A way to define a new method b. A variable that can only be accessed by
c. A way to define a new variable the class itself
d. None of the above c. A variable that can be accessed by any
7. What is polymorphism in Java? object
a. A way to create a new object d. None of the above
b. A way to override a method in a 14. Find the output of the following code.
subclass int Integer = 24;
c. A way to overload a method in a class char String = ‘I’;
d. All of the above System.out.print(Integer);
System.out.print(String);
8. What is encapsulation in Java?
a. A way to protect data by hiding
a. Compiler error
implementation details
b. Throws exception
c. I d. Method
d. 24I 19. Which of the Following is used to find and fix
15. Find the output of the following Code? bugs in the Program
Public class solution{ a. JDK
Public static voicemail (String[] ARGS) b. JRE
{ c. JVM
Short X = 10; d. JDB
X = X * 5; 20. Output of Math.floor(3.6)?
System.out.print(X); a. 3
} b. 3.0
} c. 4
a. 50 d. 4.0
b. 10 21. Which of the following keyword support
c. Compile error dynamic method resolution?
d. Exception a. Abstract
16. Find the output of the following code b. Virtual
Public class solution{ c. Dynamic
Public static voicemail (String[] ARGS){ d. Typeid
Byte x = 127; 22. Which feature in OOPs allows reusing code?
x++; a. Polymorphism
x++; b. Inheritance
system.out.print(x); c. Encapsulation
} d. Data hiding
} 23. An error element is accessed using?
a. 130 a. The dot operator
b. 127 b. A member name
c. 129 c. An index number
d. 128 d. An asterisk(*)
17. Find the value of a[1] after executing the 24. Element in an array identified by an
following program unique____
Int[] A = {0,2,4,1,3}; a. Data Type
For(int I = 0; i< a.lenght; i++) b. Subscript
{ c. Order
a[i] = a[(a[i]+3)%a.lenght]; d. Symbol
} 25. The void function does have return type?
a. 0 a. True
b. 1 b. False
c. 2 26. Write a program to check if a number is
d. 3 prime
18. What is Runnable?
27. Write a program to find the second largest
a. Abstract class number in an array.
b. Interface 28. Write a program to count the number of
c. Class vowels in a string

You might also like