Question:
What will be the output of the following Python code?
class A:
    def __init__(self, x= 1):
        self.x = x
class der(A):
    def __init__(self,y = 2):
        super().__init__()
        self.y = y
def main():
    obj = der()
    print(obj.x, obj.y)
main()

Choices:
- Error, the syntax of the invoking method is wrong
- The program runs fine but nothing is printed
- 1 0
- 1 2


Question:
What will be the output of the following Python code?
class A:
    def one(self):
        return self.two()

    def two(self):
        return 'A'

class B(A):
    def two(self):
        return 'B'
obj1=A()
obj2=B()
print(obj1.two(),obj2.two())

Choices:
- A A
- A B
- B B
- An exception is thrown


Question:
What type of inheritance is illustrated in the following Python code?
class A():
    pass
class B():
    pass
class C(A,B):
    pass

Choices:
- Multi-level inheritance
- Multiple inheritance
- Hierarchical inheritance
- Single-level inheritance


Question:
What type of inheritance is illustrated in the following Python code?
class A():
    pass
class B(A):
    pass
class C(B):
    pass

Choices:
- Multi-level inheritance
- Multiple inheritance
- Hierarchical inheritance
- Single-level inheritance


Question:
What will be the output of the following Python code?
class A:
     def __init__(self):
         self.__i = 1
         self.j = 5

     def display(self):
         print(self.__i, self.j)
class B(A):
     def __init__(self):
         super().__init__()
         self.__i = 2
         self.j = 7
c = B()
c.display()

Choices:
- 2 7
- 1 5
- 1 7
- 2 5


Question:
What will be the output of the following Python code?
class A:
    def __init__(self,x):
        self.x = x
    def count(self,x):
        self.x = self.x+1
class B(A):
    def __init__(self, y=0):
        A.__init__(self, 3)
        self.y = y
    def count(self):
        self.y += 1
def main():
    obj = B()
    obj.count()
    print(obj.x, obj.y)
main()

Choices:
- 3 0
- 3 1
- 0 1
- An exception in thrown


Question:
What will be the output of the following Python code?
>>> class A:
	pass
>>> class B(A):
	pass
>>> obj=B()
>>> isinstance(obj,A)

Choices:
- True
- False
- Wrong syntax for isinstance() method
- Invalid method for classes


Question:
What will be the output of the following Python code?
class A:
    def __init__(self):
        self.__x = 1
class B(A):
    def display(self):
        print(self.__x)
def main():
    obj = B()
    obj.display()
main()

Choices:
- 1
- 0
- Error, invalid syntax for object declaration
- Error, private class member can’t be accessed in a subclass


Question:
What will be the output of the following Python code?
class A:
    def __init__(self):
        self._x = 5
class B(A):
    def display(self):
        print(self._x)
def main():
    obj = B()
    obj.display()
main()

Choices:
- Error, invalid syntax for object declaration
- Nothing is printed
- 5
- Error, private class member can’t be accessed in a subclass


Question:
What will be the output of the following Python code?
class A:
    def __init__(self,x=3):
        self._x = x
class B(A):
    def __init__(self):
        super().__init__(5)
    def display(self):
        print(self._x)
def main():
    obj = B()
    obj.display()

main()

Choices:
- 5
- Error, class member x has two values
- 3
- Error, protected class member can’t be accessed in a subclass


Question:
What will be the output of the following Python code?
class A:
    def __str__(self):
        return '1'
class B(A):
    def __init__(self):
        super().__init__()
class C(B):
    def __init__(self):
        super().__init__()
def main():
    obj1 = B()
    obj2 = A()
    obj3 = C()
    print(obj1, obj2,obj3)
main()

Choices:
- 1 1 1
- 1 2 3
- ‘1’ ‘1’ ‘1’
- An exception is thrown


Question:
What will be the output of the following Python code?
class Demo:
    def __init__(self):
        self.x = 1
    def change(self):
        self.x = 10
class Demo_derived(Demo):
    def change(self):
        self.x=self.x+1
        return self.x
def main():
    obj = Demo_derived()
    print(obj.change())

main()

Choices:
- 11
- 2
- 1
- An exception is thrown


Question:
What will be the output of the following Python code?
class A:
    def __repr__(self):
        return "1"
class B(A):
    def __repr__(self):
        return "2"
class C(B):
    def __repr__(self):
        return "3"
o1 = A()
o2 = B()
o3 = C()
print(obj1, obj2, obj3)

Choices:
- 1 1 1
- 1 2 3
- ‘1’ ‘1’ ‘1’
- An exception is thrown


Question:
What will be the output of the following Python code?
class A:
    def __init__(self):
        self.multiply(15)
        print(self.i)

    def multiply(self, i):
        self.i = 4 * i;
class B(A):
    def __init__(self):
        super().__init__()

    def multiply(self, i):
        self.i = 2 * i;
obj = B()

Choices:
- 15
- 60
- An exception is thrown
- 30


Question:
What will be the output of the following Python code?
class Demo:
    def check(self):
        return " Demo's check "
    def display(self):
        print(self.check())
class Demo_Derived(Demo):
    def check(self):
        return " Derived's check "
Demo().display()
Demo_Derived().display()

Choices:
- Demo’s check Derived’s check
- Demo’s check Demo’s check
- Derived’s check Demo’s check
- Syntax error


Question:
What will be the output of the following Python code?
class A:
    def __init__(self):
        self.multiply(15)
    def multiply(self, i):
        self.i = 4 * i;
class B(A):
    def __init__(self):
        super().__init__()
        print(self.i)

    def multiply(self, i):
        self.i = 2 * i;
obj = B()

Choices:
- 15
- 30
- An exception is thrown
- 60


Question:
What will be the output of the following Python code?
class Demo:
    def __check(self):
        return " Demo's check "
    def display(self):
        print(self.check())
class Demo_Derived(Demo):
    def __check(self):
        return " Derived's check "
Demo().display()
Demo_Derived().display()

Choices:
- Demo’s check Derived’s check
- Demo’s check Demo’s check
- Derived’s check Demo’s check
- Syntax error


Question:
What will be the output of the following Python code?
class A:
    def __init__(self, x, y):
        self.x = x
        self.y = y
    def __str__(self):
        return 1
    def __eq__(self, other):
        return self.x * self.y == other.x * other.y
obj1 = A(5, 2)
obj2 = A(2, 5)
print(obj1 == obj2)

Choices:
- False
- 1
- True
- An exception is thrown


Question:
What will be the output of the following Python code?
class A:
    def one(self):
        return self.two()
    def two(self):
        return 'A'
class B(A):
    def two(self):
        return 'B'
obj2=B()
print(obj2.two())

Choices:
- A
- An exception is thrown
- A B
- B


Question:
What will be the output of the following Python code?
class Demo:
    def __init__(self):
        self.a = 1
        self.__b = 1

    def display(self):
        return self.__b
obj = Demo()
print(obj.a)

Choices:
- The program has an error because there isn’t any function to return self.a
- The program has an error because b is private and display(self) is returning a private member
- The program runs fine and 1 is printed
- The program has an error as you can’t name a class member using __b


Question:
What will be the output of the following Python code?
class Demo:
    def __init__(self):
        self.a = 1
        self.__b = 1

    def display(self):
        return self.__b

obj = Demo()
print(obj.__b)

Choices:
- The program has an error because there isn’t any function to return self.a
- The program has an error because b is private and display(self) is returning a private member
- The program has an error because b is private and hence can’t be printed
- The program runs fine and 1 is printed


Question:
Which of these is a private data field?
def Demo:
def __init__(self):
    __a = 1
    self.__b = 1
    self.__c__ = 1
    __d__= 1

Choices:
- __a
- __b
- __c__
- __d__


Question:
What will be the output of the following Python code?
class Demo:
     def __init__(self):
         self.a = 1
         self.__b = 1

     def get(self):
         return self.__b

obj = Demo()
print(obj.get())

Choices:
- The program has an error because there isn’t any function to return self.a
- The program has an error because b is private and display(self) is returning a private member
- The program has an error because b is private and hence can’t be printed
- The program runs fine and 1 is printed


Question:
What will be the output of the following Python code?
class Demo:
     def __init__(self):
         self.a = 1
         self.__b = 1
     def get(self):
         return self.__b
obj = Demo()
obj.a=45
print(obj.a)

Choices:
- The program runs properly and prints 45
- The program has an error because the value of members of a class can’t be changed from outside the class
- The program runs properly and prints 1
- The program has an error because the value of members outside a class can only be changed as self.a=45


Question:
What will be the output of the following Python code?
class fruits:
    def __init__(self):
        self.price = 100
        self.__bags = 5
    def display(self):
        print(self.__bags)
obj=fruits()
obj.display()

Choices:
- The program has an error because display() is trying to print a private class member
- The program runs fine but nothing is printed
- The program runs fine and 5 is printed
- The program has an error because display() can’t be accessed


Question:
What will be the output of the following Python code?
 class student:
    def __init__(self):
        self.marks = 97
        self.__cgpa = 8.7
    def display(self):
        print(self.marks)
obj=student()
print(obj._student__cgpa)

Choices:
- The program runs fine and 8.7 is printed
- Error because private class members can’t be accessed
- Error because the proper syntax for name mangling hasn’t been implemented
- The program runs fine but nothing is printed


Question:
What will be the output of the following Python code?
class objects:
    def __init__(self):
        self.colour = None
        self._shape = "Circle"

    def display(self, s):
        self._shape = s
obj=objects()
print(obj._objects_shape)

Choices:
- The program runs fine because name mangling has been properly implemented
- Error because the member shape is a protected member
- Error because the proper syntax for name mangling hasn’t been implemented
- Error because the member shape is a private member


Question:
Is the following Python code valid?
try:
    # Do something
except:
    # Do something
finally:
    # Do something

Choices:
- no, there is no such thing as finally
- no, finally cannot be used with except
- no, finally must come before except
- yes


Question:
Is the following Python code valid?
try:
    # Do something
except:
    # Do something
else:
    # Do something

Choices:
- no, there is no such thing as else
- no, else cannot be used with except
- no, else must come before except
- yes


Question:
What will be the output of the following Python code?
def foo():
    try:
        return 1
    finally:
        return 2
k = foo()
print(k)

Choices:
- 1
- 2
- 3
- error, there is more than one return statement in a single try-finally block


Question:
What will be the output of the following Python code?
def foo():
    try:
        print(1)
    finally:
        print(2)
foo()

Choices:
- 1 2
- 1
- 2
- none of the mentioned


Question:
What will be the output of the following Python code?
try:
    if '1' != 1:
        raise "someError"
    else:
        print("someError has not occurred")
except "someError":
    print ("someError has occurred")

Choices:
- someError has occurred
- someError has not occurred
- invalid code
- none of the mentioned


Question:
What will be the output of the following Python code?
x=10
y=8
assert x>y, 'X too small'

Choices:
- Assertion Error
- 10 8
- No output
- 108


Question:
What will be the output of the following Python code?
#generator
def f(x):
    yield x+1
g=f(8)
print(next(g))

Choices:
- 8
- 9
- 7
- Error


Question:
What will be the output of the following Python code?
def a():
    try:
        f(x, 4)
    finally:
        print('after f')
    print('after f?')
a()

Choices:
- No output
- after f?
- error
- after f


Question:
What will be the output of the following Python code?
def f(x):
    for i in range(5):
        yield i
g=f(8)
print(list(g))

Choices:
- [0, 1, 2, 3, 4]
- [1, 2, 3, 4, 5, 6, 7, 8]
- [1, 2, 3, 4, 5]
- [0, 1, 2, 3, 4, 5, 6, 7]


Question:
The error displayed in the following Python code is?
import itertools
l1=(1, 2, 3)
l2=[4, 5, 6]
l=itertools.chain(l1, l2)
print(next(l1))

Choices:
- ‘list’ object is not iterator
- ‘tuple’ object is not iterator
- ‘list’ object is iterator
- ‘tuple’ object is iterator


Question:
What will be the output of the following Python code?
g = (i for i in range(5))
type(g)

Choices:
- class <’loop’>
- class <‘iteration’>
- class <’range’>
- class <’generator’>


Question:
What happens if the file is not found in the following Python code?
a=False
while not a:
    try:
        f_n = input("Enter file name")
        i_f = open(f_n, 'r')
    except:
        print("Input file not found")

Choices:
- No error
- Assertion error
- Input output error
- Name error


Question:
What will be the output of the following Python code?
lst = [1, 2, 3]
lst[3]

Choices:
- NameError
- ValueError
- IndexError
- TypeError


Question:
What will be the output of the following Python code?
t[5]

Choices:
- IndexError
- NameError
- TypeError
- ValeError


Question:
What will be the output of the following Python code, if the time module has already been imported?
4 + '3'

Choices:
- NameError
- IndexError
- ValueError
- TypeError


Question:
What will be the output of the following Python code?
int('65.43')

Choices:
- ImportError
- ValueError
- TypeError
- NameError


Question:
Compare the following two Python codes shown below and state the output if the input entered in each case is -6?
CODE 1
import math
num=int(input("Enter a number of whose factorial you want to find"))
print(math.factorial(num))

