Home > Java Programming > Quizzes > Java Basics Practice Test: java.lang & java.io
Java Basics Practice Test: java.lang & java.io
Fast practice, instant feedback. Timer auto-submits when time’s up.
Avg score: 0% Most missed: “Which of the following exceptions is thrown by every method of Runtime class?”
java quiz on various concepts of java.lang, including data types, types of classes, character and byte streams, builtin exceptions, rounding functions, system class, byte, short, double and float wrappers, character and boolean wrappers and environment properties. Java.lang and java.io are two of the most important packages in the Java programming language. Here's a summary of what each of them contains and the differences between them. java.lang Contains classes and interfaces that are fundamental to the design of the Java programming language. Includes classes such as Object, String,... Show more
Java Basics Practice Test: java.lang & java.io
Time left 00:00
25 Questions

1. What will be the output of the following Java program?
class Output
{
public static void main(String args[])
{
char a[] = {'a', '5', 'A', ' '};
System.out.print(Character.isDigit(a[0]) + " ");
System.out.print(Character.isWhitespace(a[3]) + " ");
System.out.print(Character.isUpperCase(a[2]));
}
}
2. Which of these methods of Byte wrapper can be used to obtain Byte object from a string?
3. What will be the output of the following Java program?
class Output
{
public static void main(String args[])
{
double x = 3.14;
int y = (int) Math.toRadians(x);
System.out.print(y);
}
}
4. What will be the output of the following Java program?
import java.io.*;
public class filesinputoutput
{
public static void main(String[] args)
{
String obj = "abc";
byte b[] = obj.getBytes();
ByteArrayInputStream obj1 = new ByteArrayInputStream(b);
for (int i = 0; i < 2; ++ i)
{
int c;
while ((c = obj1.read()) != -1)
{
if(i == 0)
{
System.out.print((char)c);
}
}
}
}
}
5. What will be the output of the following Java code?
class Output
{
public static void main(String args[])
{
Double i = new Double(257.5);
boolean x = i.isNaN();
System.out.print(x);
}
}
6. What will be the output of the following Java program?
class Output
{
public static void main(String args[])
{
Double i = new Double(257.5);
Double x = i.MIN_VALUE;
System.out.print(x);
}
}
7. What will be the output of the following Java program?
class newthread implements Runnable
{
Thread t1,t2;
newthread()
{
t1 = new Thread(this,"Thread_1");
t2 = new Thread(this,"Thread_2");
t1.start();
t2.start();
}
public void run()
{
t2.setPriority(Thread.MAX_PRIORITY);
System.out.print(t1.equals(t2));
}
}
class multithreaded_programing
{
public static void main(String args[])
{
new newthread();
}
}
8. Which of these method of Double wrapper can be used to check whether a given value is infinite or not?
9. Which of these classes is used for input and output operation when working with bytes?
10. What will be the output of the following Java program?
class Output
{
public static void main(String args[])
{
int a = Character.MAX_VALUE;
System.out.print((char)a);
}
}
11. What will be the output of the following Java program?
class Output
{
public static void main(String args[])
{
Integer i = new Integer(257);
byte x = i.byteValue();
System.out.print(x);
}
}
12. Which of these methods is used to check for infinitely large and small values?
13. Standard output variable ‘out’ is defined in which class?
14. Which class loader loads jar files from JDK directory?
15. What will be the output of the following Java program?
class Output
{
public static void main(String args[])
{
double x = 102;
double y = 5;
double z = Math.IEEEremainder(x, y);
System.out.print(z);}
}
}
16. Which of these method is a rounding function of Math class?
17. Which of these methods can be used to check whether the given value is a number or not?
18. Which of these methods is not defined in both Byte and Short wrappers?
19. What will be the output of the following Java program?
class exception_handling
{
public static void main(String args[])
{
try
{
int a = 1;
int b = 10 / a;
try
{
if (a == 1)
a = a / a - a;
if (a == 2)
{
int c[] = {1};
c[8] = 9;
}
finally
{
System.out.print("A");
}
 
}
catch (NullPointerException e)
{
System.out.println("B");
}
}
}
20. Which of the following constant are defined in Character wrapper?
21. Does code Segment loads the java code?
22. What will be the output of the following Java program?
import java.io.*;
public class filesinputoutput
{
public static void main(String[] args)
{
String obj = "abc";
byte b[] = obj.getBytes();
ByteArrayInputStream obj1 = new ByteArrayInputStream(b);
for (int i = 0; i < 2; ++ i)
{
int c;
while ((c = obj1.read()) != -1)
{
if (i == 0)
{
System.out.print(Character.toUpperCase((char)c));
obj2.write(1);
}
}
System.out.print(obj2);
}
}
}
23. Will this Java program generate same output is executed again?
class Output
{
public static void main(String args[])
{
int y = double z = Math.random();
System.out.print(y);
}
}
24. Which of the following method of Process class can terminate a process?
25. Which of the following exceptions is thrown by every method of Runtime class?