MCQ IN COMPUTER SCIENCE & ENGINEERING

COMPUTER SCIENCE AND ENGINEERING

ALGORITHMS

Question [CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
Which of the following is an example of a simple (atomic) variable?
A
score = 7
B
name = “Jack”
C
scores = [4, 2, 12, 7]
D
grades = ["A", “F", “B"]
Explanation: 

Detailed explanation-1: -An atomic variable is just a variable whose value changes atomically.

Detailed explanation-2: -Atomic is a toolkit of variable java. util. concurrent. atomic package classes, which assist in writing lock and wait-free algorithms with the Java language. An algorithm requiring only partial threads for constant progress is lock-free.

Detailed explanation-3: -They are called atomic variables because they provide some operations that cannot be interfered by multiple threads. Here’s to name a few: incrementAndGet(): Atomically increments by one the current value. decrementAndGet(): Atomically decrements by one the current value.

Detailed explanation-4: -Java provides atomic classes such as AtomicInteger, AtomicLong, AtomicBoolean and AtomicReference. Objects of these classes represent the atomic variable of int, long, boolean, and object reference respectively.

There is 1 question to complete.