CODE 2
num=int(input("Enter a number of whose factorial you want to find"))
print(math.factorial(num))

Choices:
- ValueError, NameError
- AttributeError, ValueError
- NameError, TypeError
- TypeError, ValueError


Question:
What will be the output of the following Python code?
def getMonth(m):
    if m<1 or m>12:
        raise ValueError("Invalid")
    print(m)
getMonth(6)

Choices:
- ValueError
- Invalid
- 6
- ValueError(“Invalid”)


Question:
What will be the output of the following Python code if the input entered is 6?
valid = False
while not valid:
    try:
        n=int(input("Enter a number"))
        while n%2==0:
            print("Bye")
        valid = True
    except ValueError:
        print("Invalid")

Choices:
- Bye (printed once)
- No output
- Invalid (printed once)
- Bye (printed infinite number of times)


Question:
Identify the type of error in the following Python codes?
Print(“Good Morning”)
print(“Good night)

Choices:
- Syntax, Syntax
- Semantic, Syntax
- Semantic, Semantic
- Syntax, Semantic


Question:
What will be the output of the following R program?
r<-0:10
r[2]

Choices:
- 0
- 1
- 2
- 3


Question:
What will be the output of the following R program?
        y<-0:5
 	vector(y)
 	y[3]

Choices:
- Error in vector(y): invalid ‘mode’ argument
- 1
- 4
- 3


Question:
What will be the output of the following R code?
y <- c(TRUE, 2)

Choices:
- [1] “TRUE”	“2”
- [1] “TRUE”	 2
- [1] “0”	“2”
- [1]   1        2


Question:
What is the class defined by the following R code?
y<-c(2,”t”)

Choices:
- Character
- Numeric
- Logical
- Integer


Question:
What is the class defined in the following R code?
    y<-c(FALSE,2)

Choices:
- Character
- Numeric
- Logical
- Integer


Question:
What will be the output of the following R code?
       x<- c (“a”,” b”)
       as.numeric(x)

Choices:
- [1]	1 2
- [1]	TRUE TRUE
- [1]	NA NA (Warning message: NAs introduced by coercion)
- [1]     NAN


Question:
How could be the matrix constructed by using the following R code?
 m <- matrix(1:6, nrow = 2, ncol = 3)

Choices:
- row-wise
- column-wise
- any manner
- data insufficient


Question:
What will be the output of the following R code?
    x <- c(3, 7, NA, 4, 7)
    y <- c(5, NA, 1, 2, 2)
    x + y

Choices:
- Symbol
- Missing Data
- 5
- 15.5


Question:
What is the mode of ‘a’ in the following R code?
     a <- c(1,” a”, FALSE)

Choices:
- Numeric
- Character
- Integer
- Logical


Question:
What is the length of b?
b <- 2:7

Choices:
- 4
- 5
- 6
- 0


Question:
What is the mode of b in the following R code?
     b <- c(TRUE, TRUE, 1)

Choices:
- Numeric
- Character
- Integer
- Logical


Question:
What are the typeof(x) and mode(x) in the following R syntax?
     x<-1:3

Choices:
- Numeric, Integer
- Integer, Numeric
- Integer, Integer
- Numeric, Numeric


Question:
What will be the output of the following R code?
       x <- (“a”, “b”)
       as.logical(x)

Choices:
- a  b
- “a”  “b”
- 1   1
- Error


Question:
What will be the output of the following R code?
      a <- (“a” , “b”)
      mode(a)

Choices:
- Character
- Numeric
- Complex
- Integer


Question:
What will be the output of the following R code?
options(digits = 16)
20/6

Choices:
- 3.33
- 3.333
- 3.3333333
- 3.3333333333333333


Question:
What will be the output of the following R code?
> x <- 1
> print(x)

Choices:
- 1
- 2
- 3
- 5


Question:
What is the meaning of the following R function?
x <- c(4, 5, 1, 2, 3, 3, 4, 4, 5, 6)
x <- as.factor(x)

Choices:
- x becomes a factor
- x is a factor
- x does not exist
- x is not a vector


Question:
What is the meaning of the following R function?
print( sqrt(2) )

Choices:
- 1.414314
- 1.414214
- Error
- 14.1414


Question:
What will be the output of the following R function?
d <- date()
d

Choices:
- Prints todays date
- Prints some date
- Prints exact present time and date
- Error


Question:
What will be the output of the following R function?
paste("Everybody", "is", “a” , "warrior")

Choices:
- “Everybody”, “is”, “a” , “warrior”
- Everybody is a warrior
- Everybody”, “is”, “a” , “warrior
- “Everybody is a warrior”


Question:
What will be the output of the following R function?
cat("Everybody", "is", "a", “warrior”,sep="*")

Choices:
- “Everybody”, “is”, “a” , “warrior”
- Everybody*is*a*warrior
- Everybody”, “is”, “a” , “warrior
- “Everybody*is*a*warrior”


Question:
What will be the output of the following R function?
nchar()

Choices:
- no. of characters
- first 5 characters
- last 5 characters
- Does not exist


Question:
What will be the output of the following R function?
Sys.Date()

Choices:
- Tomorrow date
- Present date
- Some date
- Yesterday date


Question:
What will be the output of the following R function?
Sys.time()

Choices:
- Tomorrow date and time
- Present date and time
- Some date
- Yesterday date and time


Question:
What will be the output of the following R code?
> x <- vector("numeric", length = 10)
> x

Choices:
- 10
- 0 0 0 0 0 0 0 0 0 0
- 01
- 00120


Question:
What will be the output of the following R code?
> x <- 6
> class(x)

Choices:
- “integer”
- “numeric”
- “real”
- “imaginary”


Question:
What will be the output of the following R code?
> x <- 0:6
> as.logical(x)

Choices:
- FALSE TRUE TRUE TRUE TRUE TRUE TRUE
- “0” “1” “2” “3” “4” “5” “6”
- 0 1 2 3 4 5 6
- 6 5 5 3 2 1


Question:
What will be the output of the following R code?
 > sqrt(-17)

Choices:
- -4.02
- 4.02
- NaN
- 3.67


Question:
Which of the following statement would print “0” “1” “2” “3” “4” “5” “6” for the following R code?
 > x <- 0:6

Choices:
- as.character(x)
- as.logical(x)
- as.numeric(x)
- as.num(y)


Question:
What will be the output of the following R code?
x <- c("a", "b", "c")
> as.numeric(x)

Choices:
- Warning
- Error
- Abnormal termination
- Prints x


Question:
What will be the output of the following R code?
> x <- c("a", "b", "c")
> as.logical(x)

Choices:
- a b c
- NA NA NA
- 0 1 2
- 6 8 9


Question:
What will be the output of the following R code?
 > m <- matrix(nrow = 2, ncol = 3)
 > dim(m)

Choices:
- 3 2
- 2 3
- 2 2
- 4 5


Question:
What will be the output of the following R code?
> m <- 1:10
> m

Choices:
- 1 2 3 4 5 6 7 8 9 10
- 1 2 3 4 5 6 7 8 9 10 11
- 0 1 2 3 4 5 6 7 8 9 10
- 10 9 8 6 5 4 2 3 1 2


Question:
Find the following type of vector?
a <- c(1,2,5.3,6,-2,4)

Choices:
- Numeric
- Character
- Integer
- Logical


Question:
What will be the output of the following R code?
> x <- vector("list", length = 5)
> x

Choices:
- NULL
- 1
- 0
- 4


Question:
What will be the output of the following R code?
> x <- c(1, 2, NaN, NA, 4)
> is.na(x)

Choices:
- FALSE FALSE TRUE TRUE FALSE
- FALSE TRUE TRUE TRUE FALSE
- TRUE FALSE TRUE TRUE FALSE
- TRUE FALSE TRUE FALSE FALSE


Question:
What will be the output of the following R code?
> x <- data.frame(foo = 1:4, bar = c(T, T, F, F))
> ncol(x)

Choices:
- 2
- 4
- 7
- 9


Question:
What will be the output of the following R code?
> x <- 1:3
> names(x)

Choices:
- NULL
- 1
- 2
- 4.5


Question:
Which of the following R statement will save the output to the file for following R code?
> a <- data.frame(x = rnorm(100), y = runif(100))
> b <- c(3, 4.4, 1 / 3)

Choices:
- save(a, b, file = “mydata.rda”)
- save_image(a, b, file = “mydata.rda”)
- keep(a, b, file = “mydata.rda”)
- keep_image(a, b, file = “mydata.rda”)


Question:
Which of the following extracts first element from the following R vector?
 > x <- c("a", "b", "c", "c", "d", "a")

Choices:
- x[10]
- x[1]
- x[0]
- x[2]


Question:
Which of the following extracts first four element from the following R vector?
 > x <- c("a", "b", "c", "c", "d", "a")

Choices:
- x[0:4]
- x[1:4]
- x[0:3]
- x[4:3]


Question:
What will be the output of the following R code?
> x <- c("a", "b", "c", "c", "d", "a")
> x[c(1, 3, 4)]

Choices:
- “a” “b” “c”
- “a” “c” “c”
- “a” “c” “b”
- “b” “c” “b”


Question:
What will be the output of the following R code?
> x <- matrix(1:6, 2, 3)
> x[1, 2]

Choices:
- 3
- 2
- 1
- 0


Question:
What will be the output of the following R code?
> x <- matrix(1:6, 2, 3)
> x[1, ]

Choices:
- 1 3 5
- 2 3 5
- 3 3 5
- file


Question:
Which of the following R code extracts the second column for the following matrix?
 > x <- matrix(1:6, 2, 3)

Choices:
- x[2, ]
- x[1, 2]
- x[, 2]
- x[1 1 2]


Question:
Which of the following extracts first element from the following R list?
 > x <- list(foo = 1:4, bar = 0.6)

Choices:
- x[[1]]
- x[1]
- x[[0]]
- x[0]


Question:
What will be the output of the following R code?
> x <- list(foo = 1:4, bar = 0.6, baz = "hello")
> name <- "foo"
> x$name

Choices:
- 1
- 2
- 3
- NULL


Question:
What will be the output of the following R code?
> x <- list(foo = 1:4, bar = 0.6, baz = "hello")
> name <- "foo"
> x[[name]]

Choices:
- 1 2 3 4
- 0 1 2 3
- 1 2 3 4 5
- All of the mentioned


Question:
What will be the output of the following R code?
> x <- list(a = list(10, 12, 14), b = c(3.14, 2.81))
> x[[c(1, 3)]]

Choices:
- 13
- 14
- 15
- 18


Question:
What will be the output of the following R code?
> x <- list(aardvark = 1:5)
> x$a

Choices:
- 1 2 3 4 5
- 2 3 5
- 1 3 3 5
- 1 2 3


Question:
Which of the following code extracts 1st element of the 2nd element?
 > x <- list(a = list(10, 12, 14), b = c(3.14, 2.81))

Choices:
- x[[c(2, 1)]]
- x[[c(1, 2)]]
- x[[c(2, 1,1)]]
- x[[(2, 2,1)]]


Question:
What will be the output of the following R code?
> x <- list(aardvark = 1:5)
> x[["a", exact = FALSE]]

Choices:
- 1 2 3 4 5
- 2 3 5
- 1 3 3 5
- 1 2 3


Question:
What will be the output of the following R code?
> x <- c(1, 2, NA, 4, NA, 5)
> bad <- is.na(x)
> print(bad)

Choices:
- FALSE FALSE FALSE FALSE TRUE FALSE
- FALSE TRUE TRUE FALSE TRUE FALSE
- FALSE FALSE TRUE FALSE TRUE FALSE
- FALSE TRUE TRUE TRUE TRUE FALSE


Question:
Which of the following is example of vectorized operation as far as subtraction is concerned?
> x <- 1:4
> y <- 6:9

Choices:
- x+y
- x-y
- x/y
- x–y


Question:
What will be the output of the following R code?
> x <- 1:4
> y <- 6:9
> z <- x + y
> z

Choices:
- 7 9 11 13
- 7 9 11 13 14
- 9 7 11 13
- NULL


Question:
What will be the output of the following R code?
> x <- 1:4
> x > 2

Choices:
- 1 2 3 4
- FALSE FALSE TRUE TRUE
- 1 2 3 4 5
- 5 4 3 1 2 1


Question:
What will be the output of the following R code?
> x <- 1:4
> y <- 6:9
> x/y

Choices:
- 0.1666667 0.2857143 0.4444444
- 0.1666667 0.2857143 0.3750000 0.4444444
- 0.2857143 0.3750000 0.4444444
- Error


Question:
What will be the output of the following R code?
> x <- as.Date("1970-01-01")
> x

Choices:
- “1970-01-01”
- “1970-01-02”
- “1970-02-01”
- “1970-02-02”


Question:
What will be the output of the following R code?
> x <- Sys.time()
> class(x)

Choices:
- “POSIXct” “POSIXt”
- “POSIXXt” “POSIXt”
- “POSIXct” “POSIct”
- “POSIXt” “POSIXt”


Question:
What will be the output of the following R code?
> p <- as.POSIXlt(x)
> names(unclass(p))
> p$wday

Choices:
- 1
- 2
- 3
- NULL


