Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Worksheet Questions Extraction

Total questions: 86

Worksheet time: 43mins

Name
Class
Date
1.

Finalize method is associated with?

a)

Construction

b)

Serialization

c)

Cloning

d)

Garbage Collection (Pre-destruction)

2.

G1 GC stands for?

a)

Global 1

b)

Generation 1

c)

Garbage First

d)

General One

3.

Heap memory is used for?

a)

Dynamic Object Allocation

b)

Primitives

c)

Code

d)

Threads

4.

If you pass an Object reference to a method, what is actually passed?

a)

The memory address directly

b)

A deep copy

c)

A copy of the reference bits (Value of the reference)

d)

The object itself

5.

Immutability implies that an object's state…

a)

Cannot be modified after creation

b)

Is synchronized

c)

Is transient

d)

Can change anytime

6.

Java Records introduced to reduce?

a)

Boilerplate code for data carriers

b)

Security

c)

Compilation time

d)

Performance

7.

Recursive method calls without a base case lead to?

a)

OutOfMemoryError

b)

Heap Space Error

c)

StackOverflowError

d)

CPU Overheat

8.

Static context cannot access?

a)

Constants

b)

this or super (Instance context)

c)

Global vars

d)

Static vars

9.

Static methods and class definitions are stored in?

a)

Stack

b)

Young Generation

c)

Old Generation

d)

Metaspace (formerly PermGen)

10.

Thread safety is inherent in?

a)

Builders

b)

Prototypes

11.

To prevent inheritance, a class must be marked as?

a)

Final

b)

Sealed

c)

Private

d)

Static

12.

Uninitialized boolean defaults to?

a)

Null

b)

False

c)

True

d)

1

13.

Universal superclass in Java?

a)

Root

b)

Object

c)

Entity

d)

Main

14.

Variable scope on the stack ends when?

a)

Method returns

b)

App stops

c)

GC runs

d)

Class unloads

15.

Which memory segment holds method-local primitive types?

a)

Native Stack

b)

Heap

c)

Metaspace

d)

Stack

16.

Wrapper classes allow primitives to be used in?

a)

Collections (Generics)

b)

Switch statements

c)

Math operations

d)

Loops

17.

new String("xyz") creates objects in…

a)

None

b)

Pool only

c)

Stack only

d)

Both Heap and potentially String Pool

18.

ConcurrentModificationException occurs when?

a)

List is full

b)

Modifying collection while iterating (without iterator's remove)

c)

Map is empty

d)

Thread sleep

19.

Contract for equals() and hashCode()?

a)

If equals is false, hashCode must be same

b)

No relation

c)

If hashCode is same, equals must be true

d)

If equals is true, hashCode must be same

20.

CopyOnWriteArrayList is best for?

a)

Sorting

b)

Large lists

c)

Write-heavy

d)

Read-heavy concurrent scenarios

21.

Fast reading by index is a feature of?

a)

HashSet

b)

ArrayList

c)

LinkedList

d)

TreeSet

22.

HashMap buckets typically contain?

a)

Only values

b)

Linked Lists (or Trees) of Entry nodes

c)

Only keys

d)

Arrays

23.

HashSet lookup time?

a)

O(n*n)

b)

O(1) amortized

c)

O(n)

d)

O(log n)

24.

Key collision in HashMap results in?

a)

Overwriting the existing entry

b)

Multiple entries chained in the same bucket (linked list or tree)

c)

Throwing a runtime exception

d)

Automatic key renaming

25.

LinkedList get(i) complexity?

a)

Logarithmic

b)

Exponential

c)

Linear O(n)

d)

Constant

26.

Map keys must implement correctly?

a)

compareTo

b)

run

c)

hashCode and equals

d)

serialize

27.

Map interface extends Collection?

a)

Indirectly

b)

No

c)

Yes

d)

In Java 21

28.

Natural ordering is defined by?

a)

Comparable interface

