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. Faster performance

  2. Methods are synchronised

  3. Thread-safety

  4. Multithreading

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

StringBuilder is not thread-safe - its methods are NOT synchronized, which eliminates synchronization overhead. StringBuffer is thread-safe with synchronized methods, making it slower. The main advantage of StringBuilder is faster performance in single-threaded environments.

Multiple choice technology web technology
  1. HttpServletRequest

  2. HttpServletResponse

  3. ServletConfig

  4. ServletContext

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

To solve this question, the user needs to know that the getWriter() method returns an object of type PrintWriter, which can be used to generate output. The user must also know which class defines this method.

The getWriter() method is used to return an object of type PrintWriter, which can be used to generate output. This method is defined in the HttpServletResponse class.

Therefore, the correct answer is:

The Answer is: B. HttpServletResponse

Multiple choice technology databases
  1. It loads the Java code into the database.

  2. It publishes Java methods in CardValidation.java

  3. It loads the metadata related to the Java class file into the database.

  4. It loads the Java class file into the Java pool in the database instance.

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

The loadjava utility loads Java source code, class files, and resources into an Oracle database. When given a .java file, it compiles and loads the Java code into the database schema. It does not publish methods (that requires separate publication) nor does it specifically load metadata only into Java pool.

Multiple choice technology
  1. True

  2. False

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

Yes, Java transformation is a valid transformation type in Informatica PowerCenter. It allows developers to write custom transformation logic using Java code, providing flexibility for complex data transformations that might be difficult to achieve using built-in transformations. The Java transformation can include imports, use Java libraries, and implement custom business logic.

Multiple choice technology programming languages
  1. extern

  2. volatile

  3. transient

  4. this

Reveal answer Fill a bubble to check yourself
B,C,D Correct answer
Explanation

Java keywords are reserved words with special meaning. 'volatile' is used for variables in multithreading, 'transient' marks fields not to be serialized, and 'this' refers to the current instance. 'extern' is a C/C++ keyword, not used in Java.

Multiple choice technology programming languages
  1. The member variable called length

  2. The method length() returns the number of characters.

  3. The member variable called size

  4. The method size() returns the number of characters.

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

In Java, String objects use the length() method to return the character count, not a member variable. This is because String is a class - not a primitive or struct - so it encapsulates its data and exposes methods like length() rather than public fields. Option D's size() method doesn't exist for String.

Multiple choice technology web technology
  1. Load ( )

  2. Fill( )

  3. DataList

  4. DataBind

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

The Fill() method is used to populate a DataSet with data from a data source in ADO.NET. It executes the query and retrieves rows into the DataSet. Load() is not a standard DataAdapter method, DataList is a UI control, and DataBind is for web controls.

Multiple choice technology programming languages
  1. RowUpdating, AfterUpdate

  2. BeforeUpdate, RowUpdating

  3. RowUpdating, RowUpdated

  4. BeforeUpdate, AfterUpdate

  5. BeforeUpdate, RowUpdated

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

The DataAdapter in ADO.NET fires two events for each row during database updates: RowUpdating (before the update action) and RowUpdated (after the update completes). These events allow developers to intervene in the update process for validation, logging, or error handling. The prefix 'Row' is consistent for both events.

Multiple choice technology programming languages
  1. Application.Exit();

  2. System.Environment.Exit(0)

  3. System.Environment.Exit(1)

  4. All the above

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

All listed methods can terminate a C# application. Application.Exit() informs all message loops to terminate, which is suitable for Windows Forms. System.Environment.Exit(0) and System.Environment.Exit(1) terminate the process immediately and return exit codes to the operating system, representing success and failure respectively.

Multiple choice technology programming languages
  1. ReadAllLine()

  2. ReadAllBytes()

  3. ReadAllTexts()

  4. WriteAllLine()

  5. WriteAllTexts()

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

In the C# System.IO.File class, ReadAllBytes() is a valid built-in method. The other options are incorrect because they use incorrect naming: the correct framework methods are plural ReadAllLines(), singular ReadAllText(), plural WriteAllLines(), and singular WriteAllText(). C# is case-sensitive and strict about method signatures.

Multiple choice technology testing
  1. Set

  2. Property Object

  3. Count

  4. ChildObjects

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

The ChildObjects method in QTP retrieves all child objects within a parent container that match specified description criteria. It returns a collection of objects that can be iterated through programmatically. Property objects are used for defining descriptions, Set assigns object references, and Count returns the number of items.

Multiple choice technology programming languages
  1. Data

  2. Message

  3. StackTrace

  4. Source

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

The StackTrace property provides a detailed call stack that shows the sequence of method calls that led to the exception, including the exact line numbers where the exception originated. This is precisely what a developer needs to locate the problematic code. The Message property only contains a description of the error, while Data contains arbitrary additional information, and Source indicates the application name - none provide the specific line location like StackTrace does.

Multiple choice technology programming languages
  1. True

  2. False

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

Vector is synchronized, making it thread-safe for multi-threaded environments, whereas ArrayList is not synchronized and therefore not thread-safe. This is a fundamental difference in Java collections, where ArrayList offers better performance when synchronization is not required.