Docsity

Java Certification Practice Exam Q&A, Exams of Java Programming

Toggle sidebar
bg1
Texas Java Developer Certification
Practice Exam Questions And Correct
Answers (Verified Answers) Plus
Rationales 2025|2026 Q&A | Instant
Download Pdf
1. What is the default value of a local variable in Java?
null
0
No default value
false
Local variables must be initialized before use, or the compiler will
throw an error. They do not have a default value.
2. Which keyword is used to inherit a class in Java?
extends
implements
inherit
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e

Partial preview of the text

Download Java Certification Practice Exam Q&A and more Exams Java Programming in PDF only on Docsity!

Texas Java Developer Certification

Practice Exam Questions And Correct

Answers (Verified Answers) Plus

Rationales 2025|2026 Q&A | Instant

Download Pdf

  1. What is the default value of a local variable in Java?  null  0  No default value  false Local variables must be initialized before use, or the compiler will throw an error. They do not have a default value.
  2. Which keyword is used to inherit a class in Java?  extends  implements

 inherit

 super The extends keyword is used for class inheritance.

  1. What is the output of System.out.println(10 + 20 + "30");?

 "102030"

 "3030"

 "30"

"3030" Java adds integers first (10 + 20 = 30), then concatenates the string "30", resulting in "3030".

  1. Which access modifier makes a member visible only within its own package and subclass?

 private

 public

protected

 default The protected modifier allows access within the same package and subclasses, even if they are in different packages.

  1. Which of the following is a wrapper class for primitive type int?

 Int

 integer

 Number

 ObjectClass

 JavaObject

Object

 Base The Object class is the root of the class hierarchy in Java.

  1. Which keyword is used to define a constant in Java?

 static

final

 const

 fixed The final keyword makes a variable constant, meaning it cannot be reassigned.

  1. Which of the following is not a Java keyword?

 static

unsigned

 throw

 synchronized Java does not support the unsigned keyword.

  1. What is the use of super keyword in Java?

 Call the main method

Call the parent class constructor or method

 Define a new method

 Override a class super is used to refer to the superclass's methods or constructors.

  1. Which method is used to start a thread in Java?

 execute()

 begin()

start()

 init() To start a thread, you use the start() method, which invokes the run() method.

  1. Java is a...

 Compiled language only

 Interpreted language only

Compiled and interpreted language

 Scripted language Java source code is compiled into bytecode, which is interpreted/executed by the JVM.

  1. What does JVM stand for?

 Java Vendor Machine

Java Virtual Machine

 Java Visual Model

 Java Version Manager JVM stands for Java Virtual Machine, responsible for executing bytecode.

NullPointerException

 ClassNotFoundException NullPointerException is a runtime (unchecked) exception.

  1. What is the default value of a boolean variable in a class?

 true

 1

false

 null Boolean instance variables have a default value of false.

  1. Which of the following is not part of the java.lang package?

 String

 Math

Scanner

 Object The Scanner class is in java.util, not java.lang.

  1. Which of these interfaces must be implemented to create a thread?

 Runnable

Runnable

 Callable

 Executable Runnable is the standard interface for creating threads.

  1. Which Java operator is used to perform logical AND?

 &

&&

 ||

 | Logical AND uses &&; bitwise AND uses &.

  1. Which method must be implemented in an abstract class?

 static

 private

abstract

 final An abstract method must be implemented by a subclass of the abstract class.

  1. What does the this keyword refer to?

Current object

 Parent class

 Main method

 Superclass constructor The this keyword refers to the current instance of the class.

  1. What type of loop is guaranteed to execute at least once?

 for loop

 while loop

  1. Which of these is not a feature of Java?

 Platform-independent

 Object-oriented

Pointer support

 Robust Java does not support pointers like C/C++.

  1. Which keyword is used to handle exceptions?

 try

catch

 throw

 return The catch block is used to handle exceptions thrown in a try block.

  1. Which statement will stop a loop in Java?

 continue