b)

Comparator

c)

Equals

d)

Hash

29.

Sorted unique elements are found in?

a)

HashMap

b)

Vector

c)

TreeSet

d)

ArrayList

30.

Stack implementation typically uses?

a)

Sorted

b)

FIFO

c)

LIFO (Last In First Out)

d)

Random Access

31.

Treeify threshold for HashMap?

a)

4

b)

8

c)

16

d)

2

32.

@Override usage is?

a)

To indicate a method overrides a superclass or interface method

b)

To declare a new class-level constant

c)

To enable runtime reflection on private fields

d)

To mark a constructor as default

33.

Abstract class forces subclasses to?

a)

Use super

b)

Be final

c)

Be static

d)

Implement abstract methods (unless abstract themselves)

34.

Composition suggests?

a)

Copying code

b)

Building classes from other classes (Has-A)

c)

Splitting classes

d)

Inheriting code

35.

Conflicting default methods key solution?

a)

Runtime error

b)

First one wins

c)

Class must override and explicitly choose (Class.super.method)

d)

Compiler chooses

36.

Constructors are not?

a)

Public

b)

Overloaded

c)

Called

d)

Inherited

37.

Default methods in interfaces allow?

a)

Constructors

b)

Backward compatibility (adding method bodies)

c)

Destructors

d)

State

38.

Diamond Problem relates to?

a)

Multiple Implementation Inheritance ambiguity

b)

Memory

c)

Interfaces

d)

Graphics

39.

Final method prevents?

a)

Access

b)

Overriding

c)

Execution

d)

Overloading

40.

Has-A relationship is?

a)

Composition / Aggregation

b)

Interface

c)

Polymorphism

d)

Inheritance

41.

Interface instantiation?

a)

Impossible ever

b)

Only via reflection

c)

Possible directly

d)

Possible via Anonymous Inner Class

42.

Liskov Substitution Principle implies?

a)

Subtype must be substitutable for Base type

b)

No inheritance

c)

Interfaces only

d)

Parent replaces Child

43.

Multiple Inheritance of State is?

a)

Mandatory

b)

Forbidden in Java

c)

Possible via Abstract classes

d)

Allowed

44.

Overriding depends on?

a)

Static type

b)

Runtime object type (Dynamic Binding)

c)

Compiler

d)

File name

45.

Package-private access is default when?

a)

Private is used

b)

No modifier is specified

c)

Public is used

d)

Protected is used

46.

SAM type stands for?

a)

Synchronized Async Method

b)

Static Access Mode

c)

Single Abstract Method

d)

Simple Abstract Model

47.

Serializable is an example of?

a)

Functional Interface

b)

Marker Interface

c)

Class

d)

Annotation

48.

White-box reuse refers to?

a)

Copy-Paste

b)

Composition

c)

Libraries

d)

Inheritance (Subclass knows internals)

49.

Accumulate elements into a summary result?

a)

Filter

b)

Split

c)

Reduce

d)

Generate

50.

Can you reuse a closed stream?

a)

Sometimes

b)

No, IllegalStateException

c)

After reset

d)

Yes

51.

Declarative programming focuses on?

a)

Steps

b)

Result desired

c)

Memory management

d)

Control flow

52.

Double colon operator (::) signifies?

a)

Cast

b)

Method Reference

c)

Scope

d)

Constructor

53.

Finding one element and stopping?

a)

findAny

b)

forEach

c)

sorted

d)

peek

54.

ForkJoinPool is used by? (MEDIUM)

a)

JDBC

b)

Serial Stream

c)

IO Stream

d)

Parallel Stream

55.

Function that accepts value and returns void? (MEDIUM)

a)

Predicate

b)

Supplier

c)

Operator

d)

Consumer

56.

Function that returns boolean? (MEDIUM)

a)

Predicate

b)

Supplier

c)

Function

d)

Consumer

57.

Function signature? (MEDIUM)

