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. SortedList

  2. ArrayList

  3. ListDictionary

  4. HashTable

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

HashTable is the .NET collection class designed specifically for storing and retrieving elements using unique key-value pairs. Unlike ArrayList which uses integer indices, HashTable allows you to access any value directly by its unique key, providing fast lookups through hashing. SortedList also supports key access but maintains sorted order, while ListDictionary is optimized for small collections.

Multiple choice technology web technology
  1. service() method is invoked by the container once per request.

  2. service() method can be invoked only once.

  3. init() is invoked by the container only once per request.

  4. init() is invoked by the container only once per instance.

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

In the servlet lifecycle, the service() method is invoked by the container for each incoming request, making it responsible for request processing. The init() method is called only once per servlet instance when it's first loaded, not for each request. This lifecycle design ensures efficient resource management - initialization happens once, while request handling can occur many times concurrently.

Multiple choice technology web technology
  1. Sets all properties to null values

  2. b. Sets all properties to their default values

  3. c. Repopulates the properties with their original values from request parameter

  4. d. None of the above

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

The default Reset method in Struts ActionForm does not set properties to null or default values. Instead, it resets the form to its initial state by repopulating properties with original values from the request parameters. However, this description is not exactly what the default reset() does - the default reset() method is actually empty and does nothing. Options B and C have formatting issues with 'b.' and 'c.' prefixes, making 'None of the above' the best choice.

Multiple choice technology mainframe
  1. To creates object instances of a COBOL or Java class or invokes a method defined in a COBOL or Java class

  2. To creates object instances of a COBOL or ORACLE class or invokes a method defined in a COBOL or ORACLE class

  3. To creates object instances of a COBOL or UNIX class or invokes a method defined in a COBOL or UNIX class

  4. Invalid Syntax

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

The INVOKE statement in COBOL is used to create object instances of COBOL or Java classes and to invoke methods defined in those classes. It's part of COBOL's object-oriented extensions that enable interoperability with Java and COBOL objects.

Multiple choice technology web technology
  1. Object Oriented

  2. Write Once, Run Anywhere

  3. Compiled Programming language

  4. None of the above

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

While Java is object-oriented, its defining characteristic is 'Write Once, Run Anywhere' - the ability to compile to bytecode that runs on any platform with a JVM. This portability across different operating systems and hardware is Java's core advantage. Java is also compiled (to bytecode) but WORA is more distinctive.

Multiple choice technology programming languages
  1. True

  2. False

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

Java features automatic garbage collection for memory management. The JVM automatically reclaims memory from objects that are no longer reachable, handling the entire object lifecycle from allocation to deallocation. This eliminates manual memory management and common memory leaks.

Multiple choice technology programming languages
  1. a class that initializes the applet

  2. A required method in an applet

  3. A place to declare variablesA place to declare variables

  4. none of the above

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

To understand the purpose of this bit of code, the user needs to know that this is a method definition in Java. The method name "init" suggests that this code is related to initializing something, but more context is needed to determine what that something is.

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

A. A class that initializes the applet: This option is incorrect because this code does not define a class. It defines a method called "init". While this method may be used to initialize an applet, it is not itself a class.

B. A required method in an applet: This option is correct. In Java, "init" is a required method in applets. This method is called by the Java Virtual Machine (JVM) when the applet starts. It is used to perform any necessary initialization before the applet can be displayed.

C. A place to declare variables: This option is incorrect because this code does not declare any variables. It defines a method, which may use variables, but it does not itself declare any.

D. None of the above: This option is incorrect because option B is correct. "init" is a required method in applets.

Therefore, the answer is: B

Multiple choice technology testing
  1. GetVisibleText

  2. GetROProperty

  3. SetROProperty

  4. GetTOProperty

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

GetROProperty (Get Run-Time Object Property) in QTP/UFT retrieves the current property value of an object during test execution. This differs from GetTOProperty which retrieves test object properties from the Object Repository. RO properties reflect the actual state of the application at runtime.