Computer Knowledge

Java Core Classes and Threads

1,473 Questions

Java core classes and threads form the foundation of object oriented programming and are crucial for IT officer and programming exams. This includes concepts like string mutability, collections, and multithreading. Solve these questions to test your practical coding and theoretical knowledge.

String and StringBuffer classesThread execution methodsJava collections frameworkCharacter streams input outputVariable serialization rules

Java Core Classes and Threads Questions

Multiple choice
  1. Applets are inserted inside a JVM interpreter when the web page is loaded.

  2. An untrusted applet is bypassed in to sandbox to restrict its behaviour.

  3. A system call is made only when the applet is found trusted by the interpreter.

  4. An applet, which comes from a local disk cannot be trusted.

  5. A security monitor is placed, when the applet is try to access the system resources to check its approval.

Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

This is false statement as a local disk applet is termed as a secure applet.

Multiple choice
  1. u0000

  2. 0

  3. null

  4. 0.0f

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

The default value for char primitive type in Java is '\u0000' (the null character). This is Unicode value 0. Option B (0) is an int, C (null) is only for reference types, and D (0.0f) is for float.

Multiple choice
  1. import java.lang.*;

  2. import java.io.*;

  3. import java.util.*;

  4. import java.awt.*;

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

The Scanner class is in java.util package, which is imported with import java.util.*. Option A incorrectly imports java.lang (auto-imported), Option B imports java.io for I/O operations, and Option D imports java.awt for GUI components. Scanner is specifically a utility class for text parsing.

Multiple choice
  1. Math.random();

  2. getRandom();

  3. setRandom

  4. random();

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

Math.random() is the standard Java method that returns a double between 0.0 and 1.0. Option B (getRandom) doesn't exist in Java API. Option C (setRandom) is not a standard method. Option D (random) alone isn't valid without Math. prefix.

Multiple choice
  1. Java Virtual Machine

  2. Operating System

  3. User

  4. Java Development Environment

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

The JVM performs automatic garbage collection to reclaim memory from objects no longer referenced. This is a key Java feature that prevents memory leaks. The OS manages system memory but doesn't know Java's object graph. Users don't manually trigger GC. The JDE is just a development tool bundle.