NEW
Font size
WorksheetsOOP_1
Total questions: 10
Worksheet time: 5mins
What will str1==str2 return if both refer to the same string literal?
true
false
compilation error
0
What is the purpose of a constructor?
To destroy objects
to call methods
to initialise object
to inherit classes
Which of these is an incorrect array declaration?
int arr[] = new int[5]
int [] arr = new int[5]
int arr[] = new int[5]
int arr[] = int [5] new
Which access modifier makes a member accessible within the same package?
public
private
protected
default(no modifier)
What does the static keyword mean in a method declaration?
The method belongs to an object
The method can only be called once
The method belongs to the class, not instances
The method cannot be accessed
What is constructor overloading?
Having multiple constructors with different names
Having multiple constructors with different return types
Having multiple constructors with different parameters
Having a constructor inside a method
Which of these method of String class can be used to test to strings for equality?
isequal()
isequals()
equal()
equals()
What will be the output of the following Java program?
9
10
11
12
false false
true true
true false
false true
How many constructors can a class have in Java?
only one
two
As many as needed (overloaded)
none
