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
  1. Get Count ()

  2. Get Items Count

  3. Items.Count ()

  4. Get Item Count ()

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

In Visual Basic and similar GUI frameworks, the getItemCount() method returns the number of items in a ListBox or similar control. This allows you to programmatically determine how many items are currently in the list.

Multiple choice
  1. Add First ()

  2. Remove Last ()

  3. Remove At ()

  4. Add Last ()

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

Java's LinkedList class has addFirst(), addLast(), and removeLast() methods, but does NOT have a removeAt() method. To remove an element at a specific index, you would use the remove(int index) method instead, not removeAt().

Multiple choice
  1. Insets (int, int, int, int)

  2. Insets (int, int, int)

  3. Insets (int, int)

  4. Insets (int)

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

The Insets class constructor takes four integer parameters (top, left, bottom, right) that specify the padding between a component and the edges of its container. This allows precise control over the spacing and positioning of components within a layout.

Multiple choice
  1. calling

  2. called

  3. main

  4. child

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

Every Java program starts execution with a single thread known as the main thread. This thread is responsible for executing the main() method and serves as the starting point from which other threads can be spawned, making it the foundation of multi-threaded Java applications.

Multiple choice
  1. character

  2. Boolean

  3. Integer

  4. String

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

The drawString() method in Java Graphics class requires a String as its first argument, which specifies the text to be rendered. The subsequent arguments specify the x and y coordinates where the string should be drawn on the graphical context.

Multiple choice
  1. 10

  2. 9

  3. 8

  4. 7

  5. 6

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

There are 8 constructors of SQLTimeoutException class in java. These are: 1.) SQLTimeoutException(): Constructs a SQLTimeoutException object. 2.) SQLTimeoutException(String reason): Constructs a SQLTimeoutException object with a given reason. 3.) SQLTimeoutException(String reason, String SQLState): Constructs a SQLTimeoutException object with a given reason and SQLState. 4.) SQLTimeoutException(String reason, String SQLState, int vendorCode): Constructs a SQLTimeoutException object with a given reason, SQLState and vendorCode. 5.) SQLTimeoutException(String reason, String SQLState, int vendorCode, Throwable cause): Constructs a SQLTimeoutException object with a given reason, SQLState, vendorCode and cause. 6.) SQLTimeoutException(String reason, String SQLState, Throwable cause): Constructs a SQLTimeoutException object with a given reason, SQLState and cause. 7.) SQLTimeoutException(String reason, Throwable cause): Constructs a SQLTimeoutException object with a given reason and cause. 8.) SQLTimeoutException(Throwable cause): Constructs a SQLTimeoutException object with a given cause. So, this is the correct answer.

Multiple choice
  1. addBatch(String sql)

  2. closeOnCompletion()

  3. executeQuery(String sql)

  4. executeBatch()

  5. getResults()

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

There is no method named getResults() in the Statement interface. The correct method name is getMoreResults(), which moves to this Statement object's next result; returns true if it is a ResultSet object and implicitly closes any current ResultSet object(s) obtained with the method getResultSet. So, this answer is true.