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 platforms and products
  1. True

  2. False

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

Sensors in Android are NOT uniquely identified by integer IDs. They are identified by sensor type constants (like Sensor.TYPE_ACCELEROMETER) and an integer handle that can vary between devices. Multiple sensors of the same type exist, requiring additional identification beyond a simple unique integer ID.

Multiple choice technology mainframe
  1. Operational exception

  2. Address exception

  3. Data exception

  4. Numeric exception

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

When an arithmetic operation is attempted on non-numeric data (like trying to do math on a text field or alphabetic character), it causes a 'Data Exception' (decimal data exception or 0Cx exception in IBM mainframe terminology). Operational exceptions relate to program interrupts, Address exceptions to invalid memory access.

Multiple choice technology web technology
  1. Method with ActionResult keyword

  2. All methods

  3. All methods except non-public methods

  4. All of the above

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

By default, the controller treats all public methods as potential action methods. Non-public methods (private, protected) are not considered actions. Special attributes like [NonAction] can also exclude public methods from being actions.

Multiple choice technology web technology
  1. [Private]

  2. [NonAction]

  3. [Internal]

  4. [Protected]

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

The [NonAction] attribute prevents a public method in a controller from being invoked by a URL request, even though it's public. [Private] and [Protected] are access modifiers for class members, not MVC-specific attributes. [Internal] limits visibility to the assembly but doesn't prevent URL routing.

Multiple choice technology programming languages
  1. Exec

  2. Execute

  3. CacheMetadata

  4. beginExec

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

In custom activities derived from CodeActivity, the Execute method contains the execution logic. This is where you implement the activity's primary behavior. For NativeActivity, you override Execute differently, and CacheMetadata is for runtime metadata registration, not execution logic. Exec and beginExec are not valid WF4.0 method names.

Multiple choice technology programming languages
  1. Using InArgument Name

  2. Using context.GetValue(InArgumentName)

  3. InArgumentName.Get(context)

  4. InArgument.Get()

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

To access InArgument values within a custom activity's Execute method in WF 4.0, you have two correct approaches: either use context.GetValue(inArgument) or call inArgument.Get(context). Both methods require the ActivityContext parameter to resolve the argument's value at runtime. Simply referencing the argument by name or calling Get() without context will not work.

Multiple choice technology web technology
  1. ExecuteDataSet()

  2. ExecuteScalar()

  3. ExecuteReader()

  4. ExecuteNonQuery()

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

ExecuteNonQuery is specifically designed for SQL commands that don't return row data - INSERT, UPDATE, DELETE, DDL statements. It returns only the count of affected rows. ExecuteReader returns rows, ExecuteScalar returns a single value, ExecuteDataSet returns a DataSet.

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 onUnload event fires when a document is unloaded from the browser window. This occurs in three scenarios: when the browser window closes, when the page reloads (including refresh), and when the user navigates away from the page (clicking links, back/forward buttons). Therefore, all listed conditions are correct.

Multiple choice technology programming languages
  1. session.contains() method to determine if an instance belongs to the session cache.

  2. session.contains() method to determine if an instance belongs to the data base

  3. Both are correct

  4. none of the above

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

In Hibernate, the session.contains() method checks whether a given instance is present in the first-level cache (session cache), not whether it exists in the database. To check database existence, you would use a query or get() method. The statement correctly identifies this.

Multiple choice technology programming languages
  1. Remove the object and its collections from the first level cache

  2. Remove the object and its collections from the second level cache

  3. Remove the object and its collections from the data base

  4. None of the above

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

The session.evict() method removes a specified object and its associated collections from the first-level cache (session cache). This is useful when you want to detach an object from the session without closing it. It does NOT remove from the second-level cache (that's a different concept) or from the database (that would be a delete operation).

Multiple choice technology programming languages
  1. ListResultSet

  2. ResultSet

  3. ScrollableResultSet

  4. ScrollableResult

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

The session.createQuery("Query").scroll() method returns a ScrollableResult, which allows you to scroll through query results both forward and backward. This is different from scroll() on a Criteria query which returns ScrollableResults. Note the singular 'Result' versus 'Results'.

Multiple choice technology programming languages
  1. Refresh();

  2. Flush();

  3. Fetch();

  4. Load()

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

The refresh() method re-loads an object and all its collections from the database, overwriting any changes made in memory. This is particularly useful when database triggers initialize or modify properties after a save operation. It ensures your in-memory object reflects the actual database state.

Multiple choice technology programming languages
  1. Refresh();

  2. Flush();

  3. Fetch();

  4. Load()

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

The refresh() method re-loads an object and all its collections from the database, overwriting any changes made in memory. This is particularly useful when database triggers initialize or modify properties after a save operation. It ensures your in-memory object reflects the actual database state.

Multiple choice technology
  1. execute(), exit()

  2. execute(), setProperties()

  3. execute(), setParameter()

  4. exit(), systemProperties()

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

The StreamTransformation interface requires two mandatory methods: execute() contains the main transformation logic (input to output), and setParameter() receives runtime configuration from the XI pipeline. Options A, B, and D incorrectly include exit() or systemProperties(), which are not part of the interface.