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 technology programming languages
  1. Dispose

  2. Close

  3. Finalize

  4. None of the above

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

In VB.NET, the Finalize method is the destructor equivalent called by the garbage collector during object cleanup. Dispose (option A) is for deterministic resource cleanup via the IDisposable pattern. Close (option B) is typically for closing resources like files/connections but not the destructor.

Multiple choice technology programming languages
  1. ExecuteNonQuery & ExecuteScalar

  2. ExecuteQuery & ExecuteScalar

  3. ExecuteParameter

  4. None of the above

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

The Command object in ADO.NET has ExecuteNonQuery for INSERT/UPDATE/DELETE (returns affected rows), ExecuteScalar for single value queries, and ExecuteReader for multiple rows. ExecuteQuery and ExecuteParameter are not valid methods.

Multiple choice technology
  1. Java automatically works both within a web page and stand-alone.

  2. You have to write separate pieces of Java if you want to run them in both a web page and stand-alone, although many

  3. If you're careful, the same piece of Java can be used both as a stand-alone program and within a web page.

  4. You run your Java first in a web page. A button then lets you save a local copy which you can run stand-alone

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

Java's 'write once, run anywhere' design allows the same code to run as standalone application or applet if designed properly without platform-specific dependencies.

Multiple choice technology
  1. To maintain multiple contexts

  2. To allow a Java program to do several things at the same time

  3. Only to hold the seams in the programmer's trousers.

  4. As a debugging tool to allow the programmer to trace back once a Java program has completed its operation

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

Threads enable concurrent execution - a Java program can perform multiple tasks simultaneously like handling UI while processing data in background.

Multiple choice technology
  1. A Unix or Linux workstation which (in practice) would have a permanent link to the internet.

  2. The applet in .class format

  3. A licensed copy of the Java Development Kit, which comes with the appropriate rights for any programs you create

  4. A Java-enabled web server

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

Java applets are distributed as compiled .class files (bytecode) that browsers download and execute via JVM. Source code or JDK license is not required for users.

Multiple choice technology programming languages
  1. gets

  2. getstring

  3. Both A and B

  4. None of the Above

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

The gets() function in C reads a single line from stdin into a char array until a newline. Note that gets() is deprecated and dangerous because it doesn't check buffer boundaries, leading to buffer overflows. Use fgets() instead in production code. There is no standard C function called getstring().

Multiple choice technology testing
  1. Import Table

  2. SheetImport

  3. ImportSheet

  4. ImportDataTable

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

The ImportSheet method in QTP's DataTable object imports a sheet from an external Excel file into the runtime Data Table. The syntax is DataTable.ImportSheet(filename, sheetSource, sheetDest). ImportTable and SheetImport are not valid methods.

Multiple choice technology testing
  1. GetCellData(Row ,Col)

  2. GetData(Row,Col)

  3. GetRowValue(Roeid,Colname)

  4. None of the Above

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

The GetCellData(Row, Col) method retrieves data from a specific cell in an HTML Table object in QTP. You pass row and column indices as parameters. GetData and GetRowValue are not standard QTP table methods.

Multiple choice technology testing
  1. SetROProperty

  2. GetROProperty

  3. GetTOProperty

  4. GetVisibleText

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

GetROProperty retrieves the actual runtime property value of an object during test execution, reflecting the current state of the application. This differs from GetTOProperty which fetches property values from the Object Repository (test object definition), not the live application. SetROProperty is incorrect as it doesn't exist: RO properties are read-only runtime values.

Multiple choice technology programming languages
  1. public void run()

  2. public void start()

  3. public void exit()

  4. public final void setAccess()

  5. public final void setPriority(int priNbr)

  6. public final int getPriority()

Reveal answer Fill a bubble to check yourself
A,B,E,F Correct answer
Explanation

The methods run(), start(), setPriority(int), and getPriority() are standard methods defined in the java.lang.Thread class used to manage thread execution and priorities. Methods exit() and setAccess() do not exist in the Thread class, making them incorrect.

Multiple choice technology databases
  1. Open

  2. Begin Transaction

  3. Execute

  4. Commit Transaction

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

In ADO.NET, the DbConnection class (such as SqlConnection or OleDbConnection used in VB.NET) features methods like Open(), BeginTransaction(), and Close(). The Execute() method does not belong to the Connection object; execution is instead handled by a Command object (SqlCommand.ExecuteNonQuery, etc.). Note that Commit is on the transaction object, but Execute is definitely not on the connection.