wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Spark Arch & Component

Total questions: 30

Worksheet time: 15mins

Name
Class
Date
1.

RDDs in Spark are…

a)
Resilient Distributed Datasets (RDDs) are single-threaded collections of objects that are not fault-tolerant.
b)
RDDs in Spark are mutable collections of objects that cannot be processed in parallel.
c)
Resilient Distributed Datasets (RDDs) are immutable collections of objects that can be processed in parallel.
d)
Resilient Distributed Datasets (RDDs) are temporary collections of data stored in memory.
2.

Which transformation creates a new RDD?

a)

collect()

b)

count()

c)

map()

d)

take()

3.

Which of the following is an action on an RDD?

a)

flatMap

b)

filter

c)

reduce

d)

map

4.

RDD lineage helps in:

a)

Storing RDD data permanently

b)

Recomputing lost partitions

c)

Increasing cluster size

d)

Scheduling cluster jobs

5.

Which storage level provides the highest performance for RDD caching?

a)

MEMORY_ONLY

b)

DISK_ONLY

c)

MEMORY_AND_DISK

d)

OFF_HEAP

6.

The DAG in Spark is created during:

a)

Actions

b)

Transformations

c)

Both A and B

d)

Neither A nor B

7.

The DAG Scheduler in Spark converts the DAG into:

a)

Blocks

b)

Stages

c)

Tasks

d)

Executors

8.

A stage is divided into tasks based on:

a)

Number of executors

b)

Number of partitions

c)

Driver configuration

d)

Cluster manager

9.

The DAG created by Spark is:

a)

Acyclic

b)

Cyclic

c)

Can be cyclic or acyclic

d)

Always linear

10.

Spark Driver is responsible for:

a)

Running tasks on executors

b)

Managing cluster resources

c)

Converting logical plan into physical plan

d)

Scheduling tasks

11.

Which component actually executes tasks?

a)

Driver

b)

Executor

c)

Cluster Manager

d)

DAG Scheduler

12.

Cluster Manager allocates:

a)

Tasks

b)

RDDs

c)

Resources

d)

Transformations

13.

Which of the following is not a cluster manager used in Spark?

a)

YARN

b)

Mesos

c)

Kubernetes

d)

Jenkins

14.

Which is true about Spark Executors?

a)

They run on the driver node

b)

They continue running for the entire application

c)

They store metadata only

d)

They schedule jobs

15.

What is the output of the following code?

val rdd = sc.parallelize(Seq(1, 2, 3))

val result = rdd.map(_ * 2)

println(result.collect().mkString(","))

a)

2, 4, 6

b)

1, 2, 3

c)

Compilation error

d)

Runtime error

16.

What type of operation is filter in the snippet below?

val rdd = sc.parallelize(Seq(5, 10, 15))

val result = rdd.filter(_ > 10)

a)

Action

b)

Transformation

c)

Shuffle operation

d)

Persistence operation

17.

What will be printed?

val rdd = sc.parallelize(List("a","b","c"))

val mapped = rdd.map(x => x.toUpperCase)

println(mapped.first())

a)

"a"

b)

"A"

c)

"C"

d)

"A","B","C"

18.

What does reduce return in this code?

val rdd = sc.parallelize(List(1,2,3,4))

val res = rdd.reduce(_ + _)

a)

RDD[Int]

b)

Int

c)

Iterator[Int]

d)

Array[Int]

19.

What happens when the following code runs?

val rdd = sc.parallelize(Seq(1,2,3))

val cached = rdd.cache()

println(cached.count())

a)

Data is cached after count()

b)

Data is cached before count()

c)

No caching happens

d)

Throws exception

20.

How many stages will this produce?

val rdd1 = sc.textFile("file1")

val rdd2 = rdd1.map(_.length)

val rdd3 = rdd2.reduce(_ + _)

a)

1

b)

Depends on file size

c)

2

d)

4

21.

How many stages will this create?

val rdd = sc.parallelize(Seq(("a",1),("b",2),("a",3)))

val reduced = rdd.reduceByKey(_ + _)

println(reduced.collect().toList)

a)

Depends on cluster size

b)

1

c)

2

d)

3

22.

Which action triggers DAG execution here?

val rdd = sc.parallelize(Seq(1,2,3)).map(_ * 3)

val result = rdd.filter(_ > 3)

result.count()

a)

map

b)

filter

c)

count

d)

parallelize

23.

What does Spark build when running this?

val rdd1 = sc.parallelize(Seq(1,2))

val rdd2 = rdd1.map(_ + 1)

val result = rdd2.collect()

a)

Physical execution plan directly

b)

DAG then stages

c)

Only one stage plan

d)

No DAG needed

24.

When is the DAG finalized in this flow?

val x = sc.textFile("data.txt").map(_.length)

x.reduce(_ + _)

a)

During map

b)

During reduce

c)

After reduce executes

d)

During textFile

25.

Which component creates tasks here?

val rdd = sc.parallelize(Seq(1,2,3))

rdd.map(_ * 2).collect()

a)

Executor

b)

Driver

c)

Cluster Manager

d)

Worker node

26.

What happens when collect() is called?

val rdd = sc.parallelize(List(1,2)).map(_ * 10)

val result = rdd.collect()

a)

Driver receives all results

b)

Executors store results

c)

Cluster manager merges tasks

d)

DAG scheduler deletes RDD

27.

What runs continuously throughout the application?

val rdd = sc.parallelize(Seq("x","y"))

rdd.count()

a)

Driver

b)

Executors

c)

DAG Scheduler

d)

Task Scheduler

28.

What will be the schema of the following DataFrame?

val df = Seq((1, "Alice"), (2, "Bob"))

.toDF("id", "name")

df.printSchema()

a)

id: String

name: String

b)

id: Int

name: String

c)

id: Long

name: String

d)

Schema cannot be inferred

29.

What does this code return?

val df = Seq(10, 20, 30).toDF("num")

val result = df.select(col("num") * 2)

result.show()

a)

A DataFrame with column num multiplied by 2

b)

A DataFrame with no column name

c)

A DataFrame with a column named "num"

d)

A runtime error

30.

What is the result of this code?

val df = Seq(("a", 1), ("b", 2), ("a", 3)).toDF("key", "value")

val result = df.groupBy("key").agg(sum("value"))

result.show()

a)

Fails due to missing alias

b)

Groups by key and sums values

c)

Returns same rows

d)

Throws a runtime error