Font size
WorksheetsOOP - Java Classes
Total questions: 15
Worksheet time: 12mins
Which one of the following is a valid statement?
char[] c = new char();
char[] c = new char[5];
char[] c = new char(4);
char[] c = new char[];
Which is the correct way of knowing Array Size in Java?
int[] ary;
ary.length()
int[] ary;
ary.length
int[] ary;
ary->length()
int[] ary;
ary->length
A ___________ is a pre-defined set of steps that complete a specific task, optionally based on parameter values, and optionally returning some result.
array
function
method
module
class
Predict the output of the following program.
class A{
int a=40;//non static
public static void main(String args[]){
System.out.println(a);
}
}
Compilation Error
40
0
None of the above
what is the output of this question?
class Test1 {
public
static void main(String[] args)
{
int x = 20;
System.out.println(x);
}
static
{
int x = 10;
System.out.print(x + " ");
}
}
10 20
20 10
10 10
20 20
Which of the following variable is declared as static?
Home address of a particular Student
Account number of a Customer
Company name of all Employees in an Organization
Name of a Employee
What is the output of the following code?
public class Demo
{
public void show(int a)
{
System.out.println(a);
}
public static void main(String[] args)
{
show(20);
}
}
20
No Output Displayed
a constant is passed as argument
Compile Time Error
Output of following Java Program?
10
20
Compilation Error
Run Time Error
Output of following Java Program?
12
321
123
23
What is subclass in java?
A subclass is a class that extends another class
A subclass is a class declared inside a class
Both above.
None of the above.
Output of following Java program?
Base
Derived
Derived
Base
Base
Derived
Base
Derived
Base
Compiler Error
Which of this keyword must be used to inherit a class?
super
this
extent
extends
Which of these is correct way of inheriting class A by class B?
class B + class A {}
class B inherits class A {}
class B extends A {}
class B extends class A {}
A package is a collection of
classes
interfaces
editing tools
classes and interfaces
which package is imported implicitly?
java.applet
java.util
java.lang
java.io
