Font size
WorksheetsJava Advance review
Total questions: 109
Worksheet time: 1hrs 11mins
which one this keywords are used to create a class in java
class
struct
int
none of the avove
which of this class is used by character streams for reading data from buffer
BufferReader
InputStreamReader
FileReader
FileInputStream
superclass of all classes representing the output stream of characters is -------------
OutputStream
Reader
InputStream
Writer
which interface needs to be implemented in order to make an object seralized
clonnable
remote
seralizable
none of the above
Which one of the following statement is not true about the collection interface?
all methods defined in set interface are also defined in collection interface
list interface extends collection interface
set interface extends collection interface
all methods defined in list interface are also defined in collection interface
which one of the following is true?
runnable interface declares the start method
Thread.start() method is used to move a thread from a new state to the runnable state
Thread.runnable() method is used to move a thread from new state to the runnable state
Thread.run() method is used to move a thread from new state to the runnable state
which one of the following have elements in insertion order
sorted map
hashmap
linkedhashmap
treemap
How would you declare a variable storing a person's name?
string name = "Elroy";
name String = "Elroy";
String name = Elroy;
String name = "Elroy";
Me llamo Elroy
List all parameters that exist in this program segment:-
double point, String student
point, student
name, mark
name[i], mark[i]
What is the first index of an array?
1
0
2
3
For the array:
int stats[3];
What is the range of the index?
0 to 3
0 to 2
1 to 3
0 to 4
int [] nums = {2, 3, 5, 8, 9, 11};
How would you access the fourth element in nums?
nums[4]
nums[3]
nums(4)
nums(3)
a = {0, 2, 3, 4} and v = 1?
Find the output
class Test {
public static void main(String args[]) {
int arr[2];
System.out.println(arr[0]);
System.out.println(arr[1]);
}
}
Compile error
Exception
Garbage Value
Garbage Value
0
0
Is String a primitive data type?
Yes
No
Both
What is the list nums if it is initially [5, 3, 1] and the following code is executed?
nums.add(6);
nums.add(0, 4);
nums.remove(1);
[4, 3, 1, 6]
[5, 3, 1, 6]
[4, 3, 6]
[4, 5, 3, 6]
What index value is used to locate the last element in the nums ArrayList?
nums.size()-1
nums.length()-1
nums.size()
nums.length
Which statement below is the correct way to retrieve the first element in the nums ArrayList?
nums.get(0)
nums[0]
nums(0)
nums[1]
How many ways a thread can be created in Java multithreading?
1
2
5
10
Which method is used to make main thread to wait for all child threads
Join ()
Sleep ()
Wait ()
Stop ()
Which will contain the body of the thread in Java?
Start()
Run()
Main()
Execute()
The life cycle of a thread in java is controlled by
JRE
JDK
JVM
None
Which method is used to get current running thread object?
runningThread()
currentThread()
runnableThread()
None
Synchronized static methods acquire lock on
Class
Object
Interface
None
Thread priority in Java is?
Integer
Float
Double
Long
In JAVA multi threading, a thread can be created by_______
Extending class
Implementing Runnable Interface
both
none
Which statements is/are correct
On calling Thread start ( ) method a new thread is created
Thread start( ) method call run( ) method internally
Thread run( ) method can also be called directly to create thread
both a & b
Q) What is maximum thread priority in Java
10
12
5
8
Q) Execution of a java thread begins on which method call?
Start ()
Run ()
Execute ()
Launch ()
What is the advantage of Exception Handling
To avoid abnormal termination of a program
To find out errors
To Debug program
None of these
What is the parent class of All Exceptions in JAVA
Throw
Exception
Error
Bug
Which of the following key word is optional in Exception handling program
try
catch
finally
throw
try block may or may not contains catch blocks
True
False
What is the purpose of 'throw' keyword
To Raise an exception explicityly
To Raise an exception implicityly
To create user defined exceptions
To create custom exceptions
How to create our own exception
using 'throw' keyword
using 'throws' keyword
using 'finally' keyword
using 'throwable' keyword
Exception classes belongs to following package
import java.io.*
import java.lang.*
import java.util.*
import java.lang.Exception.*
Composition is a
uses-a relationship
has-a relationship
is-a relationship
none of the above
What is not a Java primitive data type?
float
byte
Boolean
char
Select the access level/s of a private modifier.
Class
Package
Subclass
World
It keeps the data and the code safe from external interference.
Polymorphism
ArrayList
Autoboxing
Encapsulation
Which data type is not supported by ArrayList?
Integer
String
double
Boolean
What is an instance of a class?
Class
Object
Reference
Primitive
What is the default value of a primitive int data type?
-1
null
0
garbage data
Consider the given code. What would be the display on the screen?
Class A
Class B
Class C
Compile error
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 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.
Which of this keyword must be used to inherit a class?
super
this
extent
extends
A package is a collection of
classes
interfaces
editing tools
classes and interfaces
Attributes of an object are also known as
methods
properties
classes
functions
Polymorphism related to :
PPO
Class
OPP
OOP
Which from the following is a feature that allows us to perform a single action in different ways.
Abstraction
Polymorphism
Encapsulation
Inheritance
The process by which objects of one class acquire the properties of objects of another class is known as
Polymorphism
Inheritance
Data Hiding
Association
Hiding complexity can also be termed as
Inheritance
Overloading
Data hiding
Abstraction
Which one is NOT the basic element of OOP?
Class
Abstraction
BlueJ
Polymorphism
Which of the following is the complete syntax of creating a class?
public class Main { }
public class Main() { }
public class Main
public class Main()
Which of the following creates an object of Main class?
Main obj = new Main;
Main obj = new Main();
Main obj = new Mian();
Main obj == new Main();
Another term for variable within a class
(a)
Methods are declared within a class.
True
False
static void myMethod(){ }
What is the name of the method?
static void myMethod
void myMethod
static myMethod
myMethod
Which of the following statements is invalid?
Tutor jimmy = new CSTutor();
CSTutor sally = new JavaTutor();
Tutor suzie = new JavaTutor();
Tutor johnny = new Tutor();
Identify the type of error that exists in this method program.
Logic error
runtime error
syntax error
Value error
Class
def class Test(){}
public class Circle{}
public class Circle(){}
public class circle{}
Extends
Adds libraries to your project
Extends the life of your variable when the program closes
Inheritance to a parent object
Polymorphism
The following Syntax is used for?
class Subclass-name extends Superclass-name
{
//methods and fields
}
Polymorphism
Encapsulation
Inheritance
None of the above
A class that is inherited is called a ______ .
superclass
Subclass
subsetclass
Relativeclass
which are the features of Java?
main
Inheritance
Polymorphism
Data Hiding
which one of the following is a legal decelration of a two- dimensional array of integers
int[] a[] = new int[5][];
int[5][5] a = new int[][];
int a = new int[5,5];
int[][] a = new int[][5];
which one this keywords are used to create a class in java
class
struct
int
none of the avove
Describe method.
A component of a program in a big program.
A program to perform a specific task.
A component of a program written to perform a specific task.
A variable that use to read an input.
This is a general structure a method.
<Returnvalue type> <Method Name> (argument / s)
<Modifier> < type> <Method Name> (parameter / s)
public static void main (String[ ] args)
<Method Name> (parameter)
The different between static and non static method is ....
for non static method : user need to create object in a class to call a method.
A method is to perform only specific task.
There is no significant differences between static and non - static method.
Both are bounded with a class.
Data type for non return method is
int
double
void
public static
Which statement(s) are equivalent to i = i + 1?
i += 1
i++
i -= 1
i--
Which of the following is FALSE about arrays on Java
A java array is always an object
Length of array can be changed after creation of array
Arrays in Java are always allocated on heap
What is the length of the following array: byte[] data = { 12, 34, 9, 0, -62, 88 };
1
5
6
12
class Demo1
{
public static void main(String args[])
{
int i[] = new int[10];
System.out.println(i[10]);
}
}
0
Garbage Value
Out-of-bounds exception
Error
Which method would you use to check if two Strings are exactly the same?
equals()
equalsIgnoreCase()
toUpperCase()
toLowerCase()
Which method was used to convert this String: "IT learners are clever" to "IT LEARNERS ARE CLEVER" ?
toUpperCase()
toLowerCase()
equalsIgnoreCase()
compareTo()
Which method was used to convert this String: "Life is TOO SHORT to be BORED" to: "life is too short to be bored" ?
toLowerCase()
toUpperCase()
equals()
equalsIgnoreCase()