Question:
What will be the output of the following R code?
> datestring <- c("January 10, 2012 10:40", "December 9, 2011 9:10")
> x <- strptime(datestring, "%B %d, %Y %H:%M")
> x

Choices:
- “2012-01-10 10:40:00 EST” “2011-12-09 09:10:00 EST”
- “2012-01-10 10:40:00 IST” “2011-12-09 09:10:00 IST”
- “2012-01-10 10:40:00 GMT” “2011-12-09 09:10:00 GMT”
- Error


Question:
What will be the output of the following R code?
> x <- as.Date("2012-01-01")
> y <- strptime("9 Jan 2011 11:34:21", "%d %b %Y %H:%M:%S")
> x-y

Choices:
- Time difference of 356.3095 days
- Warning
- NULL
- Error


Question:
What will be the output of the following R code?
> x <- as.Date("2012-03-01")
> y <- as.Date("2012-02-28")
> x-y

Choices:
- Time difference of 3 days
- Time difference of 2 days
- Time difference of 1 days
- Time difference of 5 days


Question:
What will be the output of the following R code?
> x <- as.POSIXct("2012-10-25 01:00:00")
> y <- as.POSIXct("2012-10-25 06:00:00", tz = "GMT")
> y-x

Choices:
- Time difference of 1 hour
- Time difference of 1 min
- Time difference of 1 sec
- Time difference of 5 sec


Question:
What will be the output of the following R code?
> x <- 3
> switch(x, 2+2, mean(1:10), rnorm(5))

Choices:
- 2.2903605  2.3271663 -0.7060073  1.3622045 -0.2892720
- 5.5
- NULL
- Error


Question:
What will be the output of the following R code?
> x <- 3
> switch(2, 2+2, mean(1:10), rnorm(5))

Choices:
- 5
- 5.5
- NULL
- 58


Question:
What will be the output of the following R code?
> x <- 3
> switch(6, 2+2, mean(1:10), rnorm(5))

Choices:
- 10
- 1
- NULL
- 5


Question:
What will be the output of the following R code?
> y <- "fruit"
> switch(y, fruit = "banana", vegetable = "broccoli", "Neither")

Choices:
- “banana”
- “Neither”
- “broccoli”
- Error


Question:
What will be the output of the following R code?
> centre <- function(x, type) {
+ switch(type,
+        mean = mean(x),
+        median = median(x),
+        trimmed = mean(x, trim = .1))
+ }
> x <- rcauchy(10)
> centre(x, "mean")

Choices:
- 0.8760325
- 0.5360891
- 0.6086504
- gives mean with values depending on rcauchy values


Question:
What will be the output of the following R code?
> f <- function() {
+             ## This is an empty function
+ }
> f()

Choices:
- 0
- No result
- NULL
- 1


Question:
What will be the output of the following R code?
> f <- function() {
+              ## This is an empty function
+ }
> class(f)

Choices:
- “function”
- “class”
- “procedure”
- “system”


Question:
What will be the output of the following R code?
> f <- function(num) {
+ hello <- "Hello, world!\n"
+ for(i in seq_len(num)) {
+                    cat(hello)
+ }
+                    chars <- nchar(hello) * num
+                    chars
+ }
> meaningoflife <- f(3)
> print(meaningoflife)

Choices:
- 32
- 42
- 52
- 46


Question:
What will be the output of the following R code snippet?
 > paste("a", "b", se = ":")

Choices:
- “a+b”
- “a=b”
- “a b :”
- none of the mentioned


Question:
What will be the output of the following R code snippet?
> f <- function(a, b) {
+       a^2
+ }
> f(2)

Choices:
- 4
- 3
- 2
- 5


Question:
What will be the output of the following R code snippet?
 > paste("a", "b", sep = ":")

Choices:
- “a+b”
- “a=b”
- “a:b”
- a*b


Question:
What will be the output of the following R code snippet?
> f <- function(a, b) {
+              print(a)
+              print(b)
+ }
> f(45)

Choices:
- 32
- 42
- 52
- 45


Question:
What would be the value of following R expression?
 log(-1)

Choices:
- Warning in log(-1): NaNs produced
- 1
- Null
- 0


Question:
What will be the output of the following R code?
> printmessage <- function(x) {
+ if(x > 0)
+         print("x is greater than zero")
+ else
+         print("x is less than or equal to zero")
+ invisible(x)
+ }
> printmessage(1)

Choices:
- Error
- Warning
- Messages
- 0


Question:
What will be the output of the following R code?
> printmessage <- function(x) {
+ if(x > 0)
+         print("x is greater than zero")
+ else
+         print("x is less than or equal to zero")
+ invisible(x)
+ }
> printmessage(NA)

Choices:
- Error
- Warning
- Messages
- Null


Question:
What will be the output of the following R code snippet?
> lm <- function(x) { x * x }
> lm

Choices:
- function(x) { x * x }
- func(x) { x * x }
- function(x) { x / x }
- function { x $ x }


Question:
Which of the variable in the following R code is variable?
> f <- function(x, y) {
+            x^2 + y / z
+ }

Choices:
- x
- y
- z
- yy


Question:
What will be the output of the following R code snippet?
> g <- function(x) {
+             a <- 3
+             x+a+y
+          ## 'y' is a free variable
+ }
> g(2)

Choices:
- 9
- 42
- 8
- Error


Question:
What will be the output of the following R code?
function(p) {
          params[!fixed] <- p
          mu <- params[1]
          sigma <- params[2]
## Calculate the Normal density
          a <- -0.5*length(data)*log(2*pi*sigma^2)
          b <- -0.5*sum((data-mu)^2) / (sigma^2)
          -(a + b)
}
> ls(environment(nLL))

Choices:
- “data” “fixed” “param”
- “data” “variable” “params”
- “data” “fixed” “params”
- “data” “param”


Question:
What will be the output of the following R code?
> nLL <- make.NegLogLik(normals, c(FALSE, 2))
> optimize(nLL, c(-1, 3))$minimum

Choices:
- 1.217775
- 2.217775
- 3
- empty


Question:
What will be the output of the following R code?
> nLL <- make.NegLogLik(normals, c(1, FALSE))
> optimize(nLL, c(1e-6, 10))$minimum

Choices:
- 1.217775
- 1.800596
- 3.73424
- empty


Question:
What will be the output of the following R code?
> g <- function(x) {
+               a <- 3
+               x+a+y
+             ## 'y' is a free variable
+ }
> y <- 3
> g(2)

Choices:
- 9
- 42
- 8
- Error


Question:
What will be the output of the following R expression?
  > log(-2.3)

Choices:
- Warning in log(-2.3): NaNs produced
- 1
- Null
- 0


Question:
What will be the output of the following R code?
> printmessage2 <- function(x) {
+                      if(is.na(x))
+                              print("x is a missing value!")
+                      else if(x > 0)
+                              print("x is greater than zero")
+                      else
+                              print("x is less than or equal to zero")
+                      invisible(x)
+ }
> printmessage2(NA)

Choices:
- “x is a missing value!”
- “x is greater than zero”
- “x is less than or equal to zero”
- Error


Question:
What will be the output of the following R code?
> printmessage <- function(x) {
+                      if(x > 0)
+                           print("x is greater than zero")
+                      else
+                           print("x is less than or equal to zero")
+                      invisible(x)
+ }
> printmessage(NA)

Choices:
- Error
- Warning
- Messages
- x is greater than zero


Question:
What will be the output of the following R code?
> mean(x)
  Error in mean(x) : object 'x' not found
> traceback()

Choices:
- 1: mean(x)
- Null
- 0
- 2


Question:
What will be the output of the following R code?
 > pnorm(2)

Choices:
- 0.9772499
- 1.9772499
- 0.6772499
- 2.6772499


Question:
What will be the output of the following R code?
install.packages(c("devtools", "roxygen2"))

Choices:
- Develops the tools
- Exits R studio
- Installs the given packages
- Nothing happens


Question:
What is the output of the given code?
boolean_1 = 77<78
   puts(boolean_1)

Choices:
- Nil
- True
- False
- Error


Question:
What is the output of the given code?
my_string=Ruby
    puts(my_string)

Choices:
- Ruby
- Nil
- Error
- None of the mentioned


Question:
What is the output of the the given code?
 puts "My name is #{Name}"

Choices:
- Error in compilation
- Name variable not defined earlier
- My name is #{Name}
- Undefined Error


Question:
What is the output of the given code?
Ans=Ruby
    puts "#[Ans] is an oop language"

Choices:
- Error, no output
- Ruby is an oop language
- Warning:already initialized constant Ans
- None of the mentioned


Question:
What is the output of the following?
 "Iam learning ruby language".length

Choices:
- 26
- 23
- 20
- 18


Question:
What is the output of the following?
 ruby.reverse

Choices:
- Error in compilation
- ybur
- 4
- Undefined local variable ruby


Question:
What will be the output of the following?
"Eric".irreverse

Choices:
- Eric
- cirE
- undefined method
- None of the mentioned


Question:
What will be the output of the following?
"Ruby".reverse.upcase

Choices:
- RUBY
- ybuR
- YBUR
- YBUr


Question:
What will be the output of the given code?
"I'am learning Ruby Language".length.reverse.upcase

Choices:
- 27
- egaugnal ybuR gninreal ma’I
- ERAUGNAL YBUR GNINREAL MA’I
- Undefined method `reverse’ for 27:Fixnum


Question:
What will be the output of the given code?
"I'am learning Ruby Language".reverse.upcase.length

Choices:
- 27
- egaugnal ybuR gninreal ma’I
- ERAUGNAL YBUR GNINREAL MA’I
- Undefined method `reverse’ for 27:Fixnum


Question:
What will we the output of the given code?
 "I'am Learning RUBY Language".downcase

Choices:
- iam learning ruby language
- i’AM lEARNING ruby lANGUAGE
- “i’am learning ruby language”
- None of the mentioned


Question:
What is the output of given code?
 string="I'am Learning RUBY Language".downcase
    string.upcase

Choices:
- Undefined method
- “I’AM LEARNING RUBY LANGUAGE”
- I’am Learning RUBY Language
- None of the mentioned


Question:
What will be the output of the given code?
"Come let's learn.reverse Ruby.length language".upcase

Choices:
- nreal s’tel emoC 4 LANGUAGE
- Undefined error
- “COME LET’S LEARN.REVERSE RUBY.LENGTH LANGUAGE”
- None of the above


Question:
What will we the output of the given code?
I'am Learning RUBY Language.downcase

Choices:
- iam learning ruby language
- i’AM lEARNING ruby lANGUAGE
- “i’am learning ruby language”
- unterminated string meets end of file


Question:
What is the output of the given code?
"Ruby Language".length
       =begin
       calculate length
       =end

Choices:
- 13
- 13 calculate length
- 12
- None of the mentioned


Question:
What is the output of the given code?
"Ruby Language".length
       = begin
       calculate length
       = end

Choices:
- 13
- 12
- Error
- None of the mentioned


Question:
What is the output of the following?
if 1<2
   print "one is less than two"
   end

Choices:
- One is less than two
- Syntax error
- 1<2
- None of the mentioned


Question:
What is the output of the code?
 if 11<2
   print "Eleven is less than two"
   end
   print "11 is greater"

Choices:
- 11 is greater
- Eleven is less than two
- Eleven is less than two 11 is greater
- None of the mentioned


Question:
What is the output of the given code?
x=1
    if x > 2
    puts "x is greater than 2"
    elsif x <= 2 and x!=0
    puts "x is 1"
    else
    puts "I can't guess the number"
    end

Choices:
- x is greater than 2
- x is 1
- I can’t guess the number
- None of the mentioned


Question:
What is the output of the given code?
if 1>2
   puts "false"
   else
   puts "True"

Choices:
- False
- True
- Syntax error
- None of the mentioned


Question:
What is the output of the code?
 if 1>2
   puts "false"
   end
   else
   puts "True"
   end

Choices:
- False
- True
- Syntax error
- None of the mentioned


Question:
What is the output of the code?
variable=true
   if variable
   puts "true"
   else
   puts "false"
   end

Choices:
- False
- True
- Syntax error
- None of the mentioned


Question:
What is the output of the code?
 variable="true".reverse
   if variable
   puts "true"
   else
   puts "false"
   end

Choices:
- False
- True
- Syntax error
- None of the mentioned


Question:
What is the output of the code?
variable=true
   if !variable
   puts "true"
   else
   puts "false"
   end

Choices:
- False
- True
- Syntax error
- None of the mentioned


Question:
What is the output of the code?
variable="true".length
   if variable
   puts "true"
   else
   puts "false"
   end

Choices:
- False
- True
- Syntax error
- 4


Question:
What is the output of the given code?
 if !true
   print "False"
   elsif !true || true
   print "True"
   end

Choices:
- True
- False
- Syntax eroor
- None of the mentioned


Question:
What is the output of the given code?
variable = false
   if variable
   print "false"
   elsif !variable
   print "true"
   end

Choices:
- False
- True
- Syntax error
- None of the mentioned


Question:
What is the output of the given code?
x=7
   y=9
   if x==y
   print "equal"
   elsif x>y
   print "greater"
   else
   print "less"
   end

