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 web technology
  1. delimited by single quote

  2. delimited by double quote

  3. delimited by <<< identifier

  4. All of above

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

In PHP, the heredoc syntax defined by &lt;&lt;&lt; followed by an identifier allows string interpolation, meaning variables inside the heredoc block are evaluated. Double quotes also support interpolation, making the option 'All of above' or a more specific answer arguable, but in standard terminology, heredocs are explicitly grouped here.

Multiple choice technology web 2.0
  1. Add a TYPE=HIDDEN INPUT to the form

  2. Trap the return keypress and return (null)

  3. Add 'return false' to onsubmit="..." in the FORM tag

  4. Instruct the user not to press the Return key.

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

Adding 'return false' to the onsubmit handler prevents the form from being submitted when the Return key is pressed, which would otherwise submit the form before the button click. TYPE=HIDDEN doesn't prevent submission, trapping keypress is JavaScript-heavy, and instructing users isn't a technical fix.

Multiple choice technology web 2.0
  1. The statement(s) it executes run(s) only once.

  2. It pauses the script in which it is called.

  3. clearTimeOut() won't stop its execution.

  4. The delay is measured in hundredths of a second.

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

To understand setTimeOut(), the user needs to know how JavaScript functions and the concept of asynchronous programming.

setTimeOut() is a built-in function in JavaScript that allows you to execute a block of code after a specified delay.

Now, let's go through each option and explain why it is right or wrong:

A. The statement(s) it executes run(s) only once. - This option is correct. The block of code passed as the first parameter to setTimeOut() is executed only once after the specified delay. If you want to execute it repeatedly, you can use setInterval().

B. It pauses the script in which it is called. - This option is incorrect. setTimeOut() is an asynchronous function, which means that it does not pause the script. Instead, it schedules the block of code to run after the specified delay and continues executing the rest of the code.

C. clearTimeOut() won't stop its execution. - This option is incorrect. If you want to stop the execution of setTimeOut() before it runs the scheduled block of code, you can use clearTimeout(). This function takes the ID returned by setTimeOut() as a parameter and cancels the execution.

D. The delay is measured in hundredths of a second. - This option is incorrect. The delay is measured in milliseconds, not hundredths of a second. For example, if you want to delay the execution of a block of code for 1 second, you can pass 1000 (1000 milliseconds = 1 second) as the delay parameter to setTimeOut().

Therefore, the correct answer is:

The Answer is: A

Multiple choice technology programming languages
  1. The AutoEventWireup attribute is set to False

  2. The AutomaticPostBack attribute is set to False

  3. The codebehind module is not properly compiled

  4. The ListBox must be defined WithEvents

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

For ListBox SelectedIndexChanged to fire and execute its event handler, AutoPostBack must be set to True. When True, the control automatically posts back to the server on selection change, triggering the event. If False (the default), the selection changes client-side but no postback occurs, so the server-side event handler never runs. AutoEventWireup relates to event binding method, and WithEvents is a VB.NET concept not used here. The answer identifies the correct property, though it misspells it as 'AutomaticPostBack' instead of 'AutoPostBack'.

Multiple choice technology programming languages
  1. The AutoEventWireup attribute is set to False

  2. The AutomaticPostBack attribute is set to False

  3. The codebehind module is not properly compiled

  4. The ListBox must be defined WithEvents

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

In ASP.NET Web Forms, the AutoPostBack property controls whether a control's change event causes an immediate postback to the server. When AutoPostBack is False (the default), the SelectedIndexChanged event only fires during the next form submission, not immediately when the selection changes. Setting AutoPostBack to True enables automatic postback on selection change.

Multiple choice technology architecture
  1. Observer Pattern

  2. Intercepting Filter

  3. Iterator pattern

  4. Value List Iterator pattern

  5. Facade pattern

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

The Value List Iterator (J2EE) pattern is specifically designed for handling large result sets with pagination. It maintains the original query results and allows traversal through chunks (pages) without re-executing the database query, meeting all the stated requirements. Observer is for notifications, Intercepting Filter modifies requests/ responses, Iterator is a basic traversal pattern, and Facade simplifies interfaces.

Multiple choice technology architecture
  1. Looper pattern

  2. Visitor pattern

  3. DataAccess pattern

  4. Iterator pattern

  5. None of the above

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

The Iterator pattern provides a way to access elements of a collection sequentially without exposing its underlying representation. It defines a uniform interface for traversal, whether the collection is an array, list, tree, or any other structure. Looper isn't a standard pattern, Visitor adds operations without changing classes, and DataAccess isn't a GoF pattern.

Multiple choice technology programming languages
  1. Hashtable.

  2. ListDictionary.

  3. Hybrid Dictionary.

  4. NameValueCollection.

  5. StringDictionary.

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

StringDictionary is specifically designed to store name/value pairs where both keys and values are strongly typed as strings. It provides a type-safe string-to-string mapping. Hashtable and ListDictionary are not strongly typed (they store objects), HybridDictionary switches between the two, and NameValueCollection allows multiple values per key.

Multiple choice technology programming languages
  1. A method without code

  2. A method which is called when an event is triggered.

  3. A method which doesnot contain code.

  4. A reference to a method which itself doesnot contain code.

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

A delegate is a reference to a method - it's a type-safe function pointer that holds a reference to a method with a matching signature. The delegate itself doesn't contain implementation code, it merely references a method that does. Option D correctly describes a delegate as a reference to a method, which itself contains the actual code. Options A, B, and C are incorrect descriptions of what delegates represent.

Multiple choice technology programming languages
  1. After serialization is complete

  2. Before deserialization

  3. After Deserialization is complete

  4. To be called explicitly after serialization

  5. To be called explicitly after Deserialization.

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

The IDeserializationCallback.OnDeserialization() method is invoked automatically by the runtime after deserialization of an object is complete. This allows objects to perform any necessary post-deserialization initialization. It is not called during serialization (A), nor must it be called explicitly (D, E). Option B is incorrect because the method fires after deserialization completes, not before it begins.

Multiple choice technology programming languages
  1. Message

  2. StackTrace

  3. Source

  4. Data

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

The StackTrace property contains the execution history of the call stack, which includes the file names and line numbers where an exception originated. Message only describes the exception, Source identifies the assembly, and Data contains custom key-value pairs.

Multiple choice technology programming languages
  1. String start = new String("Welcome to Java Programming");

  2. String start[] = "Welcome to Java Programming";

  3. String start = "Welcome to Java Programming";

  4. none

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

String literals in Java are automatically interned and shared from the string pool. Using new String() creates a separate object. The array syntax in B is incorrect for a single String.