break

 return

 exit The break statement is used to terminate a loop immediately.

  1. What is the output of Integer.parseInt("123")?

 "123"

 123.

123

 Error parseInt() converts a numeric string into an integer.

  1. Which keyword is used to prevent method overriding?

 static

final

 abstract

 protected The final keyword prevents a method from being overridden.

  1. What is garbage collection in Java?

 Manual memory allocation

Automatic memory management

 File deletion

 Process killing Garbage collection automatically frees memory by deleting unused objects.

  1. What will happen if the main() method is not declared as static?

 Code runs fine

Compiler error

 Runtime error

 Nothing The JVM cannot call a non-static method without creating an object.

  1. Which of these is a checked exception?

Math.floor() returns the largest integer less than or equal to the input.

  1. What is returned by StringBuilder().append("abc").reverse()?

 "abc"

"cba"

 "abcba"

 null The reverse method of StringBuilder reverses the string.

  1. Which Java keyword indicates that a method does not return a value?

 return

 static

 public

void The void keyword specifies that the method returns no value.

  1. Which of the following is true about interfaces in Java?

 Can contain constructors

 Can contain private methods only

Can contain default and static methods

 Cannot be extended Since Java 8, interfaces can contain default and static methods.

  1. Which of the following classes is synchronized?

 ArrayList

Vector

 LinkedList

 HashMap Vector is synchronized; ArrayList is not.

  1. What is the result of "hello".substring(1,4)?

"ell"

 "hello"

 "llo"

 "hel" substring(1,4) gives characters from index 1 to 3 (excluding 4).

  1. Which annotation is used to override a method?

 @Inherited

 @Implemented

@Override

 @Method The @Override annotation ensures that a method is overriding a superclass method.

  1. What does finalize() do?

 Compile code

 Convert types

Clean up before garbage collection

 Infinity

ArithmeticException

 NaN Division by zero for integers results in an ArithmeticException at runtime.

  1. Which method is called when an object is created?

 init()

 run()

constructor

 build() Constructors are special methods called at object instantiation.

  1. Which collection stores elements in key-value pairs?

 List

 Set

Map

 Queue Map stores data in key-value pairs and allows fast retrieval based on keys.

  1. What is the output of System.out.println(true && false);?

 true

false

 0

Logical AND (&&) only returns true if both operands are true.

  1. Which of these can be used to implement polymorphism?

 Inheritance

 Interfaces

 Method Overriding

All of the above Polymorphism in Java is implemented through method overriding, interfaces, and inheritance.

  1. Which statement is true about Java strings?

 Mutable

 Stored on stack

Immutable

 Uses char[] internally Strings in Java are immutable, meaning their value cannot be changed after creation.

  1. Which package is automatically imported in every Java program?

java.lang

 java.util

 java.io

 java.net The java.lang package is automatically imported by the compiler.

 HashSet

 TreeSet

ArrayList

 PriorityQueue ArrayList maintains insertion order and allows duplicates.

  1. What happens if an exception is not caught?

 Compilation error

 Program ignores it

Program terminates abnormally

 JVM halts gracefully Uncaught exceptions cause the program to terminate unexpectedly.

  1. Which interface provides CRUD operations for database connectivity in Java?

 JDBCException

 JNDI

JDBC

 SQLLink JDBC (Java Database Connectivity) provides methods for CRUD operations on databases.

  1. Which keyword is used to create a subclass?

 sub

 this

extends

 parent The extends keyword is used to inherit a class.

  1. What does System.out.println(Math.max(5, 10)); print?

 5

10

 0

 Error The Math.max() function returns the greater of two values.

  1. What is the primary benefit of encapsulation?

Data hiding

 Faster execution

 Multithreading

 Serialization Encapsulation hides internal object details, exposing only necessary parts.

  1. Which class would you use to write character-based output?

 FileInputStream

FileWriter

 DataOutputStream

 ObjectOutputStream FileWriter is used to write characters to a file.