Choices:
- equal
- greater
- less
- none of the mentioned


Question:
What is the output of the given code?
a=true
   b=false
   if a && b
   puts "False"
   elsif a || b
   puts "True"
   else
   puts "neither true nor false"
   end

Choices:
- false
- true
- neither true nor false
- none of the mentioned


Question:
What is the output of the given code?
a=10
    b=2
    if a>b
    a=a*b
    puts (a)
    elsif a<b
    a=a*a+b
    puts (a)
    else
    a=a-b
    puts (a)
    end

Choices:
- 20
- 102
- -98
- None of the mentioned


Question:
What is the output of the given code?
x=3
unless x>2
puts "x is less than 2"
else
puts "x is greater than 2"
end

Choices:
- x is greater than 2
- x is less than 2
- 3
- None of the mentioned


Question:
What is the output of the given code?
hungry=false
unless hungry
 print "Not hungry"
else
 print "Hungry"
end

Choices:
- Not hungry
- Hungry
- Syntax error
- None of the mentioned


Question:
What is the output of the given code?
counter=12
unless counter
 print counter+1
else
 print counter+2
end

Choices:
- 13
- 14
- 15
- None of the mentioned


Question:
What is the output of the given code?
unless true && false
print "false"
else
    print "ruby"
end

Choices:
- True
- False
- Nil
- Syntax error


Question:
What is the output of the given code?
print "2 is less than 3" unless 2>3

Choices:
- 2>3
- 2 is less than 3
- Syntax error
- None of the mentioned


Question:
What is the output of the given code?
age =  5
case age
when 0 .. 2
    puts "baby"
when 3 .. 6
    puts "little child"
when 7 .. 12
    puts "child"
when 13 .. 18
    puts "youth"
else
    puts "adult"
end

Choices:
- baby
- adult
- little child
- youth


Question:
What is the output of the given code?
age =  4
case age
puts "baby" when 0 .. 2
puts "little child" when 3 .. 6
puts "child" when 7 .. 12
puts "youth" when 13 .. 18
puts "adult" else
end

Choices:
- adult
- youth
- child
- syntax error


Question:
What is the output of the given code?
l=9
case l
print "ruby" when l==9
print "language" when l==10
end

Choices:
- l==9
- l==10
- Syntax error
- Ruby


Question:
What will the following code evaluate to?
a=9!=10

Choices:
- True
- False
- Syntax error
- None of the mentioned


Question:
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)

Choices:
- True false true false
- True True True False
- False False True True
- None of the mentioned


Question:
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

Choices:
- a and b are same
- Not same
- a==b
- None of the mentioned


Question:
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

Choices:
- a greater than b
- Not greater
- Syntax error
- None of the mentioned


Question:
What is the output of the given code?
if(a==10 && b=9)
    print "true"
else
    print "false"
end

Choices:
- True
- False
- Error
- None of the mentioned


Question:
What is the output of the given code?
counter=1
if counter<=5
    puts (counter)
    counter=counter+1

Choices:
- Syntax error
- 1 2
- 1
- None of the mentioned


Question:
What will be the output of the given code?
boolean_1 = 77 < 78 && 77 < 77
puts boolean_1

Choices:
- True
- False
- Error
- None of the mentioned


Question:
What will be the output of the given code?
 boolean_1 = (3 < 4 || false) && (false || true)
puts boolean_1

Choices:
- True
- False
- Error
- None of the mentioned


Question:
What will be the output of the given code?
 boolean_1 = !(3 < 4 || false) && (false || true)
puts boolean_1

Choices:
- True
- False
- Error
- None of the mentioned


Question:
What will be the output of the given code?
 boolean_1 = 2**3 != 3**2 || true
puts boolean_1

Choices:
- True
- False
- Error
- None of the mentioned


Question:
What will be the output of the given code?
 boolean_1 = false || -10 > -9
puts boolean_1

Choices:
- True
- False
- Error
- None of the mentioned


Question:
What will be the output of the given code?
 boolean_1 = !(700 / 10 == 70)
puts boolean_1

Choices:
- True
- False
- Error
- None of the mentioned


Question:
What will be the output of the given code?
 boolean_1 = !true
puts boolean_1
boolean_2 = !true && !true
puts boolean_2

Choices:
- True True
- False False
- True False
- None of the mentioned


Question:
What will be the output of the given code?
 boolean_2 = !true && (!true || 100 != 5**2)
puts boolean_2

Choices:
- True
- False
- Error
- None of the mentioned


Question:
What is the output of the given code?
counter = 2
while counter < 68
  puts counter
  counter**=2
  end

Choices:
- 2 4 16 64
- 2 4 16
- 2 4 16 256
- None of the mentioned


Question:
What is the output of the given code?
counter = 1
while counter < 11
  puts counter
  counter+=1
  end

Choices:
- 1 2 3 4 5
- 1…10
- 1..10
- None of the mentioned


Question:
What is the output of the given code?
counter = 100
while counter > 0
  puts counter
  counter/=5
  end

Choices:
- 100 20 4
- 100 20 5
- 100..5
- None of the mentioned


Question:
What is the output of the given code?
counter = 100
while counter > 0
  puts counter
  counter-=25
  end

Choices:
- 100 75 50 25
- 100 25 5
- 100..5
- None of the mentioned


Question:
What is the output of the given code?
counter = -50
while counter <0
  puts counter
  counter+=10
  end

Choices:
- 100 75 50 25
- -50 -40 -30 -20 -10
- 100..5
- None of the mentioned


Question:
What is the output of the given code?
a = 22.5
while a >11.5
  puts a
  a-=3.5
  end

Choices:
- 22.5 19.0 15.5 12.0
- 22.5 11.5
- 100..5
- None of the mentioned


Question:
What is the output of the given code?
a = 5
b=10
while a <10 && b<20
  puts a+b
  a+=2
  b+=2
  end

Choices:
- 10 20
- 15 19 23
- 15 16 17 18 19 20
- None of the mentioned


Question:
What is the output of the given code?
a = 5
b=10
while a <10 && b<20
  puts a*b
  a+=2
  b+=2
  end

Choices:
- 10 20
- 15 19 23
- 50 84 126
- None of the mentioned


Question:
What is the output of the given code?
 a= 5
b=10
while a <10 && b<20
  puts a-b
  a+=2
  b+=2
  end

Choices:
- 10 20
- 15 19 23
- -5 -5 -5
- None of the mentioned


Question:
What is the output of the given code?
 a = 5
b=10
while a <10 || b<20
  puts a*b
  a+=2
  b+=2
  end

Choices:
- 10 20
- 50 84 126 176 234
- -5 -5 -5
- None of the mentioned


Question:
What is the output of the given code?
 a = 5
b=10
while (a <10 || b<20)&&true
  puts a*b
  a+=2
  b+=2
  end

Choices:
- 10 20
- 50 84 126 176 234
- -5 -5 -5
- None of the mentioned


Question:
What is the output of the given code?
counter = 1
while counter < 11
  puts counter
  counter = counter + 1
end

Choices:
- Prints the number from 1 to 10
- Prints the number from 1 to 11
- Prints the number from 2 to 10
- Infinite loop


Question:
What is the output of the given code?
counter = true
while counter !=false
  puts counter
end

Choices:
- True
- False
- Syntax error
- Infinite loop


Question:
What is the output of the given code?
i = 0
while i < 5
  puts i
   i=(i+1)**2
end

Choices:
- 1 2 3 4 5
- 0 1 4
- 0 1
- 1 4


Question:
What is the output of the given code?
a=5
b=15
while a&&b
puts a+b
end

Choices:
- 5..15
- 20
- Infinite loop
- 5 15


Question:
What is the output of the given code?
a=5
b=15
while b>a
puts a*(b-a)
while a>b
  a+=1
  b-=1
end
end

Choices:
- 5..15
- 50
- Infinite loop
- 5 50


Question:
What is the output of the given code?
i = 3
while i > 0 do
  print i
  i -= 1
end

Choices:
- 3
- 321
- Infinite loop
- 3 2 1 0


Question:
What is the output of the given code?
i = 50
while i > 25 do
  print 50/i
  i -= 1
end

Choices:
- 50..25
- 50..1
- Infinite loop


Question:
What is the output of the given code?
a = 5
b=10
while a<b do
  puts a*b
  a+=2
  b-=2
  end

Choices:
- 5 10
- 50 56
- Infinite loop
- 5 6 7 8 9 10


Question:
What is the output of the given code?
counter = 1
until counter > 10
  puts counter
counter+=1
  end

Choices:
- 1 2 3 4 5 6 7 8 9 10
- 11 12 13 14 … infinite loop
- 0 1 2 3 4 5 6 7 8 9
- None of the mentioned


Question:
What is the output of the given code?
counter = 0
until counter >= 10
  puts counter
counter+=1
  end

Choices:
- 1 2 3 4 5 6 7 8 9 10
- 11 12 13 14 … infinite loop
- 0 1 2 3 4 5 6 7 8 9
- None of the mentioned


Question:
What is the output of the given code?
i = 3
while i > 0 do
  puts i
  i -= 1
end

j = 3
until j == 0 do
  puts j
  j -= 1
end

Choices:
- 1 2 3 1 2 3
- 3 2 1 3 2 1
- 0 1 2 3 4 5 6 7 8 9
- None of the mentioned


Question:
What is the output of the given code?
a="hungry"
until !a
puts "hungry"
a=!a
end

Choices:
- hungry
- Nil
- Error
- None of the mentioned


Question:
What is the output of the given code?
m= 8
loop do
    m += 2
    puts m
    break if m == 16
end

Choices:
- 10 12 14 16
- Nil
- Error
- None of the mentioned


Question:
What is the output of the given code?
m=0
loop do
    print "ruby"
    m+=1
    break if m==5
end

Choices:
- rubyrubyrubyrubyrubyruby
- rubyrubyrubyrubyruby
- Error
- None of the mentioned


Question:
What is the output of the given code?
m=0
loop do
    puts m*10
    m+=1
    break if m==5
end

Choices:
- 0 10 20 30 40
- 10 20 30 40 50
- Error
- None of the mentioned


Question:
What is the output of the given code?
m=0
loop do
    puts 101
    m+=1
    break if m==5
end

Choices:
- 101 101 101 101 101
- 10 20 30 40 50
- Error
- None of the mentioned


Question:
What is the output of the given code?
m=5
loop do
    m-=1
    break if m==0
end

Choices:
- 1 2 3 4 5
- 10 20 30 40 50
- Error
- Nil


Question:
What is the output of the given code?
for num in 1...5
  puts num
end

Choices:
- 1 2 3 4 5
- 1 2 3 4
- 2 3 4 5
- None of the mentioned


Question:
What is the output of the given code?
for num in 1..3
  puts num
  for i in 1..2
  puts num*i
  end
end

Choices:
- 1 2 3 4 5
- 1 1 2 2 2 4 3 3 6
- 2 3 4 5
- None of the mentioned


Question:
What is the output of the given code?
m= 0
loop do
    m += 1
    print m
    break if m == 10
end

Choices:
- 12345678910
- 1 2 3 4
- 2 3 4 5
- None of the mentioned


Question:
What is the output of the given code?
for num in 1..5
  puts num*num
end

Choices:
- 12345678910
- 1 2 3 4
- 1 4 9 16 25
- None of the mentioned


Question:
What is the output of the given code?
for num in 1..3
  puts num*num
  m= 0
loop do
    m += 1
    puts m
    break if m == 3
end
end

Choices:
- 12345678910
- 1 1 2 3 4 1 2 3 9 1 2 3
- 1 4 9 16 25
- None of the mentioned


Question:
What is the output of the given code?
loop do
    m += 1
    puts m
    break if m == 3
end

Choices:
- Garbage values
- 1 1 2 3 4 1 2 3 9 1 2 3
- 1 4 9 16 25
- None of the mentioned


Question:
What is the output of the given code?
i=1
for i in 5..10
puts i^2
end

Choices:
- 7 4 5 10 11 8
- 25 36 49 64 81 100
- 1 4 9 16 25
- None of the mentioned


Question:
What is the output of the given code?
i=5
j=10
for i in 5..10 && j in 5..10
puts i**j
end

Choices:
- Syntax error
- 25 36 49 64 81 100
- 1 4 9 16 25
- None of the mentioned


Question:
What will be output of the given code?
my_array = [1, 2, 3, 4]
print my_array

Choices:
- [1, 2, 3, 4].
- 1234
- Error
- None of the mentioned


Question:
What will be the output of the following?
array = [100, 200, 300, 400, 500]
print array[4]

Choices:
- 400
- 500
- Nil
- None of the mentioned


Question:
What will be the output of the following?
array = [100, 200, 300, 400, 500]
print array[5]

Choices:
- 400
- 500
- Nil
- None of the mentioned


Question:
What will be the output of the following?
array = [100, 200, 300, 400, 500]
print "array[5]"

Choices:
- array[5].
- 500
- Nil
- None of the mentioned


Question:
What will be the output of the following?
array1 = [100, 200, 300, 400, 500]
array2 = [1,2,3,4,5]
if array1 == array2
print "They are equal"
else
    print "Not equal"
end

