Skip to main content

Basic Syntax In Ruby — Part 1 MCQs with Explanations

Practice high-yield Programming & Software Development MCQs on Basic Syntax In Ruby — Part 1 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
Question 1 of 40
★ FPSC ★ PPSC

What symbol is used to denote comments in Ruby?

Question 2 of 40
★ FPSC ★ PPSC

Which symbol is used to concatenate strings in Ruby?

Question 3 of 40
★ FPSC ★ PPSC

What does the 'puts' method do in Ruby?

Question 4 of 40
★ FPSC ★ PPSC

In Ruby, what is the keyword used to define a method?

Question 5 of 40
★ FPSC ★ PPSC

Which of the following is a valid variable name in Ruby?

Question 6 of 40
★ FPSC ★ PPSC

What does the 'gets' method do in Ruby?

Question 7 of 40
★ FPSC ★ PPSC

Which of the following is NOT a valid data type in Ruby?

Question 8 of 40
★ FPSC ★ PPSC

What is the correct syntax for defining a variable in Ruby?

Question 9 of 40
★ FPSC ★ PPSC

What does the 'print' method do in Ruby?

Question 10 of 40
★ FPSC ★ PPSC

What symbol is used to denote the end of a statement in Ruby?

Question 11 of 40
★ FPSC ★ PPSC

Which of the following is the correct way to start a single-line comment in Ruby?

Question 12 of 40
★ FPSC ★ PPSC

In Ruby, what is the keyword used to define a class?

Question 13 of 40
★ FPSC ★ PPSC

Which of the following is the correct way to define a constant in Ruby?

Question 14 of 40
★ FPSC ★ PPSC

What is the default file extension for Ruby files?

Question 15 of 40
★ FPSC ★ PPSC

Which method is used to convert a string to uppercase in Ruby?

Question 16 of 40
★ FPSC ★ PPSC

What is the correct way to declare a variable in Ruby?

Question 17 of 40
★ FPSC ★ PPSC

What is the correct syntax for printing a message to the console?

Question 18 of 40
★ FPSC ★ PPSC

How do you add two numbers in Ruby?

Question 19 of 40
★ FPSC ★ PPSC

Which of these operators is used for string concatenation?

Question 20 of 40
★ FPSC ★ PPSC

What is the correct way to define a conditional statement in Ruby?

Question 21 of 40
★ FPSC ★ PPSC

What is the correct syntax for creating a hash in Ruby?

Question 22 of 40
★ FPSC ★ PPSC

How do you access a value from a hash in Ruby?

Question 23 of 40
★ FPSC ★ PPSC

What is the correct way to define a method in Ruby?

Question 24 of 40
★ FPSC ★ PPSC

How do you call a method in Ruby?

Question 25 of 40
★ FPSC ★ PPSC

What are the different types of comments in Ruby?

Question 26 of 40
★ FPSC ★ PPSC

What is the difference between =~ and == operators?

Question 27 of 40
★ FPSC ★ PPSC

What is the difference between nil and false?

Question 28 of 40
★ FPSC ★ PPSC

What is the correct way to define a symbol in Ruby?

Question 29 of 40
★ FPSC ★ PPSC

What is the purpose of the gem command in Ruby?

Question 30 of 40
★ FPSC ★ PPSC

What is the correct way to define an array in Ruby?

Question 31 of 40
★ FPSC ★ PPSC

How do you check the truthiness of a value in Ruby?

Question 32 of 40
★ FPSC ★ PPSC

How do you break out of a loop in Ruby?

Question 33 of 40
★ FPSC ★ PPSC

What is the default return value of a method in Ruby?

Question 34 of 40
★ FPSC ★ PPSC

What is the correct syntax for accessing a class method?

Question 35 of 40
★ FPSC ★ PPSC

How do you define a range in Ruby?

Question 36 of 40
★ FPSC ★ PPSC

What is the correct syntax for string interpolation in Ruby?

Question 37 of 40
★ FPSC ★ PPSC

How do you compare two objects in Ruby?

Question 38 of 40
★ FPSC ★ PPSC

What is the correct way to define a block in Ruby?

Question 39 of 40
★ FPSC ★ PPSC

How do you pass arguments to a method in Ruby?

Question 40 of 40
★ FPSC ★ PPSC

What is the purpose of the require keyword in Ruby?

✓ Link copied to clipboard
Continue Your Practice

Advance Html — Part 1

Master the next curriculum module with 40 exam-standard MCQs.

Next Practice Set →

💡 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.

More Modules in Programming & Software Development

View All →
📚

Study Guides

Topic summaries and syllabus breakdown

Explore Guides →
🎯

Complete Library

Search through 78,000+ verified MCQs

Browse Library →
📱

Mobile App

Offline mock tests and instant bookmarks

Get Mobile App →