Generic selectors
Exact matches only
Search in title
Search in content
Search in posts
Search in pages
Filter by Categories
nmims post
Objective Type Set
Online MCQ Assignment
Question Solution
Solved Question
Uncategorized

1. The == ‘is equal to’ is known as relational operator.
a) True
b) False

View Answer

Answer: a [Reason:] The == is used to compare two things are equal or not and hence it is known as comparator/relational operator.

2. The ‘=’ is used for assigning value to variable?
a) True
b) False

View Answer

Answer: a [Reason:] The ‘=’ is known as assignment operator.

3. What will the following code evaluate to?

a=9!=10

a) True
b) False
c) Syntax error
d) None of the mentioned

View Answer

Answer: a [Reason:] 9 is not equal to 10 hence it will evaluate to true.

Output:
True

4. What is the output of the given code?

test_1 = 17 > 16
puts(test_1)
test_2 = 21 <= 30
puts(test_2)
test_3 = 9 >= 9
puts(test_3)
test_4 = -11 > 4
puts(test_4)

a) True false true false
b) True True True False
c) False False True True
d) None of the mentioned

View Answer

Answer: b [Reason:] All the expressions which are correct will evluate to true rest all will evaluate to false.

Output:
true
true
true
false

5. What is the output of the given code?

a="string"
b="strings"
if(a==b)
    print ("a and b are same")
else 
    print "Not same"
end

a) a and b are same
b) Not same
c) a==b
d) None of the mentioned

View Answer

Answer: b [Reason:] a and b are not similar hence the else condition will get executed.

Output:
Not same

6. Assignment operator is also known as relational operator.
a) True
b) False

View Answer

Answer: a [Reason:] Assignment operator is used for assigning a value.

7. What is the output of the given code?

a=10
b=9
if(a>b)
    print ("a greater than b")
else 
    print "Not greater"
end

a) a greater than b
b) Not greater
c) Syntax error
d) None of the mentioned

View Answer

Answer: a [Reason:] Assigning the value to the variable and checking the condition.

Output:
a greater than b

8. Which of the following are used for comparison?
a) Equal to
b) Not equal to
c) Less than or greater than
d) All of the mentioned

View Answer

Answer: d [Reason:] All of the mentioned above are used for comparisons.

9. What is the output of the given code?

if(a==10 && b=9)
    print "true"
else
    print "false"
end

a) True
b) False
c) Error
d) None of the mentioned

View Answer

Answer: c [Reason:] We are assigning the value to the variable b which is not correct.

Output:
warning: found = in conditional, should be ==

10. What is the output of the given code?

counter=1
if counter<=5
    puts (counter)
    counter=counter+1

a) Syntax error
b) 1 2
c) 1
d) None of the mentioned

View Answer

Answer: a [Reason:] end statement is required after every if statement.

Output: syntax error, unexpected $end, expecting keyword_end

Synopsis and Project Report

You can buy synopsis and project from distpub.com. Just visit https://distpub.com/product-category/projects/ and buy your university/institute project from distpub.com