Computer Knowledge

Java Core Classes and Threads

1,473 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. Start()

  2. Thread(…)

  3. Run()

  4. Both (1) and (3)

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

In Java and Android threading, calling the start() method of a Thread class tells the system to initiate a new thread of execution, creating a separate background process or thread path. The run() method merely executes code in the current thread.

Multiple choice
  1. It is used for concurrency issue in the application.

  2. It makes sure that no race condition in the application code.

  3. This technique does not maintain the thread safety in the application.

  4. This technique allows the developer to delay the instantiation of the object until it is first called upon.

  5. Both (1) and (3).

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

These are the correct statements.

Multiple choice
  1. switch(exp) { case value1: statement_1; case value2: statement_2; …………………… case valuen: statement_n; [default: statements ;] }

  2. switch(exp) { case value1: statement_1; case value2: statement_2; …………………… case valuen: statement_n; default: statements ; }

  3. switch(exp) { case value1: statement_1; case value2: statement_2; …………………… case valuen: statement_n; }

  4. switch(exp) { case value1; statement_1; case value2; statement_2; …………………… case valuen; statement_n; [default: statements ;] }

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

The correct syntax is as follows: switch(exp) { case value1: statement_1; case value2: statement_2; …………………… case valuen: statement_n; [default: statements ;] } The default statement is optional.