Computer Knowledge

Java Core Classes and Threads

1,935 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 technology programming languages
  1. To provide access to the Java runtime system.

  2. To avoid run time exception.

  3. To provide the capability to execute code no matter whether or not an exception is thrown or caught.

  4. Both 2 & 3

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

The Runtime class in Java provides access to the Java runtime environment. It allows applications to interface with the environment in which they are running. Common uses include executing system commands (exec), forcing garbage collection (gc), getting free memory (freeMemory), and terminating the JVM (exit). It does not handle exceptions or provide finally-like behavior.

Multiple choice technology programming languages
  1. all sub-classes of Throwable

  2. not the sub classes of RuntimeException

  3. all sub-classes of Error

  4. None of these

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

Checked exceptions are exceptions that must be either caught or declared in a throws clause. They are all subclasses of Throwable EXCEPT RuntimeException and its subclasses (unchecked exceptions) and Error and its subclasses (system errors). So checked exceptions are 'not the subclasses of RuntimeException' (and also not Error subclasses).

Multiple choice technology testing
  1. Random input parameter

  2. Sequence inputs

  3. Boundary value conditions.

  4. Data points

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

Boundary value analysis is a fundamental testing technique that systematically tests parameters at their limits and edges. For API testing, this means testing minimum values, maximum values, values just beyond boundaries, and edge cases. Random inputs and sequences don't provide systematic coverage, and 'data points' is too vague.

Multiple choice technology programming languages
  1. the heap space occupied by an un-referenced object can be recycled and made available for subsequent new objects

  2. When the total memory allocated to a Java program exceeds some threshold the garbage coollector is invoked

  3. the program does not suspend during garbage collection

  4. garbage collection requires extra memory

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

Java garbage collection typically suspends all application threads during the collection phase, causing 'stop-the-world' pauses. This is necessary to safely identify and reclaim unreachable objects without concurrent modifications.

Multiple choice technology programming languages
  1. When browser is closed

  2. When the page reloads as well.

  3. Only when you navigate out of the page.

  4. All Of the Above

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

The unload event triggers when the document is being unloaded. This occurs under all specified scenarios: closing the browser or tab, reloading the current page, or navigating to a different URL. Thus, 'All Of the Above' is correct.

Multiple choice technology programming languages
  1. FaultException

  2. RESTException

  3. WebFaultException

  4. WebHttpFaultException

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

WebFaultException is the specific exception type for WCF RESTful services (WebHttpBinding). It allows returning HTTP status codes along with fault information. FaultException is for SOAP services. RESTException and WebHttpFaultException do not exist in WCF.

Multiple choice technology programming languages
  1. Dispose

  2. Close

  3. Finalize

  4. None of the above

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

In VB.NET, the Finalize method is the destructor equivalent called by the garbage collector during object cleanup. Dispose (option A) is for deterministic resource cleanup via the IDisposable pattern. Close (option B) is typically for closing resources like files/connections but not the destructor.

Multiple choice technology programming languages
  1. ExecuteNonQuery & ExecuteScalar

  2. ExecuteQuery & ExecuteScalar

  3. ExecuteParameter

  4. None of the above

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

The Command object in ADO.NET has ExecuteNonQuery for INSERT/UPDATE/DELETE (returns affected rows), ExecuteScalar for single value queries, and ExecuteReader for multiple rows. ExecuteQuery and ExecuteParameter are not valid methods.

Multiple choice technology
  1. To maintain multiple contexts

  2. To allow a Java program to do several things at the same time

  3. Only to hold the seams in the programmer's trousers.

  4. As a debugging tool to allow the programmer to trace back once a Java program has completed its operation

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

Threads enable concurrent execution - a Java program can perform multiple tasks simultaneously like handling UI while processing data in background.

Multiple choice technology programming languages
  1. gets

  2. getstring

  3. Both A and B

  4. None of the Above

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

The gets() function in C reads a single line from stdin into a char array until a newline. Note that gets() is deprecated and dangerous because it doesn't check buffer boundaries, leading to buffer overflows. Use fgets() instead in production code. There is no standard C function called getstring().