a)

T get()

b)

R apply(T t)

c)

void apply()

d)

boolean test(T t)

58.

Merging multiple streams into one? (MEDIUM)

a)

group

b)

sort

c)

flatMap

d)

map

59.

Operation for observing without changing? (MEDIUM)

a)

Peek

b)

Switch

c)

Change

d)

Map

60.

Optional is essentially? (MEDIUM)

a)

A primitive

b)

A container object which may or may not contain a non-null value

c)

A collection

d)

A pointer

61.

Parallel streams overhead logic? (MEDIUM)

a)

Splitting and merging costs may outweigh benefits for small tasks

b)

None

c)

Linear

d)

Always huge

62.

Processing moves data? (MEDIUM)

a)

To the code

b)

Through the pipeline (Pull based)

c)

To disk

d)

To network

63.

Transforming elements one-to-one? (MEDIUM)

a)

reduce

b)

filter

c)

peek

d)

map

64.

forEach() is? (MEDIUM)

a)

Optional

b)

Helper

c)

Intermediate

d)

Terminal

65.

Argument to avoid running tests? (HARD)

a)

--no-tests

b)

-DskipTests

c)

-T 0

d)

-Fast

66.

Command to run unit tests?

a)

mvn run

b)

mvn test

c)

mvn debug

d)

mvn check

67.

Descriptor for Maven?

a)

package.json

b)

build.xml

c)

makefile

d)

pom.xml

68.

Gradle build script file?

a)

pom.gradle

b)

build.gradle

c)

config.gradle

d)

make.gradle

69.

Indirect dependency is called?

a)

Sub

b)

Hidden

c)

Implicit

d)

Transitive

70.

Inheritance in Maven?

a)

Via Plugins

b)

Via Parent POM

c)

Via Copying

d)

Not supported

71.

Installing artifact to local repo?

a)

mvn put

b)

mvn copy

c)

mvn save

d)

mvn install

72.

Local repo location usually?

a)

/usr/local

b)

~/.m2/repository

c)

/bin

d)

/lib

73.

Maven uses XML, Gradle uses?

a)

JSON

b)

YAML

c)

C++

d)

Groovy / Kotlin DSL

74.

Phase producing the artifact?

a)

Test

b)

Validate

c)

Clean

d)

Package

75.

Removing build directory?

a)

Wipe

b)

Remove

c)

Reset

d)

Clean

76.

Scope causing JAR to NOT be included in distribution?

a)

Import

b)

All

c)

Provided

d)

Compile

77.

Scope for dependencies needed only for compiling tests?

a)

Compile

b)

Test

c)

Runtime

d)

System

78.

Shaded Jar contains?

a)

Code only

b)

Encryption

c)

Shadows

d)

Dependencies unpacked and merged

79.

Suffix '-SNAPSHOT' implies?

a)

Photo

b)

Work in progress / volatile

c)

Backup

d)

Read-only

80.

Unique ID for a library in Maven?

a)

ISBN

b)

URL

c)

GroupId + ArtifactId + Version

d)

DOI

81.

pom.xml tracks?

a)

User data

b)

Performance

c)

Project configuration and dependencies

d)

Bugs

82.

A Bean in Spring is logically a...?

a)

Managed object instantiated by the Container

b)

Database row

c)

Primitive

d)

Coffee object

83.

Annotation to resolve ambiguity?

a)

@Qualifier

b)

@One

c)

@Select

d)

@Pick

84.

Are Singletons thread-safe by default?

a)

No, developer must ensure statelessness

b)

Yes

c)

Yes, Spring locks them

d)

Always

85.

Bean A requires Bean B, Bean B requires Bean A error?

a)

StackOverflow

b)

Circular Dependency

c)

Loop Error

d)

Memory Leak

86.

Context for web-aware request scope?

a)

Servlet

b)

ApplicationContext

c)

BeanFactory

d)

WebApplicationContext