NEW
Font size
WorksheetsWeek 2 Quiz
Total questions: 20
Worksheet time: 40mins
Which method when implemented must return true while there are still more elements to extract, and false when all the elements have been enumerated?
Object nextElement( )
boolean hasMoreElements( )
Both A & B
None of the above
Consider the following two statements
int x = 25;
Integer y = new Integer(33);
What is the difference between these two statements?
Primitive data types
primitive data type and an object of a wrapper class
Wrapper class
None of the above
Which allows the caller to remove elements from the underlying collection during the iteration with well-defined semantics?
Enumeration
Iterator
None of the above
Filtered streams are simply wrappers around underlying input or output streams that transparently provide some extended level of functionality.
True
False
Where are the primitive data type values stored?
Heap Memory
Stack Memory
Both A & B
None of the above
What will be the output of the following Java code?
import java.util.*;
public class genericstack <E>
{
Stack <E> stk = new Stack <E>();
public void push(E obj)
{
stk.push(obj);
}
public E pop()
{
E obj = stk.pop();
return obj;
}
}
class Output
{
public static void main(String args[])
{
genericstack <String> gs = new genericstack<String>();
gs.push("Hello");
System.out.println(gs.pop());
}
}
H
Hello
Runtime Error
Compilation Error
Which of these Exception handlers cannot be parameterized?
catch
throw
throws
all of the mentioned
What will be the output of the following Java program?
import java.util.*;
public class genericstack <E>
{
Stack <E> stk = new Stack <E>();
public void push(E obj)
{
stk.push(obj);
}
public E pop()
{
E obj = stk.pop();
return obj;
}
}
class Output
{
public static void main(String args[])
{
genericstack <Integer> gs = new genericstack<Integer>();
gs.push(36);
System.out.println(gs.pop());
}
}
H
Hello
Runtime Error
Compilation Error
Which of these packages contain all the collection classes?
java.lang
java.util
java.net
java.awt
What will be the output of the following Java program?
import java.util.*;
class Bitset
{
public static void main(String args[])
{
BitSet obj = new BitSet(5);
for (int i = 0; i < 5; ++i)
obj.set(i);
obj.clear(2);
System.out.print(obj);
}
}
{0, 1, 3, 4}
{0, 1, 2, 4}
{0, 1, 2, 3, 4}
{0, 0, 0, 3, 4}
Which of the these exceptions is thrown in the case when file in which you want to write is not found:-
IOException
FileNotFoundException
FileException
None of the above
What value is returned by the read() method when it encounters EOF:-
Null
-1
0
1
Which of the following classes allow us to write the file:-
FileStream
ByteStream
FileInputStream
FileBufferStream
What will be the output of the following code:-
import java.io.*;
class files
{
public static void main(String args[])
{
File obj = new File(""/java/spring"");
System.out.print(obj.getName());
}
}
spring
/java/spring
java
None of the above
In java how many streams are there by default?
1
2
3
4
Which of the following is a type of stream available in Java:-
Integer Stream
Float Stream
Double Stream
Byte Stream
Which of the following classes contains print and println method:-
PrintStream
System.out
BufferedOutputStream
System
Which of the following can be used to write in console:-
println()
write()
print()
All of the following
Which of the following is not a member of java.io:
StringReader
String
File
Writer
Which method returns true when called on a file and false when called on a directory?
IsFile()
isFile()
isfile()
Isfile()