Choices:
- They are equal
- Not equal
- Nil
- None of the mentioned


Question:
What will be the output of the following?
array1 = [0,0,0]
array2 = [0,0,0]
if array1 == array2
print "They are equal"
else
    print "Not equal"
end

Choices:
- They are equal
- Not equal
- Nil
- None of the mentioned


Question:
What will be the output of the following?
array1 = [1,2,3]
array2 = [0,0,0]
if array1 >= array2
print "Greater or equal"
else
    print "Not equal"
end

Choices:
- Greater or equal
- Not equal
- Error
- None of the mentioned


Question:
What will be the output of the following?
array1 = [1,2,3]
array2 = [0,0,0]
if array1 == array2
print "Equal"
else
    print "Not equal"
end

Choices:
- Equal
- Not equal
- Error
- None of the mentioned


Question:
What is the output of the given code?
string_array = ["a","e","i","o","u"]
print string_array

Choices:
- [“a”,”e”,”i”,”o”,”u”].
- Error
- Vowels
- None of the mentioned


Question:
What is the output of the given code?
string_array = ["a","e","i","o","u"]
print string_array[3]

Choices:
- [“a”,”e”,”i”,”o”,”u”].
- Error
- o
- None of the mentioned


Question:
What is the output of the given code?
a=[1,2,3,4,5]
b=[1,2,4,6,8]
if a[3]==b[2]
    print "Equal"
end

Choices:
- Equal
- Error
- 4
- None of the mentioned


Question:
What is the output of the given code?
a=[1,2,3,4,5]
b=[1,2,3,4,5]
if a==b
    print "Equal"
else
    print "Not equal"
end

Choices:
- Equal
- Error
- Not equal
- None of the mentioned


Question:
What is the output of the given code?
a=["hey", "ruby", "language"]
b=["hey", "ruby", "language"]
if a==b
    print "Equal"
else
    print "Not equal"
end

Choices:
- Equal
- Error
- Not equal
- None of the mentioned


Question:
What is the output of the given code?
a=["hey", "ruby", "language"]
b=["hey", "language", "ruby"]
if a==b
    print "Equal"
else
    print "Not equal"
end

Choices:
- Equal
- Error
- Not equal
- None of the mentioned


Question:
What is the output of the given code?
multi_d_array = [[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0]]
print multi_d_array

Choices:
- [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]].
- [0, 0, 0, 0].
- [0, 0, 0, 0][0, 0, 0, 0].
- None of the mentioned


Question:
What is the output of the given code?
array1 = [[1,2,3,4],[0,0,0,0]]
array2 = [[1,2,3],[0,0,0,0]]
if array1==array2
    print "Equal"
else
    print "Not equal"
end

Choices:
- [[1, 2, 3, 4], [0, 0, 0, 0]].
- Equal
- Not equal
- None of the mentioned


Question:
What is the output of the given code?
array1 = [[1,2,3,4],[0,0,0,0]]
array2 = [[1,2,3,4],[0,0,0,0]]
if array1==array2
    print "Equal"
else
    print "Not equal"
end

Choices:
- [[1, 2, 3, 4], [0, 0, 0, 0]].
- Equal
- Not equal
- None of the mentioned


Question:
What is the output of the given code?
array1 = [[1,2,3,4],[0,0,0,0]]
array2 = [[1,2,3,4],[0,0,0,0]]
print array1+array2

Choices:
- [[1, 2, 3, 4], [0, 0, 0, 0]].
- [[1, 2, 3, 4], [0, 0, 0, 0], [1, 2, 3, 4], [0, 0, 0, 0]].
- [[2,4,6,8],[0,0,0,0]].
- None of the mentioned


Question:
What is the output of the given code?
array1 = [[1,2,3,4],[0,0,0,0]]
array2 = [[1,2,3,4],[0,0,0,0]]
print array1-array2

Choices:
- [[1, 2, 3, 4], [0, 0, 0, 0]].
- [[1, 2, 3, 4], [0, 0, 0, 0], [1, 2, 3, 4], [0, 0, 0, 0]].
- None of the mentioned


Question:
What is the output of the given code?
array1 = [[1,2,3,4],[0,0,0,0]]
array2 = [[1,2,3,4],[0,0,0,0]]
print array1*array2

Choices:
- [[1, 2, 3, 4], [0, 0, 0, 0]].
- [[1, 2, 3, 4], [0, 0, 0, 0], [1, 2, 3, 4], [0, 0, 0, 0]].
- Error


Question:
What is the output of the given code?
array1 = [[1,2,3,4],[0,0,0,0]]
array2 = [[1,2,3],[0,0,0]]
print array1 && array2

Choices:
- [[1, 2, 3], [0, 0, 0]].
- [[1, 2, 3, 4], [0, 0, 0, 0], [1, 2, 3, 4], [0, 0, 0, 0]].
- Error


Question:
What is the output of the given code?
array1 = [[1,2,3,4,5],[0,0,0,0]]
array2 = [[1,2,3],[0,0,0]]
print array1 || array2

Choices:
- [[1, 2, 3], [0, 0, 0]].
- [[1, 2, 3, 4, 5], [0, 0, 0, 0]].
- Error


Question:
What is the output of the given code?
array1 = [[1,2,3,4,5],[0,0,0,0]]
array2 = [[1,2,3],[0,0,0]]
print !array1

Choices:
- [[1, 2, 3], [0, 0, 0]].
- [[1, 2, 3, 4, 5], [0, 0, 0, 0]].
- False
- Error


Question:
What is the output of the given code?
a=[["a","b"]]
b=[["e","a"]]
print a + b

Choices:
- [[“a”, “b”], [“e”, “a”]].
- [[“2a”, “b”], [“e”]].
- False
- Error


Question:
What is the output of the given code?
string_array = ["a","e","i","o","u"]
print string_array

Choices:
- [“a”,”e”,”i”,”o”,”u”].
- Error
- Vowels
- None of the mentioned


Question:
What is the output of the given code?
string_array = ["a","e","i","o","u"]
print string_array[3]

Choices:
- [“a”,”e”,”i”,”o”,”u”].
- Error
- o
- None of the mentioned


Question:
What is the output of the given code?
a=[1,2,3,4,5]
b=[1,2,4,6,8]
if a[3]==b[2]
    print "Equal"
end

Choices:
- Equal
- Error
- 4
- None of the mentioned


Question:
What is the output of the given code?
a=[1,2,3,4,5]
b=[1,2,3,4,5]
if a==b
    print "Equal"
else
    print "Not equal"
end

Choices:
- Equal
- Error
- Not equal
- None of the mentioned


Question:
What is the output of the given code?
a=["hey", "ruby", "language"]
b=["hey", "ruby", "language"]
if a==b
    print "Equal"
else
    print "Not equal"
end

Choices:
- Equal
- Error
- Not equal
- None of the mentioned


Question:
What is the output of the given code?
a=["hey", "ruby", "language"]
b=["hey", "language", "ruby"]
if a==b
    print "Equal"
else
    print "Not equal"
end

Choices:
- Equal
- Error
- Not equal
- None of the mentioned


Question: What is the correct HTML for referring to an external style sheet?

Choices:
- <style src="mystyle.css">
- <stylesheet>mystyle.css</stylesheet>
- <link rel="stylesheet" type="text/css" href="mystyle.css">


Question: Where in an HTML document is the correct place to refer to an external style sheet?

Choices:
- In the <body> section
- In the <head> section
- At the end of the document


Question: What does CSS stand for?

Choices:
- Creative Style Sheets
- Computer Style Sheets
- Cascading Style Sheets
- Colorful Style Sheets


Question: How do you select all p elements inside a div element?

Choices:
- div p
- div + p
- div.p


Question: How do you select elements with class name 'test'?

Choices:
- .test
- test
- #test
- *test


Question: How do you select an element with id 'demo'?

Choices:
- *demo
- #demo
- .demo
- demo


Question: How do you make a list that lists its items with squares?

Choices:
- list-type: square;
- list-style-type: square;
- list: square;


Question: When using the padding property; are you allowed to use negative values?

Choices:
- No
- Yes


Question: Which property is used to change the left margin of an element?

Choices:
- indent
- padding-left
- margin-left


Question: How do you display a border like this:The top border = 10 pixelsThe bottom border = 5 pixelsThe left border = 20 pixelsThe right border = 1pixel?

Choices:
- border-width:5px 20px 10px 1px;
- border-width:10px 1px 5px 20px;
- border-width:10px 5px 20px 1px;
- border-width:10px 20px 5px 1px;


Question: How do you make the text bold?

Choices:
- style:bold;
- font-weight:bold;
- font:bold;


Question: Which property is used to change the font of an element?

Choices:
- font-family
- font-style
- font-weight


Question: How do you group selectors?

Choices:
- Separate each selector with a plus sign
- Separate each selector with a space
- Separate each selector with a comma


Question: How do you display hyperlinks without an underline?

Choices:
- a {text-decoration:none;}
- a {decoration:no-underline;}
- a {underline:none;}
- a {text-decoration:no-underline;}


Question: How do you make each word in a text start with a capital letter?

Choices:
- You can't do that with CSS
- transform:capitalize
- text-style:capitalize
- text-transform:capitalize


Question: Which HTML attribute is used to define inline styles?

Choices:
- styles
- class
- font
- style


Question: Which is the correct CSS syntax?

Choices:
- body:color=black;
- {body:color=black;}
- body {color: black;}
- {body;color:black;}


Question: How do you insert a comment in a CSS file?

Choices:
- // this is a comment
- /* this is a comment */
- ' this is a comment
- // this is a comment //


Question: Which HTML tag is used to define an internal style sheet?

Choices:
- <style>
- <css>
- <script>


Question: How do you add a background color for all <h1> elements?

