R Programming Basics — Part 2 MCQs with Explanations
Practice high-yield Programming & Software Development MCQs on R Programming Basics — Part 2 with worked academic solutions for FPSC, PPSC, NTS, NITB, PTS.
Questions
40
Difficulty Level
Exam-Level
Target Exams
FPSC, PPSC, NTS...
Estimated Time
48 mins
Exam-Level FPSC PPSC NTS NITB PTS
Verified for Commission Syllabus • Oct 14, 2026
40
Verified Practice Questions
Interactive test mode with detailed academic worked solutions
Live Progress|0/40 answered
✓0 correct
✗0 wrong
0% score
🎉 Set complete! All 40 questions answered.
Question 1 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
An ordered collection of objects or components are called . . . . . . . .
Correct Answer: Option D — Lists
Detailed Academic Explanation:
Lists is the correct answer to “An ordered collection of objects or components are called . . . . . . . .”. This question is standard in competitive examination syllabi for R Programming Basics.
💡Key Conceptual Anchor:R Programming Basics
Question 2 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
The . . . . . . . . function returns a list of densities (y) corresponding to bin values (x).
Correct Answer: Option A — Spline
Detailed Academic Explanation:
Spline is the correct answer to “The . . . . . . . . function returns a list of densities (y) corresponding to bin values (x).”. This question is standard in competitive examination syllabi for R Programming Basics.
💡Key Conceptual Anchor:R Programming Basics
Question 3 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Data frames can have additional attributes such as . . . . . . . .
Correct Answer: Option B — Rownames()
Detailed Academic Explanation:
Rownames() is the correct answer to “Data frames can have additional attributes such as . . . . . . . .”. This question is standard in competitive examination syllabi for R Programming Basics.
💡Key Conceptual Anchor:R Programming Basics
Question 4 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
The . . . . . . . . function takes an arbitrary number of arguments and concatenates them one by one into character strings.
Correct Answer: Option A — copy()
Detailed Academic Explanation:
copy() is the correct answer to “The . . . . . . . . function takes an arbitrary number of arguments and concatenates them one by one into character strings.”. This question is standard in competitive examination syllabi for R Programming Basics.
💡Key Conceptual Anchor:R Programming Basics
Question 5 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
All columns in a matrix must have the same mode and the . . . . . . . . length.
Correct Answer: Option B — Same
Detailed Academic Explanation:
Same is the correct answer to “All columns in a matrix must have the same mode and the . . . . . . . . length.”. This question is standard in competitive examination syllabi for R Programming Basics.
💡Key Conceptual Anchor:R Programming Basics
Question 6 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
The four most frequently used types of data objects in R are vectors, matrices, data frames and . . . . . . . .
Correct Answer: Option B — Lists
Detailed Academic Explanation:
Lists is the correct answer to “The four most frequently used types of data objects in R are vectors, matrices, data frames and . . . . . . . .”. This question is standard in competitive examination syllabi for R Programming Basics.
💡Key Conceptual Anchor:R Programming Basics
Question 7 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
. . . . . . . .are Data frames which contain lists of homogeneous data in a tabular format.
Correct Answer: Option A — Matrix
Detailed Academic Explanation:
Matrix is the correct answer to “. . . . . . . .are Data frames which contain lists of homogeneous data in a tabular format.”. This question is standard in competitive examination syllabi for R Programming Basics.
💡Key Conceptual Anchor:R Programming Basics
Question 8 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following R code? > x <- 1:3 > y <- 10:12 > rbind(x, y)
Correct Answer: Option A — [,1] [,2] [,3] x 1 2 3 y 10 11 12
Detailed Academic Explanation:
[,1] [,2] [,3] x 1 2 3 y 10 11 12 is the correct answer to “What will be the output of the following R code? > x <- 1:3 > y <- 10:12 > rbind(x, y)”. This question is standard in competitive examination syllabi for R Programming Basics.
💡Key Conceptual Anchor:R Programming Basics
Question 9 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
To bind a row onto an already existing matrix, the . . . . . . . . function can be used.
Correct Answer: Option A — Rbind
Detailed Academic Explanation:
Rbind is the correct answer to “To bind a row onto an already existing matrix, the . . . . . . . . function can be used.”. This question is standard in competitive examination syllabi for R Programming Basics.
💡Key Conceptual Anchor:R Programming Basics
Question 10 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
vectors can be one of two types namely atomic vectors and . . . . . . . .
Correct Answer: Option C — Lists
Detailed Academic Explanation:
Lists is the correct answer to “vectors can be one of two types namely atomic vectors and . . . . . . . .”. This question is standard in competitive examination syllabi for R Programming Basics.
💡Key Conceptual Anchor:R Programming Basics
Question 11 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
A . . . . . . . . is a set of elements appearing in rows and columns where the elements are of the same mode whether they are logical, numeric (integer or double), complex or character.
Correct Answer: Option B — Matrix
Detailed Academic Explanation:
Matrix is the correct answer to “A . . . . . . . . is a set of elements appearing in rows and columns where the elements are of the same mode whether they are logical, numeric (integer or double), complex or character.”. This question is standard in competitive examination syllabi for R Programming Basics.
💡Key Conceptual Anchor:R Programming Basics
Question 12 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which function replicates elements of vectors?
Correct Answer: Option B — Rep
Detailed Academic Explanation:
Rep is the correct answer to “Which function replicates elements of vectors”. This question is standard in competitive examination syllabi for R Programming Basics.
💡Key Conceptual Anchor:R Programming Basics
Question 13 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of the following statement changes column name to h and f?
Correct Answer: Option A — colnames(m) <- c("h", "f")
Detailed Academic Explanation:
colnames(m) <- c("h", "f") is the correct answer to “Which of the following statement changes column name to h and f”. This question is standard in competitive examination syllabi for R Programming Basics.
💡Key Conceptual Anchor:R Programming Basics
Question 14 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of the following is a 3-dimensional dataset?
Correct Answer: Option B — Iris
Detailed Academic Explanation:
Iris is the correct answer to “Which of the following is a 3-dimensional dataset”. This question is standard in competitive examination syllabi for R Programming Basics.
💡Key Conceptual Anchor:R Programming Basics
Question 15 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following R code? > sqrt(-17)
Correct Answer: Option C — NaN
Detailed Academic Explanation:
NaN is the correct answer to “What will be the output of the following R code? > sqrt(-17)”. This question is standard in competitive examination syllabi for R Programming Basics.
💡Key Conceptual Anchor:R Programming Basics
Question 16 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following R code? > x <- 1:3 > y <- 10:12 > cbind(x, y)
Correct Answer: Option B — x y [1,] 1 10 [2,] 2 11 [3,] 3 12
Detailed Academic Explanation:
x y [1,] 1 10 [2,] 2 11 [3,] 3 12 is the correct answer to “What will be the output of the following R code? > x <- 1:3 > y <- 10:12 > cbind(x, y)”. This question is standard in competitive examination syllabi for R Programming Basics.
💡Key Conceptual Anchor:R Programming Basics
Question 17 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of the following statement is invalid?
Correct Answer: Option D — None of the mentioned
Detailed Academic Explanation:
None of the mentioned is the correct answer to “Which of the following statement is invalid”. This question is standard in competitive examination syllabi for R Programming Basics.
💡Key Conceptual Anchor:R Programming Basics
Question 18 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Locator function gives output as . . . . . . . .
Correct Answer: Option B — Lists
Detailed Academic Explanation:
Lists is the correct answer to “Locator function gives output as . . . . . . . .”. This question is standard in competitive examination syllabi for R Programming Basics.
💡Key Conceptual Anchor:R Programming Basics
Question 19 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Numbers in R are generally treated as . . . . . . . . precision real numbers.
Correct Answer: Option B — double
Detailed Academic Explanation:
double is the correct answer to “Numbers in R are generally treated as . . . . . . . . precision real numbers.”. This question is standard in competitive examination syllabi for R Programming Basics.
💡Key Conceptual Anchor:R Programming Basics
Question 20 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
To extract a sublist, we use . . . . . . . . brackets.
Correct Answer: Option D — Single
Detailed Academic Explanation:
Single is the correct answer to “To extract a sublist, we use . . . . . . . . brackets.”. This question is standard in competitive examination syllabi for R Programming Basics.
💡Key Conceptual Anchor:R Programming Basics
Question 21 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Using the . . . . . . . . vector, we create a species factor and bind it to the columns of iris.df.
Correct Answer: Option A — snames
Detailed Academic Explanation:
snames is the correct answer to “Using the . . . . . . . . vector, we create a species factor and bind it to the columns of iris.df.”. This question is standard in competitive examination syllabi for R Programming Basics.
💡Key Conceptual Anchor:R Programming Basics
Question 22 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which is the basic data structure of R containing the same type of data?
Correct Answer: Option C — Vector
Detailed Academic Explanation:
Vector is the correct answer to “Which is the basic data structure of R containing the same type of data”. This question is standard in competitive examination syllabi for R Programming Basics.
💡Key Conceptual Anchor:R Programming Basics
Question 23 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following R code? > m <- matrix(1:6, nrow = 2, ncol = 3) > m
[,1] [,2] [,3] [1,] 1 3 5 [2,] 2 4 6 is the correct answer to “What will be the output of the following R code? > m <- matrix(1:6, nrow = 2, ncol = 3) > m”. This question is standard in competitive examination syllabi for R Programming Basics.
💡Key Conceptual Anchor:R Programming Basics
Question 24 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following R code? > x <- data.frame(foo = 1:4, bar = c(T, T, F, F)) > ncol(x)
Correct Answer: Option A — 2
Detailed Academic Explanation:
2 is the correct answer to “What will be the output of the following R code? > x <- data.frame(foo = 1:4, bar = c(T, T, F, F)) > ncol(x)”. This question is standard in competitive examination syllabi for R Programming Basics.
> name(x) <- c("New York", "Seattle", "Los Angeles") is the correct answer to “Which of the following is invalid assignment”. This question is standard in competitive examination syllabi for R Programming Basics.
💡Key Conceptual Anchor:R Programming Basics
Question 26 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which function takes a dim attribute which creates the required number of dimensions?
Correct Answer: Option B — Array
Detailed Academic Explanation:
Array is the correct answer to “Which function takes a dim attribute which creates the required number of dimensions”. This question is standard in competitive examination syllabi for R Programming Basics.
💡Key Conceptual Anchor:R Programming Basics
Question 27 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following R code? > x <- vector("list", length = 5) > x
Correct Answer: Option A — NULL
Detailed Academic Explanation:
NULL is the correct answer to “What will be the output of the following R code? > x <- vector("list", length = 5) > x”. This question is standard in competitive examination syllabi for R Programming Basics.
💡Key Conceptual Anchor:R Programming Basics
Question 28 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
A . . . . . . . . is a two-dimensional rectangular data set.
Correct Answer: Option C — Matrix
Detailed Academic Explanation:
Matrix is the correct answer to “A . . . . . . . . is a two-dimensional rectangular data set.”. This question is standard in competitive examination syllabi for R Programming Basics.
💡Key Conceptual Anchor:R Programming Basics
Question 29 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which function is used to combine the elements into a vector?
Correct Answer: Option A — C()
Detailed Academic Explanation:
C() is the correct answer to “Which function is used to combine the elements into a vector”. This question is standard in competitive examination syllabi for R Programming Basics.
💡Key Conceptual Anchor:R Programming Basics
Question 30 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
By what function we can create data frames?
Correct Answer: Option A — Data.frames()
Detailed Academic Explanation:
Data.frames() is the correct answer to “By what function we can create data frames”. This question is standard in competitive examination syllabi for R Programming Basics.
💡Key Conceptual Anchor:R Programming Basics
Question 31 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of the following statement would print "0" "1" "2" "3" "4" "5" "6" for the following R code? > x <- 0:6
Correct Answer: Option A — as.character(x)
Detailed Academic Explanation:
as.character(x) is the correct answer to “Which of the following statement would print "0" "1" "2" "3" "4" "5" "6" for the following R code? > x <- 0:6”. This question is standard in competitive examination syllabi for R Programming Basics.
💡Key Conceptual Anchor:R Programming Basics
Question 32 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following R code? > x <- 6 > class(x)
Correct Answer: Option B — "numeric"
Detailed Academic Explanation:
"numeric" is the correct answer to “What will be the output of the following R code? > x <- 6 > class(x)”. This question is standard in competitive examination syllabi for R Programming Basics.
💡Key Conceptual Anchor:R Programming Basics
Question 33 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the Correct R code for the following output? foo bar 1 1 TRUE 2 2 TRUE 3 3 FALSE 4 4 FALSE
Correct Answer: Option C — > x <- data.frame(foo = 1:4, bar = c(T, T, F, F)) > x
Detailed Academic Explanation:
> x <- data.frame(foo = 1:4, bar = c(T, T, F, F)) > x is the correct answer to “What will be the Correct R code for the following output? foo bar 1 1 TRUE 2 2 TRUE 3 3 FALSE 4 4 FALSE”. This question is standard in competitive examination syllabi for R Programming Basics.
💡Key Conceptual Anchor:R Programming Basics
Question 34 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
. . . . . . . . function returns a vector of the same size as x with the elements arranged in increasing order.
Correct Answer: Option A — sort()
Detailed Academic Explanation:
sort() is the correct answer to “. . . . . . . . function returns a vector of the same size as x with the elements arranged in increasing order.”. This question is standard in competitive examination syllabi for R Programming Basics.
💡Key Conceptual Anchor:R Programming Basics
Question 35 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
R has how many atomic classes of objects?
Correct Answer: Option D — 5
Detailed Academic Explanation:
5 is the correct answer to “R has how many atomic classes of objects”. This question is standard in competitive examination syllabi for R Programming Basics.
💡Key Conceptual Anchor:R Programming Basics
Question 36 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Factors are created using the . . . . . . . . function.
Correct Answer: Option B — Function()
Detailed Academic Explanation:
Function() is the correct answer to “Factors are created using the . . . . . . . . function.”. This question is standard in competitive examination syllabi for R Programming Basics.
💡Key Conceptual Anchor:R Programming Basics
Question 37 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
First component of the list can be accessed by . . . . . . . .
Correct Answer: Option A — Name of the component
Detailed Academic Explanation:
Name of the component is the correct answer to “First component of the list can be accessed by . . . . . . . .”. This question is standard in competitive examination syllabi for R Programming Basics.
💡Key Conceptual Anchor:R Programming Basics
Question 38 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which function is used to enter in data at the terminal?
Correct Answer: Option C — Scan
Detailed Academic Explanation:
Scan is the correct answer to “Which function is used to enter in data at the terminal”. This question is standard in competitive examination syllabi for R Programming Basics.
💡Key Conceptual Anchor:R Programming Basics
Question 39 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which are indexed by either row or column using a specific name or number?
Correct Answer: Option B — Data frames
Detailed Academic Explanation:
Data frames is the correct answer to “Which are indexed by either row or column using a specific name or number”. This question is standard in competitive examination syllabi for R Programming Basics.
💡Key Conceptual Anchor:R Programming Basics
Question 40 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following R code? > x <- list(1, "a", TRUE, 1 + 4i) > x
Correct Answer: Option A — [[1]] [1] 1 [[2]] [1] "a" [[3]] [1] TRUE [[4]] [1] 1+4i
Detailed Academic Explanation:
[[1]] [1] 1 [[2]] [1] "a" [[3]] [1] TRUE [[4]] [1] 1+4i is the correct answer to “What will be the output of the following R code? > x <- list(1, "a", TRUE, 1 + 4i) > x”. This question is standard in competitive examination syllabi for R Programming Basics.
💡Key Conceptual Anchor:R Programming Basics
✓Link copied to clipboard
Continue Your Practice
Advance Html — Part 1
Master the next curriculum module with 40 exam-standard MCQs.
💡Examiner's Advisory for Programming & Software Development
In competitive commission exams (FPSC, PPSC, KPPSC, SPSC, CSS, PMS), questions are frequently phrased with distractor options designed to catch rote learners. Whenever you answer an MCQ, read the Detailed Academic Explanation and Conceptual Anchor to understand why the remaining options are incorrect.