NEW
Font size
WorksheetsJava Programming Quiz - 3
Total questions: 30
Worksheet time: 17mins
Which of these cannot be used for a variable name in Java?
identifier & keyword
identifier
keyword
none of the mentioned
Which component is used to compile, debug and execute the java programs?
JRE
JIT
JDK
JVM
Which of the following is not an OOPS concept in Java?
Polymorphism
Compilation
Inheritance
Encapsulation
Which of these are selection statements in Java?
break
continue
for()
if()
What is the value stored in x in following lines of code?
int x, y, z;
x = 0;
y = 1;
x = y = z = 8;
1
9
8
0
Evaluate the following Java expression, if x=3, y=5, and z=10:
++z + y - y + z + x++
24
23
20
25
Which of the following for loop declaration is not valid?
for ( int i = 99; i >= 0; i / 9 )
for ( int i = 7; i <= 77; i += 7 )
for ( int i = 20; i >= 2; - -i )
for ( int i = 2; i <= 20; i = 2* i )
What does JVM stands for?
Java Variable Machine
Java Virtual Machine
Java Virtual Mechanism
None of the above
What are the main Distribution types of Java Software?
Java SE (Java Standard Edition)
Java EE (Java Enterprise Edition)
Java ME (Java Micro Edition)
All the above
What is JVM ?
JVM is the confined memory area
All java programs run inside JVM memory
JVM provides security to the computer by giving controlled access to Files and Memory on a computer
All the above
Output of following Java Program?
Derived::show() called
Base::show() called
Run time Error
Compilation Error
What will be the output of following program?
Base::show() called
Derived::show() called
Compiler Error
Runtime Error
Which inheritance in java programming is not supported
Multiple inheritance using classes
Multiple inheritance using interfaces
Multilevel inheritance
Single inheritance
Predict the output of following program
Base
Derived
Compiler Error
Runtime Error
A class member declared protected becomes a member of subclass of which type?
public member
private member
protected member
static member
In order to restrict a variable of a class from inheriting to subclass, how variable should be declared?
Protected
Private
Public
Static
If super class and subclass have same variable name, which keyword should be used to use super class?
super
this
upper
classname
Order of execution of constructors in Java Inheritance is
Base to derived class
Derived to base class
Random order
none
In a Multi-Level Inheritance in Java, the last subclass inherits methods and properties of ____.
Only one immediate Superclass
Few classes above it.
All classes above it
None of the mentioned
Class Cat extends Animal. Which is NOT a valid declaration?
Cat x = new Cat();
Animal X = new Animal();
Cat x = new Animal();
Animal x = new Cat();
When overloading a method, the method header ________ .
Must exactly match the header of the method you are overloading.
Must have the same name, but differ in order, number, or type of parameters.
Can differ in name, but must have the same number and order of parameters.
Can be completely different from the method you are overloading, but must have @Override.
What is the output of this program?
0
1
2
Compilation Error
What is the output of this program?
2 2
3 3
2 3
3 2
What is the output of this program?
1 2
2 1
Runtime Error
Compilation Error
Which of the following is/are false about inheritance in Java?
I. A subclass inherits all the methods and variables of the superclass.
II. A subclass can override the methods of its superclass
III. A subclass has access to the private instance variables of the superclass.
I only
II only
III only
I and II only
I and III only
super keyword is used to access
only subclass methods
parent class variables and methods
subclass variables and methods
only parent class methods