Choices:
- all.h1 {background-color:#FFFFFF;}
- h1.all {background-color:#FFFFFF;}
- h1 {background-color:#FFFFFF;}


Question: Which CSS property is used to change the text color of an element?

Choices:
- color
- fgcolor
- text-color


Question: Which CSS property controls the text size?

Choices:
- text-style
- font-size
- font-style
- text-size


Question: What is the correct CSS syntax for making all the <p> elements bold?

Choices:
- p {text-size:bold;}
- <p style="text-size:bold;">
- <p style="font-size:bold;">
- p {font-weight:bold;}


Question: Which property is used to change the background color?

Choices:
- bgcolor
- color
- background-color


Question: An <iframe> is used to display a web page within a web page.

Choices:
- False
- True
- There is no such thing as an <iframe>


Question: In HTML, you can embed SVG elements directly into an HTML page.

Choices:
- False
- True


Question: Block elements are normally displayed without starting a new line.

Choices:
- False
- True


Question: Which HTML element defines the title of a document?

Choices:
- <head>
- <meta>
- <title>


Question: Which HTML attribute specifies an alternate text for an image, if the image cannot be displayed?

Choices:
- longdesc
- src
- alt
- title


Question: Which doctype is correct for HTML5?

Choices:
- <!DOCTYPE HTML5>
- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 5.0//EN" "http://www.w3.org/TR/html5/strict.dtd">
- <!DOCTYPE html>


Question: Which HTML element is used to specify a footer for a document or section?

Choices:
- <footer>
- <section>
- <bottom>


Question: HTML comments start with <!-- and end with -->

Choices:
- True
- False


Question: The HTML <canvas> element is used to:

Choices:
- manipulate data in MySQL
- create draggable elements
- display database records
- draw graphics


Question: The HTML global attribute, "contenteditable" is used to:

Choices:
- Return the position of the first found occurrence of content inside a string
- Update content from the server
- Specifies a context menu for an element. The menu appears when a user right-clicks on the element
- Specify whether the content of an element should be editable or not


Question: In HTML, onblur and onfocus are:

Choices:
- HTML elements
- Event attributes
- Style attributes


Question: Graphics defined by SVG is in which format?

Choices:
- CSS
- XML
- HTML


Question: In HTML, which attribute is used to specify that an input field must be filled out?

Choices:
- validate
- required
- formvalidate
- placeholder


Question: Which input type defines a slider control?

Choices:
- range
- controls
- search
- slider


Question: Which HTML element is used to display a scalar measurement within a range?

Choices:
- <measure>
- <meter>
- <range>
- <gauge>


Question: Which HTML element defines navigation links?

Choices:
- <nav>
- <navigation>
- <navigate>


Question: In HTML, what does the <aside> element define?

Choices:
- The ASCII character-set; to send information between computers on the Internet
- Content aside from the page content
- A navigation list to be shown at the left side of the page


Question: What is the correct HTML for inserting a background image?

Choices:
- <background img="background.gif">
- <body style="background-image:url(background.gif)">
- <body bg="background.gif">


Question: What is the correct HTML element for playing audio files?

Choices:
- <mp3>
- <sound>
- <audio>


Question: What is the correct HTML for inserting an image?

Choices:
- <img src="image.gif" alt="MyImage">
- image.gif
- <img href="image.gif" alt="MyImage">
- <image src="image.gif" alt="MyImage">


Question: What is the correct HTML element for playing video files?

Choices:
- <video>
- <movie>
- <media>


Question: What is the correct HTML for making a drop-down list?

Choices:
- <select>
- <input type="dropdown">
- <input type="list">
- <list>


Question: What is the correct HTML for making a text area?

Choices:
- <input type="textbox">
- <input type="textarea">
- <textarea>


Question: What does HTML stand for?

Choices:
- Hyper Text Markup Language
- Hyperlinks and Text Markup Language
- Home Tool Markup Language


Question: Who is making the Web standards?

Choices:
- Mozilla
- Microsoft
- The World Wide Web Consortium
- Google


Question: Choose the correct HTML element for the largest heading:

Choices:
- <heading>
- <head>
- <h6>
- <h1>


Question: What is the correct HTML for adding a background color?

Choices:
- <body bg="yellow">
- <body style="background-color:yellow;">
- <background>yellow</background>


Question: Choose the correct HTML element to define important text

Choices:
- <i>
- <strong>
- <b>
- <important>


Question: Choose the correct HTML element to define emphasized text

Choices:
- <em>
- <italic>
- <i>


Question: What is the correct HTML for creating a hyperlink?

Choices:
- W3Schools
- W3Schools.com
- W3Schools.com


Question: What is the correct HTML element for inserting a line break?

Choices:
- <break>
- <br>
- <lb>


Question: How can you open a link in a new tab/browser window?

Choices:
- <a href="url" new>
- <a href="url" target="_blank">
- <a href="url" target="new">


Question: What is the correct HTML for making a text input field?

Choices:
- <input type="text">
- <textfield>
- <input type="textfield">
- <textinput type="text">


Question: Which character is used to indicate an end tag?


Question: How can you make a bulleted list?

Choices:
- <ol>
- <list>
- <ul>
- <dl>


Question: What is the correct HTML for making a checkbox?

Choices:
- <check>
- <input type="check">
- <checkbox>
- <input type="checkbox">


Question: Inline elements are normally displayed without starting a new line.

Choices:
- True
- False


Question: Which of these elements are all <table> elements?

Choices:
- <tt>
- <thead><body><tr>
- <table><head><tfoot>


Question: How can you make a numbered list?

Choices:
- <list>
- <ul>
- <dl>
- <ol>


Question: How can you add a comment in a JavaScript?

Choices:
- //This is a comment
- <!--This is a comment-->
- 'This is a comment


Question: How can you detect the client's browser name?

Choices:
- navigator.appName
- browser.name
- client.navName


Question: JavaScript is the same as Java.

Choices:
- False
- True


Question: What is the correct JavaScript syntax for opening a new window called "w2" ?

Choices:
- w2 = window.new("http://www.w3schools.com");
- w2 = window.open("http://www.w3schools.com");


Question: How do you find the number with the highest value of x and y?

Choices:
- top(x, y)
- ceil(x, y)
- Math.max(x, y)
- Math.ceil(x, y)


Question: How do you round the number 7.25, to the nearest integer?

Choices:
- Math.rnd(7.25)
- rnd(7.25)
- round(7.25)
- Math.round(7.25)


Question: What is the correct way to write a JavaScript array?

Choices:
- var colors = (1:"red", 2:"green", 3:"blue")
- var colors = ["red", "green", "blue"]
- var colors = "red", "green", "blue"
- var colors = 1 = ("red"), 2 = ("green"), 3 = ("blue")


Question: How to insert a comment that has more than one line?

Choices:
- <!--This comment hasmore than one line-->
- /*This comment hasmore than one line*/
- //This comment hasmore than one line//


Question: How does a FOR loop start?

Choices:
- for (i = 0; i <= 5)
- for i = 1 to 5
- for (i = 0; i <= 5; i++)
- for (i <= 5; i++)


Question: What is the correct syntax for referring to an external script called "xxx.js"?

Choices:
- <script name="xxx.js">
- <script href="xxx.js">
- <script src="xxx.js">


Question: How to write an IF statement for executing some code if "i" is NOT equal to 5?

Choices:
- if (i != 5)
- if i =! 5 then
- if i <> 5
- if (i <> 5)


Question: How to write an IF statement in JavaScript?

Choices:
- if i = 5
- if i = 5 then
- if i == 5 then
- if (i == 5)


Question: How do you call a function named "myFunction"?

Choices:
- call myFunction()
- myFunction()
- call function myFunction()


Question: How do you create a function in JavaScript?

Choices:
- function:myFunction()
- function myFunction()
- function = myFunction()


Question: How do you write "Hello World" in an alert box?

Choices:
- alert("Hello World");
- alertBox("Hello World");
- msgBox("Hello World");
- msg("Hello World");


Question: The external JavaScript file must contain the <script> tag.

Choices:
- True
- False


Question: Which event occurs when the user clicks on an HTML element?

Choices:
- onmouseover
- onchange
- onmouseclick
- onclick


Question: Where is the correct place to insert a JavaScript?

Choices:
- The <head> section
- The <body> section
- Both the <head> section and the <body> section are correct


Question:
What is the correct JavaScript syntax to change the content of the HTML element below?
This is a demonstration.

Choices:
- #demo.innerHTML = "Hello World!";
- document.getElement("p").innerHTML = "Hello World!";
- document.getElementById("demo").innerHTML = "Hello World!";
- document.getElementByName("p").innerHTML = "Hello World!";


Question: How does a WHILE loop start?

Choices:
- while (i <= 10)
- while (i <= 10; i++)
- while i = 1 to 10


Question: How do you declare a JavaScript variable?

Choices:
- v carName;
- var carName;
- variable carName;


Question: Inside which HTML element do we put the JavaScript?

Choices:
- <js>
- <scripting>
- <javascript>
- <script>


Question: What will the following code return: Boolean(10 > 9)

Choices:
- true
- NaN
- false


Question: Which operator is used to assign a value to a variable?

Choices:
- x


Question: Which keyword is used to declare a function?

Choices:
- decl
- define
- function
- fun


Question: What is the correct way to create an object called myObj of MyClass?

Choices:
- MyClass.new myObj
- Main myObj = new MyClass();
- val myObj = MyClass()


Question: In Kotlin, it is possible to inherit class properties and functions from one class to another.

Choices:
- True
- False


Question: Which keyword is used to create a class in Kotlin?

Choices:
- class
- className
- MyClass
- class()


Question: Which statement is used to stop a loop?

Choices:
- exit
- break
- void
- stop


Question: How can you create a range of numbers between 5 and 15 in Kotlin?

Choices:
- for (x in 5 to 15)
- for (5..15)
- for (x in 5..15)
- for (5 to 15)


Question: How do you start writing a for loop in Kotlin, to loop through arrays?

Choices:
- for (x in y)
- for x in y
- for x
- for (x)


Question: Which keyword is used to return a value inside a function?

Choices:
- get
- break
- return
- void


Question: How do you start writing a while loop in Kotlin?

Choices:
- if x > y while
- while x < y then
- while (x < y)
- while x < y


Question: How do you start writing an if statement in Kotlin?

Choices:
- if (x > y)
- if x > y
- if x > y()
- if x > y then


Question: How do you call a function in Kotlin?

Choices:
- myFunction()
- myFunction[]
- myFunction;
- (myFunction)


Question: Array indexes start with:

Choices:
- 1
- 0


Question: To create an array in Kotlin, use

Choices:
- None of the above
- The arrayOf() function


Question: Which symbol is used for string templates/interpolation?


Question: Which operator can be used to compare two values?


Question: The value of a string variable must be surrounded by single quotes.

Choices:
- False
- True


Question: What is the output of the following code: println(5 > 3 && 5 < 10)

Choices:
- true
- false
- 2
- 5


Question: Which operator is used to add together two values?

Choices:
- The & sign
- The ADD keyword
- The + sign
- The * sign


Question: How can you create a variable with the floating number 2.8?

Choices:
- val num = 2.8
- float num = 2.8
- num = 2.8 float
- double num = 2.8


Question: How can you create a variable with the numeric value 5?

Choices:
- int num = 5
- num = 5
- val num = 5
- num = 5 int


Question: What is a correct syntax to output "Hello World" in Kotlin?

Choices:
- println("Hello World")
- Console.WriteLine("Hello World");
- cout << "Hello World";
- System.out.printline("Hello World")


Question: How do you insert COMMENTS in Kotlin code?

Choices:
- /* This is a comment
- -- This is a comment
- # This is a comment
- // This is a comment


Question: In Kotlin, code statements must end with a semicolon (;)

Choices:
- True
- False


Question: Which property can be used to find the length of a string?

Choices:
- The sizeof property
- The size property
- The length property
- The len property


Question: What is the correct way to add 1 to the $count variable?

Choices:
- $count =+1
- ++count
- $count++;
- count++;


Question: How do you create an array in PHP?

Choices:
- $cars = "Volvo", "BMW", "Toyota";
- $cars = array("Volvo", "BMW", "Toyota");
- $cars = array["Volvo", "BMW", "Toyota"];


Question: PHP server scripts are surrounded by delimiters, which?

Choices:
- <?php>...</?>
- <script>...</script>
- <?php...?>


Question: How do you write "Hello World" in PHP

Choices:
- "Hello World";
- echo "Hello World";
- Document.Write("Hello World");


Question: All variables in PHP start with which symbol?


Question: What is the correct way to end a PHP statement?

Choices:
- </php>
- New line


Question: The PHP syntax is most similar to:

Choices:
- Perl and C
- VBScript
- JavaScript


Question: How do you get information from a form that is submitted using the "get" method?

Choices:
- Request.QueryString;
- Request.Form;
- $_GET[];


Question: When using the POST method, variables are displayed in the URL:

Choices:
- True
- False


Question: In PHP you can use both single quotes ( ' ' ) and double quotes ( " " ) for strings:

Choices:
- False
- True


Question: Include files must have the file extension ".inc"

Choices:
- False
- True


Question: What is the correct way to include the file "time.inc" ?

Choices:
- <?php include "time.inc"; ?>
- <!-- include file="time.inc" -->
- <?php include:"time.inc"; ?>
- <?php include file="time.inc"; ?>


Question: What does PHP stand for?

Choices:
- PHP: Hypertext Preprocessor
- Private Home Page
- Personal Hypertext Processor


Question: What is the correct way to open the file "time.txt" as readable?

Choices:
- open("time.txt");
- fopen("time.txt","r");
- fopen("time.txt","r+");
- open("time.txt","read");


Question: What is the correct way to create a function in PHP?

Choices:
- function myFunction()
- new_function myFunction()
- create myFunction()


Question: In PHP, the only way to output text is with echo.

Choices:
- False
- True


Question: How do you create a cookie in PHP?

Choices:
- makecookie()
- setcookie()
- createcookie


Question: Which one of these variables has an illegal name?

Choices:
- $my_Var
- $my-Var
- $myVar


Question: The die() and exit() functions do the exact same thing.

Choices:
- True
- False


Question: The if statement is used to execute some code only if a specified condition is true

Choices:
- True
- False


Question: What is a correct way to add a comment in PHP?

Choices:
- <comment>...</comment>


Question: Which superglobal variable holds information about headers, paths, and script locations?

Choices:
- $_SESSION
- $GLOBALS
- $_GET
- $_SERVER


Question: PHP allows you to send emails directly from a script

Choices:
- True
- False


Question: PHP can be run on Microsoft Windows IIS(Internet Information Server):

Choices:
- True
- False


Question: Which collection does not allow duplicate members?

Choices:
- TUPLE
- LIST
- SET


Question: Which collection is ordered, changeable, and allows duplicate members?

Choices:
- LIST
- SET
- TUPLE
- DICTIONARY


Question: Which of these collections defines a DICTIONARY?

Choices:
- {"apple", "banana", "cherry"}
- ("apple", "banana", "cherry")
- ["apple", "banana", "cherry"]
- {"name": "apple", "color": "green"}


Question: Which of these collections defines a SET?

Choices:
- {"apple", "banana", "cherry"}
- {"name": "apple", "color": "green"}
- ["apple", "banana", "cherry"]
- ("apple", "banana", "cherry")


Question: Which of these collections defines a TUPLE?

Choices:
- ["apple", "banana", "cherry"]
- {"name": "apple", "color": "green"}
- {"apple", "banana", "cherry"}
- ("apple", "banana", "cherry")


Question: Which of these collections defines a LIST?

Choices:
- {"apple", "banana", "cherry"}
- ("apple", "banana", "cherry")
- {"name": "apple", "color": "green"}
- ["apple", "banana", "cherry"]


Question: Which operator can be used to compare two values?


Question: Which operator is used to multiply numbers?

Choices:
- x


Question: Which method can be used to replace parts of a string?

Choices:
- repl()
- replaceString()
- replace()
- switch()


Question: Which method can be used to return a string in upper case letters?

Choices:
- upper()
- upperCase()
- uppercase()
- toUpperCase()


Question: What is a correct syntax to return the first character in a string?

Choices:
- x = sub("Hello", 0, 1)
- x = "Hello".sub(0, 1)
- x = "Hello"[0]


Question: In Python, 'Hello', is the same as "Hello"

Choices:
- False
- True


Question: What is the correct way to create a function in Python?

Choices:
- create myFunction():
- def myFunction():
- function myfunction():


Question: How do you create a variable with the floating number 2.8?

Choices:
- Both the other answers are correct
- x = 2.8
- x = float(2.8)


Question: What is the correct file extension for Python files?

Choices:
- .py
- .pyt
- .pt
- .pyth


Question: How do you create a variable with the numeric value 5?

Choices:
- Both the other answers are correct
- x = 5
- x = int(5)


Question: Which one is NOT a legal variable name?

Choices:
- my_var
- Myvar
- _myvar
- my-var


Question: How do you insert COMMENTS in Python code?

Choices:
- //This is a comment
- /*This is a comment*/
- #This is a comment


Question: How do you start writing an if statement in Python?

Choices:
- if x > y:
- if x > y then:
- if (x > y)


Question: What is a correct syntax to output "Hello World" in Python?

Choices:
- p("Hello World")
- echo("Hello World");
- echo "Hello World"
- print("Hello World")


Question: Which method can be used to remove any whitespace from both the beginning and the end of a string?

Choices:
- strip()
- trim()
- len()
- ptrim()


Question: What is the correct syntax to output the type of a variable or object in Python?

Choices:
- print(typeof(x))
- print(typeOf(x))
- print(type(x))
- print(typeof x)


Question: How do you start writing a while loop in Python?

Choices:
- while x > y:
- while (x > y)
- while x > y {
- x > y while {


Question: How do you start writing a for loop in Python?

Choices:
- for each x in y:
- for x in y:
- for x > y:


Question: Which function is used to find the amount of rows and columns in an array?

Choices:
- nchar()
- dim_len()
- dim()
- length()


Question: How do you start writing a while loop in R?

Choices:
- while x < y
- while (x < y)
- while x < y:
- x < y while


Question: What is a correct syntax to output "Hello World" in R?

Choices:
- All of the other answers are correct
- 'Hello World'
- print("Hello World")
- "Hello World"


Question: R is an alias of React

Choices:
- False
- True


Question: How do you insert COMMENTS in R code?

Choices:
- # This is a comment
- /* This is a comment
- // This is a comment


Question: In R, you must declare the data type of a variable

Choices:
- True
- False


Question: How do you create a variable named x with the numeric value 5?

Choices:
- x <- 5
- x : 5
- int x = 5


Question: How can you assign the same value to multiple variables in one line?

Choices:
- var1, var2, var3 = "Orange"
- var1 <- var2 <- var3 <- "Orange"
- var1, var2, var3 <- "Orange"


Question: Which operator is used to add together two values?

Choices:
- The & sign
- The + sign
- The * sign


Question: The value of a string variable can be surrounded by single quotes.

Choices:
- True
- False


Question: The following values: 10.5, 55 and 787, belongs to which data type?

Choices:
- numeric
- integer
- complex


Question: Which function is often used to concatenate elements?

Choices:
- merge()
- concat()
- join()
- paste()


Question: Which function can be used to return the square root of a number?

Choices:
- sr()
- sqroot()
- sqrt()
- square_root()


Question: Which operator can be used to compare two values?


Question: Which function is used to add additional columns in a matrix?

Choices:
- join()
- add()
- cbind()
- append_item()


Question: Which function is used to draw points (markers) in a diagram?

Choices:
- draw()
- canvas()
- d()
- plot()


Question: Which function can be used to create a data frame?

Choices:
- dframe()
- data.frame()
- dataframe()
- df()


Question: What is the correct way to create a list of strings?

Choices:
- fruits <- list("banana", "apple", "orange")
- fruits <- vectorOf("banana", "apple", "orange")
- fruits <- c("banana", "apple", "orange")
- fruits <- v("banana", "apple", "orange")


Question: How do you start writing an if statement in R?

Choices:
- if (x > y)
- if x > y then:
- if x > y:


Question: Consider the following code: for (x 1:10). Which keyword is missing inside the for loop to output the numbers 1 to 10?

Choices:
- seq
- in
- list
- inside


Question: How do you call a function in R?

Choices:
- my_function()
- (my_function);
- my_function;
- my_function[]


Question: How do you create a function in R?

Choices:
- my_function <- function.
- my_function <- function()
- my_function <- function[]


Question: What will the following function do with the str string: nchar(str)

Choices:
- Add spaces to each word inside the str string
- Find the number of characters in the str string
- Add a new line for each word inside the str string
- Insert an escape character before the str string


Question: What is the correct way to create a vector of strings?

Choices:
- fruits <- c("banana", "apple", "orange")
- fruits <- listOf("banana", "apple", "orange")
- fruits <- v("banana", "apple", "orange")
- fruits <- list("banana", "apple", "orange")


Question: True or False: Interfaces are similar to type aliases, but only for object types?

Choices:
- True
- False


Question: Access modifiers control the ______ of properties and methods.

Choices:
- visibility
- inheritance
- mocking
- type


Question: _____ is a return type for when nothing is returned.

Choices:
- any[]
- void
- unknown
- any


Question: What is the type of the parameter: `function ex(param1?: string){}`?

Choices:
- unknown
- string
- string | undefined
- string | null


Question: Definitely Typed is...

Choices:
- a superset of TypeScript
- a project whose goal is to make types dynamic
- a project that provides a central repository of TypeScript definitions for NPM packages which do not have types
- the official name of TypeScript


Question: True or False: Generics can not be assigned default values.

Choices:
- True
- False


Question: True or False: 'keyof' can be used with index signatures to extract the index type.

Choices:
- False
- True


Question: Numeric enums first value is defaulted to what?

Choices:
- 10
- 0
- 5
- 1


Question: What are the two types of enums?

Choices:
- Number and Boolean
- Number and Number Array
- String and Number
- String and Boolean


Question: ________ an interface will have the same properties as that interface.

Choices:
- Extending
- Idolizing
- Improving
- Duplicating


Question: Type Aliases are mostly used with ______.

Choices:
- Booleans
- Strings
- Numbers


Question: True or False: public modifiers allow access to the class members from anywhere.

Choices:
- False
- True


Question: True or False: a Tuple and an Array are the same thing when discussing types

Choices:
- True
- False


Question: True or False: TypeScript will always correctly infer the type of an array.

Choices:
- False
- True


Question: What does the 'readonly' access modifier do for an array variable assignment like: `const codeNames: readonly string[] = ['Coding', 'God']`?

Choices:
- Allows only adding but not deleting elements in the array
- Makes you read it for better clean code
- Allows no changes and is there simply to be read from and not modified
- Makes it private and can only be used in the file its created


Question: What is the inherited type for the variable example in `const example = ['Dylan']`?

Choices:
- string
- any[]
- unknown[]
- string[]


Question: ______ is similar to 'any', but a safer alternative when uncertain about the type.

Choices:
- never
- similar
- unknown


Question: You can enable 'undefined' and 'null' types to be accounted for by enabling the compiler property:

Choices:
- strictChecksRequired
- noFalseyInits
- noAutoType
- strictNullChecks


Question: You can disable implicit variable type assignment by enabling the compiler option:

Choices:
- autoTypeAssignment = FALSE
- noImplicitAny
- Implicit = FALSE
- noAutoType


Question: True or False: TypeScript can always correctly infer a variables type.

Choices:
- False
- True


Question: What type of assignment is this variable, `const fullName: string = 'Dylan Israel';`?

Choices:
- Explicit
- Implicit


Question: What are the three main 'simple types' in TypeScript?

Choices:
- Object, Array, Symbol
- Array, Object, Boolean
- Object, String, Number
- Boolean, Number, String


Question: Which is a successful example of this tuple `[number, string]`?

Choices:
- const ourTuple = [101, 101, 'Coding God', 'Coding God']
- const ourTuple = ['Coding God', 101]
- const ourTuple = [101]
- const ourTuple = [101, 'Coding God']


Question: True or False: protected modifiers only are allowed in the inherited class.

Choices:
- False
- True


Question:
Consider the C program below.

#include <stdio.h>
int *A, stkTop;
int stkFunc (int opcode, int val)
{
    static int size=0, stkTop=0;
    switch (opcode)
    {
    case -1:
        size = val;
        break;
    case 0:
        if (stkTop < size ) A[stkTop++]=val;
        break;
    default:
        if (stkTop) return A[--stkTop];
    }
    return -1;
}
int main()
{
    int B[20];
    A=B;
    stkTop = -1;
    stkFunc (-1, 10);
    stkFunc (0, 5);
    stkFunc (0, 10);
    printf (\"%d\\n\", stkFunc(1, 0)+ stkFunc(1, 0));
}

``````C

The value printed by the above program is ___________

Choices:
- 9
- 10
- 15
- 17


Question: The C language is. (GATE CS 2002)

Choices:
- A context free language
- A context sensitive language
- A regular language
- Parsable fully only by a Turing machine


Question: The number of tokens in the following C statement isprintf("HELLO WORLD");

Choices:
- 3
- 5
- 9
- 8


Question:
Assume that the size of an integer is 4 bytes. Predict the output?

#include <stdio.h>
int fun()
{
    puts(\" Hello \");
    return 10;
}

int main()
{
    printf(\"%d\", sizeof(fun()));
    return 0;
}

``````C

Choices:
- 4
- Hello 4
- 4 Hello
- Compiler Error


Question: Which of the following best describes C language

Choices:
- C is a low level language
- C is a high level language with features that support low level programming
- C is a high level language
- C is a very high level language


Question:
#include <stdio.h>
int main()
{
    int a[][3] = {1, 2, 3, 4, 5, 6};
    int (*ptr)[3] = a;
    printf(\"%d %d \", (*ptr)[1], (*ptr)[2]);
    ++ptr;
    printf(\"%d %d\\n\", (*ptr)[1], (*ptr)[2]);
    return 0;
}

``````C

Choices:
- 2 3 5 6
- 2 3 4 5
- 4 5 0 0
- none of the above


Question:
Assume the following C variable declaration

int *A [10], B [10][10];

``````C

Of the following expressionsI.   A [2]
II.  A [2][3]
III. B [1]
IV.  B [2][3]
which will not give compile-time errors if used as left hand sides of assignment statements in a C program ?

Choices:
- I, II and IV only
- II, III and IV only
- II and IV only
- IV only


Question:
Output of Below  C Code? Assume that int takes 4 bytes.

#include<stdio.h>
int x = 5;
int main()
{
	int arr[x];
	static int x = 0;
	x = sizeof(arr);
	printf(\"%d\", x<<2);
	return 0;
}

``````C

Thanks to Gokul Kumar for contributing this question.

Choices:
- Compiler error in line "static int x = 0"
- 7
- 80
- 20


Question:
#include <stdio.h>
#include <string.h>
int main()
{
    char a[] = {\'G\',\'E\',\'E\',\'K\',\'S\',\'Q\',\'U\',\'I\',\'Z\'};
    char b[] = \"QUIZ\";
    char c[] = \"GEEKS\";
    char d[] = \"1234\";
    int l = strlen(a);
    int o = printf(\"%d\", sizeof((sizeof(l)+(c[5]+d[0]+a[1]+b[2]))) );
    printf(\"%c\", a[o]);
    return 0;
}

``````C

Thanks to Gokul for contributing this question.

Choices:
- 4E
- 8E
- 1234Q
- Compiler Dependent


Question:
Consider line number 3 of the following C- program.

int main ( ) {                   /* Line 1 */
  int I, N;                      /* Line 2 */
  fro (I = 0, I < N, I++);       /* Line 3 */
}

``````C

Identify the compiler\'s response about this line while creating the object-module

Choices:
- No compilation error
- Only a lexical error
- Only syntactic errors
- Both lexical and syntactic errors


Question:
The most appropriate matching for the following pairs (GATE CS 2000)
X: m=malloc(5); m= NULL;        1: using dangling pointers
Y: free(n); n->value=5;         2: using uninitialized pointers
Z: char *p; *p = ’a’;           3. lost memory is:

Choices:
- X—1 Y—3 Z-2
- (X—2 Y—1 Z-3
- X—3 Y—2 Z-1
- X—3 Y—1 Z-2


Question:
Consider the following three C functions :

[PI] int * g (void)
{
  int x= 10;
  return (&x);
}

[P2] int * g (void)
{
  int * px;
  *px= 10;
  return px;
}

[P3] int *g (void)
{
  int *px;
  px = (int *) malloc (sizeof(int));
  *px= 10;
  return px;
}

``````C

Which of the above three functions are likely to cause problems with pointers? (GATE 2001)

Choices:
- Only P3
- Only P1 and P3
- Only P1 and P2
- P1, P2 and P3


Question:
Output?

# include<stdio.h>
# include<stdlib.h>

void fun(int *a)
{
    a = (int*)malloc(sizeof(int));
}

int main()
{
    int *p;
    fun(p);
    *p = 6;
    printf(\"%d",*p);
    return(0);
}

``````C

Choices:
- May not work
- Works and prints 6


Question: Which of the following is/are true

Choices:
- calloc() allocates the memory and also initializes the allocates memory to zero, while memory allocated using malloc() has random data.
- malloc() and memset() can be used to get the same effect as calloc().
- calloc() takes two arguments, but malloc takes only 1 argument.
- Both malloc() and calloc() return \'void *\' pointer.
- All of the above


Question: What is the return type of malloc() or calloc()

Choices:
- void *
- Pointer of allocated memory type
- void **
- int *


Question: Which of the following is true?

Choices:
-
"ptr = calloc(m, n)" is equivalent to following
ptr = malloc(m * n);
-
"ptr = calloc(m, n)" is equivalent to following
ptr = malloc(m * n);
memset(ptr, 0, m * n);
-
"ptr = calloc(m, n)" is equivalent to following
ptr = malloc(m);
memset(ptr, 0, m);
-
"ptr = calloc(m, n)" is equivalent to following
ptr = malloc(n);
memset(ptr, 0, n);


Question:
What is the problem with following code?

#include<stdio.h>
int main()
{
    int *p = (int *)malloc(sizeof(int));

    p = NULL;

    free(p);
}

``````C

Choices:
- Compiler Error: free can\'t be applied on NULL pointer
- Memory Leak
- Dangling Pointer
- The program may crash as free() is called for NULL pointer.


Question:
Consider the following program, where are i, j and k are stored in memory?

int i;
int main()
{
    int j;
    int *k = (int *) malloc (sizeof(int));
}

``````C

Choices:
- i, j and *k are stored in stack segment
- i and j are stored in stack segment.  *k is stored on heap.
- i is stored in BSS part of data segment, j is stored in stack segment.  *k is stored on heap.
- j is stored in BSS part of data segment, i is stored in stack segment.  *k is stored on heap.


Question:
Which of the following is not a valid declaration in C?

1. short int x;

``````C

2. signed short x;

``````C

3. short x;

``````C

4. unsigned short x;

``````C

Choices:
- 3 and 4
- 2
- 1
- All are valid


Question:
Predict the output of following program.  Assume that the numbers are stored in 2\'s complement form.

#include<stdio.h>
int  main()
{
   unsigned int x = -1;
   int y = ~0;
   if (x == y)
      printf(\"same\");
   else
      printf(\"not same\");
   return 0;
}

``````C

Choices:
- same
- not same


Question:
Consider the following C function

int f(int n)
{
   static int i = 1;
   if (n >= 5)
      return n;
   n = n+i;
   i++;
   return f(n);
}

``````C

The value returned by f(1) is (GATE CS 2004)

Choices:
- 5
- 6
- 7
- 8


Question:
#include <stdio.h>
int main()
{
  int x = 10;
  static int y = x;

  if(x == y)
     printf(\"Equal\");
  else if(x > y)
     printf(\"Greater\");
  else
     printf(\"Less\");
  return 0;
}

``````C

Choices:
- Compiler Error
- Equal
- Greater
- Less


Question:
Output?

#include <stdio.h>
int fun()
{
  static int num = 16;
  return num--;
}

int main()
{
  for(fun(); fun(); fun())
    printf(\"%d \", fun());
  return 0;
}

``````C

Choices:
- Infinite loop
- 13 10 7 4 1
- 14 11 8 5 2
- 15 12 8 5 2


Question:
#include<stdio.h>
int main()
{
  typedef int *i;
  int j = 10;
  i *a = &j;
  printf(\"%d\", **a);
  return 0;
}

``````C

Choices:
- Compiler Error
- Garbage Value
- 10
- 0


Question: In the C language (GATE CS 2002)

Choices:
- At most one activation record exists between the current activation record and the activation record for the main
- The number of activation records between the current activation record and the activation record for the main depends on the actual function calling sequence.
- The visibility of global variables depends on the actual function calling sequence.
- Recursion requires the activation record for the recursive function to be saved on a different stack before the recursive function can be called.


Question:
Output?

#include<stdio.h>
int main()
{
   typedef int i;
   i a = 0;
   printf(\"%d\", a);
   return 0;
}

``````C

Choices:
- Compiler Error
- Runtime Error
- 0
- 1


Question:
#include <stdio.h>
int main()
{
    int x = 5;
    int const * ptr = &x;
    ++(*ptr);
    printf(\"%d\", x);

    return 0;
}

``````C

Choices:
- Compiler Error
- Runtime Error
- 6
- 5


Question:
#include <stdio.h>
int main()
{
    int x = 5;
    int * const ptr = &x;
    ++(*ptr);
    printf(\"%d\", x);

    return 0;
}

``````C

Choices:
- Compiler Error
- Runtime Error
- 6
- 5


Question:
#include <stdio.h>
int main()
{
    static int i=5;
    if (--i){
        printf(\"%d \",i);
        main();
    }
}

``````C

Choices:
- 4 3 2 1
- 1 2 3 4
- 4 4 4 4
- 0 0 0 0


Question:
Output of following program?

#include <stdio.h>
int main()
{
    static int i=5;
    if(--i){
        main();
        printf(\"%d \",i);
    }
    return 0;
}

``````C

Choices:
- 4 3 2 1
- 1 2 3 4
- 0 0 0 0
- Compiler Error


Question: We use malloc and calloc for

Choices:
- Dynamic memory allocation
- Static memory allocation
- Both dynamic and static memory allocation
- None of the above


Question: Which languages necessarily need heap allocation in the run time environment?

Choices:
- Those that support recursion
- Those that use dynamic scoping
- Those that use global variables
- Those that allow dynamic data structures


Question:
#include<stdio.h>
int main()
{
  typedef static int *i;
  int j;
  i a = &j;
  printf(\"%d\", *a);
  return 0;
}

``````C

Choices:
- Runtime Error
- 0
- Garbage Value
- Compiler Error


Question:
Predict the output

#include <stdio.h>

int main()
{
   float c = 5.0;
   printf (\"Temperature in Fahrenheit is %.2f\", (9/5)*c + 32);
   return 0;
}

``````C

Choices:
- Temperature in Fahrenheit is 41.00
- Temperature in Fahrenheit is 37.00
- Temperature in Fahrenheit is 0.00
- Compiler Error


Question: ‘ptrdata’ is a pointer to a data type. The expression *ptrdata++ is evaluated as (in C++) :

Choices:
- Depends on compiler
- (*ptrdata)++
- *(ptrdata)++
- *(ptrdata++)


Question:
Consider the following C function

#include <stdio.h>
int main(void)
   {
    char c[ ] = \"ICRBCSIT17\";
    char *p=c;
    printf(\"%s\", c+2[p] – 6[p] – 1);
    return 0;
   }

``````C

The output of the program is

Choices:
- SI
- IT
- TI
- 17


Question:
#include <stdio.h>
extern int var;
int main()
{
    var = 10;
    printf(\"%d \", var);
    return 0;
}

``````C

Choices:
- Compiler Error: var is not defined
- 20
- 0


Question:
#include <stdio.h>
extern int var = 0;
int main()
{
    var = 10;
    printf(\"%d \", var);
    return 0;
}

``````C

Choices:
- 10
- Compiler Error: var is not defined
- 0


Question:
Output?

int main()
{
  {
      int var = 10;
  }
  {
      printf(\"%d\", var);
  }
  return 0;
}

``````C

Choices:
- 10
- Compiler Error
- Garbage Value


Question:
Output?

#include <stdio.h>
int main()
{
  int x = 1, y = 2, z = 3;
  printf(\" x = %d, y = %d, z = %d \\n\", x, y, z);
  {
       int x = 10;
       float y = 20;
       printf(\" x = %d, y = %f, z = %d \\n\", x, y, z);
       {
             int z = 100;
             printf(\" x = %d, y = %f, z = %d \\n\", x, y, z);
       }
  }
  return 0;
}

``````C

Choices:
-
x = 1, y = 2, z = 3
 x = 10, y = 20.000000, z = 3
 x = 1, y = 2, z = 100
- Compiler Error
-
x = 1, y = 2, z = 3
 x = 10, y = 20.000000, z = 3
 x = 10, y = 20.000000, z = 100
-
x = 1, y = 2, z = 3
 x = 1, y = 2, z = 3
 x = 1, y = 2, z = 3


Question:
int main()
{
  int x = 032;
  printf(\"%d\", x);
  return 0;
}

``````C

Choices:
- 32
- 0
- 26
- 50


Question:
Consider the following C program, which variable has the longest scope?

int a;
int main()
{
   int b;
   // ..
   // ..
}
int c;

``````C

Choices:
- a
- b
- c
- All have same scope


Question:
Consider the following variable declarations and definitions in C

i) int var_9 = 1;
ii) int 9_var = 2;
iii) int _ = 3;

``````C

Choose the correct statement w.r.t. above variables.

Choices:
- Both i) and iii) are valid.
- Only i) is valid.
- Both i) and ii) are valid.
- All are valid.


Question:
Find out the correct statement for the following program.

#include \"stdio.h\"

int * gPtr;

int main()
{
 int * lPtr = NULL;

 if(gPtr == lPtr)
 {
   printf(\"Equal!\");
 }
 else
 {
  printf(\"Not Equal\");
 }

 return 0;
}

``````C

Choices:
- It’ll always print Equal.
- It’ll always print Not Equal.
- Since gPtr isn’t initialized in the program, it’ll print sometimes Equal and at other times Not Equal.


Question:
void fun(int *p)
{
  int q = 10;
  p = &q;
}

int main()
{
  int r = 20;
  int *p = &r;
  fun(p);
  printf(\"%d\", *p);
  return 0;
}

``````C

Choices:
- 10
- 20
- Compiler error
- Runtime Error


Question:
Assume sizeof an integer and a pointer is 4 byte.  Output?

#include <stdio.h>

#define R 10
#define C 20

int main()
{
   int (*p)[R][C];
   printf(\"%d\",  sizeof(*p));
   getchar();
   return 0;
}

``````C

Choices:
- 200
- 4
- 800
- 80


Question:
#include <stdio.h>
int main()
{
    int a[5] = {1,2,3,4,5};
    int *ptr = (int*)(&a+1);
    printf(\"%d %d\", *(a+1), *(ptr-1));
    return 0;
}

``````C

Choices:
- 2 5
- Garbage Value
- Compiler Error
- Segmentation Fault


Question:
#include <stdio.h>

char *c[] = {\"GeksQuiz\", \"MCQ\", \"TEST\", \"QUIZ\"};
char **cp[] = {c+3, c+2, c+1, c};
char ***cpp = cp;

int main()
{
    printf(\"%s \", **++cpp);
    printf(\"%s \", *--*++cpp+3);
    printf(\"%s \", *cpp[-2]+3);
    printf(\"%s \", cpp[-1][-1]+1);
    return 0;
}

``````C

Choices:
- TEST sQuiz Z CQ
- MCQ  Quiz Z CQ
- TEST Quiz Z CQ
- GarbageValue sQuiz Z CQ


Question:
Predict the output

#include <string.h>
#include <stdio.h>
#include <stdlib.h>

void fun(char** str_ref)
{
    str_ref++;
}

int main()
{
    char *str = (void *)malloc(100*sizeof(char));
    strcpy(str, \"GeeksQuiz\");
    fun(&str);
    puts(str);
    free(str);
    return 0;
}

``````C

Choices:
- GeeksQuiz
- eeksQuiz
- Garbage Value
- Compiler Error


Question:
Assume that the size of int is 4.

#include <stdio.h>
void f(char**);
int main()
{
    char *argv[] = { \"ab\", \"cd\", \"ef\", \"gh\", \"ij\", \"kl\" };
    f(argv);
    return 0;
}
void f(char **p)
{
    char *t;
    t = (p += sizeof(int))[-1];
    printf(\"%s\\n\", t);
}

``````C

Choices:
- ab
- cd
- ef
- gh


Question: ``````C

Choices:
- 2 3 5 6
- 2 3 4 5
- 4 5 0 0
- none of the above


Question:
#include <stdio.h>
#include <stdlib.h>

int main(void)
{
    int i;
    int *ptr = (int *) malloc(5 * sizeof(int));

    for (i=0; i<5; i++)
        *(ptr + i) = i;

    printf(\"%d \", *ptr++);
    printf(\"%d \", (*ptr)++);
    printf(\"%d \", *ptr);
    printf(\"%d \", *++ptr);
    printf(\"%d \", ++*ptr);
}

``````C

Choices:
- Compiler Error
- 0 1 2 2 3
- 0 1 2 3 4
- 1 2 3 4 5


Question:
Output of following program

#include <stdio.h>
int fun(int arr[]) {
   arr = arr+1;
   printf(\"%d \", arr[0]);
}
int main(void) {
   int arr[2] = {10, 20};
   fun(arr);
   printf(\"%d\", arr[0]);
   return 0;
}

``````C

Choices:
- Compiler Error
- 20 10
- 20 20
- 10 10


Question:
Find out the correct statement for the following program.

#include \"stdio.h\"

typedef int (*funPtr)(int);

int inc(int a)
{
 printf(\"Inside inc() %d\\n\",a);
 return (a+1);
}

int main()
{

 funPtr incPtr1 = NULL, incPtr2 = NULL;

 incPtr1 = &inc; /* (1) */
 incPtr2 = inc; /* (2) */

 (*incPtr1)(5); /* (3) */
 incPtr2(5); /* (4)*/

 return 0;
}

``````C

Choices:
- Line with comment (1) will give compile error.
- Line with comment (2) will give compile error.
- Lines with (1) & (3) will give compile error.
- Lines with (2) & (4) will give compile error.
- No compile error and program will run without any issue.