Home > Java Programming > Quizzes > Java Basics Practice Test: I/O & Applets
Java Basics Practice Test: I/O & Applets
Fast practice, instant feedback. Timer auto-submits when time’s up.
Avg score: 0% Most missed: “What is the length of the application box made the following Java program?”
Quiz on applets fundamentals, static import, basics of I/O, file reading and writing and reading console i/p and writing console o/p.   Java I/O (input/output) is a package that provides classes and interfaces for performing input and output operations. This includes reading and writing files, network communication, and console input and output. Java applets are small applications that can be embedded in web pages and run within a web browser. Applets were once a popular way to add interactivity to web pages, but they have since fallen out of favor due to security concerns. Java I/O and... Show more
Java Basics Practice Test: I/O & Applets
Time left 00:00
25 Questions

1. Which of these functions is called to display the output of an applet?
2. Which of these class is implemented by FilterInputStream class?
3. What will be the output of the following Java program?
class output
{
public static void main(String args[])
{
String a="hello i love java";
System.out.println(indexof('i')+" "+indexof('o')+" "+lastIndexof('i')+" "+lastIndexof('o') ));
}
}
4. What will be the output of the following Java program if input given is “abc’def/’egh”?
class Input_Output
{
public static void main(String args[]) throws IOException
{
char c;
BufferedReader obj = new BufferedReader(new InputStreamReader(System.in));
do
{
c = (char) obj.read();
System.out.print(c);
} while(c!='\'');
}
}
5. Which of these class contains the methods used to write in a file?
6. What is the Message is displayed in the applet made by the following Java program?
import java.awt.*;
import java.applet.*;
public class myapplet extends Applet
{
public void paint(Graphics g)
{
g.drawString("A Simple Applet", 20, 20);
}
}
7. What will be the output of the following Java program?
import java.io.*;
class Chararrayinput
{
public static void main(String[] args)
{
String obj = "abcdefgh";
int length = obj.length();
char c[] = new char[length];
obj.getChars(0, length, c, 0);
CharArrayReader input1 = new CharArrayReader(c);
CharArrayReader input2 = new CharArrayReader(c, 1, 4);
int i;
int j;
try
{
while((i = input1.read()) == (j = input2.read()))
{
System.out.print((char)i);
}
}
catch (IOException e)
{
e.printStackTrace();
}
}
}
8. What will be the output of the following Java program if input given is “abc’def/’egh”?
class Input_Output
{
public static void main(String args[]) throws IOException
{
char c;
BufferedReader obj = new BufferedReader(new InputStreamReader(System.in));
do
{
c = (char) obj.read();
System.out.print(c);
} while(c != '\'');
}
}
9. What is the length of the application box made the following Java program?
import java.awt.*;
import java.applet.*;
public class myapplet extends Applet
{
Graphic g;
g.drawString("A Simple Applet", 20, 20);
}
10. Which of these is used to read a string from the input stream?
11. Which of these classes are used by character streams for input and output operations?
12. What will be the output of the following Java program?
class output
{
public static void main(String args[])
{
StringBuffer c = new StringBuffer("Hello");
StringBuffer c1 = new StringBuffer(" World");
c.append(c1);
System.out.println(c);
}
}
13. Which of these exception is thrown by close() and read() methods?
14. Which of these class is used to read from a file?
15. Which of these classes are used by Byte streams for input and output operation?
16. Which of these class is used to read characters and strings in Java from console?
17. Which of these is a type of stream in Java?
18. What is the length of the application box made by the following Java program?
import java.awt.*;
import java.applet.*;
public class myapplet extends Applet
{
public void paint(Graphics g)
{
g.drawString("A Simple Applet", 20, 20);
}
}
19. Which of these methods is used to write() into a file?
20. Which of these operators can be used to get run time information about an object?
21. Which of these methods can be used to output a string in an applet?
22. Which of these classes are used by character streams output operations?
23. Which of these is used to perform all input & output operations in Java?
24. Which of these modifiers can be used for a variable so that it can be accessed from any thread or parts of a program?
25. What will be the output of the following Java program?
import java.io.*;
class Chararrayinput
{
public static void main(String[] args)
{
String obj = "abcdefgh";
int length = obj.length();
char c[] = new char[length];
obj.getChars(0, length, c, 0);
CharArrayReader input1 = new CharArrayReader(c);
CharArrayReader input2 = new CharArrayReader(c, 1, 4);
int i;
int j;
try
{
while((i = input1.read()) == (j = input2.read()))
{
System.out.print((char)i);
}
}
catch (IOException e)
{
e.printStackTrace();
}
}
}