Report Bug

QusWhat is the purpose of a slice in Go? QusWhat is the purpose of a slice in Go?


A. To store key-value pairs.
B. To represent a resizable array.
C. To define a block of code to be executed later.
D. To perform arithmetic operations.


Solution
B. To represent a resizable array.



Explanation
In Go, a slice is a data structure that represents a resizable and dynamically sized array. Slices provide a more flexible way to work with sequences of data compared to arrays, as they can grow or shrink as needed. Slices are widely used in Go for managing collections of data, such as lists or sequences. Option A is incorrect because slices do not store key-value pairs; that's the purpose of maps in Go. Option C is incorrect because defining a block of code to be executed later is typically done using functions or closures, not slices. Option D is incorrect because slices are not used for performing arithmetic operations.
Latest Current Affairs 2025 Online Exam Quiz for One day Exam Online Typing Test CCC Online Test 2025 Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) Best Java Training Institute in Prayagraj (Allahabad) Best Python Training Institute in Prayagraj (Allahabad) O Level Online Test in Hindi Bank SSC Railway TET UPTET Question Bank career counselling in allahabad Sarkari Naukari Notification Best Website and Software Company in Allahabad Sarkari Exam Quiz