Font size
WorksheetsOops Quiz
Total questions: 40
Worksheet time: 20mins
What is the size of an int in Java?
8 bits
16 bits
32 bits
64 bits
Which of these is not a Java keyword?
Static
Void
Integer
new
Which method is the entry point for any Java program?
start()
run()
init()
main()
What is the output of System.out.println(5 + "5");?
10
55
Compilation error
Runtime error
Which of the following is the correct way to create an object in Java?
MyClass obj = MyClass();
MyClass obj = new MyClass();
obj = new MyClass();
MyClass obj();
What will System.out.println(10 / 4); print?
2.5
2
2.0
Compilation error
Which of these allows you to reuse code in Java?
Class
Object
Inheritance
Interface
What is the purpose of the final keyword?
To define a constant
To create a new object
To allow modifications
To indicate recursion
Which feature of OOPS derives new classes from existing classes?
Encapsulation
Polymorphism
Inheritance
Abstraction
Who invented JAVA programming?
Guido van Rossum
James Gosling
Dennis Ritchie
Bjarne Stroustrup
In java, objects are created using this operator
(a)
Select the correct syntax
public static void main(String args[])
public static void main(string args[])
public static void main()
public void main(String args[])
Java is a case sensitive Language.
True
False
Which of the following tells that same method name with different parameters
Methodoverloading
Override
Method overiding
Overloaded
An_____is a collection of same datatype of elements
Object
Array
Class
Framework
What is the result of combining data and the methods that operate on that data into a single unit?
Inheritance
Polymorphism
Encapsulation
Abstraction
Which principle ensures that implementation details are hidden?
Polymorphism
Abstraction
Inheritance
Encapsulation
Which keyword prevents a method from being overridden?
static
final
abstract
private
In Java, a class can implement:
Only one interface
Multiple interfaces
No interface
Only abstract classes
What is the advantage of inheritance?
Less memory use
Improved security
Code reuse
Better compilation
Which of the following best defines encapsulation?
Writing one function inside another
Keeping data and methods in the same class
Making all variables public
Using inheritance
Polymorphism allows:
Objects to take many forms
Functions to hide data
Only one method
Variables to be static
Which of the following is NOT a type of inheritance in OOP?
Single
Multiple
Multilevel
Super
Which access modifier provides the highest level of encapsulation?
public
private
protected
default
What is method overloading an example of?
Encapsulation
Compile-time polymorphism
Abstraction
Inheritance
What is the process of hiding internal details and showing functionality called?
Encapsulation
Inheritance
Abstraction
Polymorphism
Which pillar of OOP is achieved using abstract classes and interfaces?
Encapsulation
Inheritance
Polymorphism
Abstraction
Which keyword is used to inherit a class in Java?
implements
inherits
extends
includes
What does encapsulation help achieve?
Code duplication
Data hiding
Global variables
Slower performance
Which of the following is NOT a pillar of OOP?
Encapsulation
Abstraction
Compilation
Polymorphism
Which of these keywords are used to define an abstract class?
Abstract
abstract
abstract class
abst
Predict the output of following program. Note that foo() is public in base and private in derived.
class Base { public void foo() { System.out.println("Base"); }} class Derived extends Base { private void foo() { System.out.println("Derived"); } } public class Main { public static void main(String args[]) { Base b = new Derived(); b.foo(); }}
Base
Derived
Compile Time Error
Run time error
What is the output of the following code: int[] arr = new int[5]; System.out.println(arr[5]);?
No output
ArrayIndexOutOfBoundsException
0
5
Which class is the base class for all exceptions in Java?
Error
Throwable
Exception
RuntimeException
abstraction hides the
class
complexity
Which component is used to compile, debug and execute the java programs?
JRE
JVM
JIT
JDK
Which method can used to find the length of string?
stringlength()
length()
getLength()
getSize()
Which of the following is not an object-oriented programming language?
Objective C
C++
JAVA
Pascal
Which feature JAVA does not support?
Polymorphism
Inheritance
Pointer
Portable
