IBM Bigdata MCQ 1 With Responses (2)
IBM Bigdata MCQ 1 With Responses (2)
1. Which of the following is a core component of Java Environment and provides all the
tools, executables and binaries required to compile, debug and execute a Java Program
a) JRE
b) JIT
c) JDK
d) JVM
class increment {
public static void main(String args[])
{
int g = 3;
System.out.print(++g * 8);
}
}
a) 32
b) 33
c) 24
d) 25
class Output
{
public static void main(String args[])
{
int arr[] = {1, 2, 3, 4, 5};
for ( int i = 0; i < arr.length - 2; ++i)
System.out.println(arr[i] + " ");
}
}
a) 1 2 3 4 5
b) 1 2 3 4
c) 1 2
d) 1 2 3
4. What will be the output of the following Java program?
class recursion
{
int func (int n)
{
int result;
if (n == 1)
return 1;
result = func (n - 1);
return result;
}
}
class Output
{
public static void main(String args[])
{
recursion obj = new recursion() ;
System.out.print(obj.func(5));
}
}
a) 1
b) 120
c) 0
d) None of the mentioned
class output
{
public static void main(String args[])
{
String c = "Hello i love java";
boolean var;
var = c.startsWith("hello");
System.out.println(var);
}
}
a) 0
b) true
c) 1
d) false
6. What will be the output of the following Java code?
class exception_handling
{
public static void main(String args[])
{
try
{
int a = args.length;
int b = 10 / a;
System.out.print(a);
}
catch (ArithmeticException e)
{
System.out.println("1");
}
}
}
a) 0
b) 1
c) Compilation Error
d) Runtime Error
7. What will be the output of the following Java code?
class exception_handling
{
public static void main(String args[])
{
try
{
int a = 1;
int b = 10 / a;
try
{
if (a == 1)
a = a / a - a;
if (a == 2)
{
int c[] = {1};
c[8] = 9;
}
}
finally
{
System.out.print("A");
}
}
catch (Exception e)
{
System.out.println("B");
}
}
}
a) A
b) B
c) AB
d) BA
a) TypeA
b) TypeB
c) Compilation Error
d) Runtime Error
9. Which two classes use the Shape class correctly?
class A
{
int i;
void display()
{
System.out.println(i);
}
}
class B extends A
{
int j;
void display()
{
System.out.println(j);
}
}
class inheritance_demo
{
public static void main(String args[])
{
B obj = new B();
obj.i=1;
obj.j=2;
obj.display();
}
}
a) 0
b) 1
c) 2
d) Compilation Error
class A
{
public int i;
public int j;
A()
{
i = 1;
j = 2;
}
}
class B extends A
{
int a;
B()
{
super();
}
}
class super_use
{
public static void main(String args[])
{
B obj = new B();
System.out.println(obj.i + " " + obj.j)
}
}
a) 1 2
b) 2 1
c) Runtime Error
d) Compilation Error
abstract class A
{
int i;
abstract void display();
}
class B extends A
{
int j;
void display()
{
System.out.println(j);
}
}
class Abstract_demo
{
public static void main(String args[])
{
B obj = new B();
obj.j=2;
obj.display();
}
}
a) 0
b) 2
c) Runtime Error
d) Compilation Error
12. What is the process of defining a method in a subclass having same name & type
signature as a method in its superclass?
a) Method overloading
b) Method overriding
c) Method hiding
d) None of the mentioned
class A
{
public int i;
private int j;
}
class B extends A
{
void display()
{
super.j = super.i + 1;
System.out.println(super.i + " " + super.j);
}
}
class inheritance
{
public static void main(String args[])
{
B obj = new B();
obj.i=1;
obj.j=2;
obj.display();
}
}
a) 2 2
b) 3 3
c) Runtime Error
d) Compilation Error
15. What will be the output of the following Java code?
class A
{
int i;
void display()
{
System.out.println(i);
}
}
class B extends A
{
int j;
void display()
{
System.out.println(j);
}
}
class method_overriding
{
public static void main(String args[])
{
B obj = new B();
obj.i=1;
obj.j=2;
obj.display();
}
}
a) 0
b) 1
c) 2
d) Compilation Error
Oracle
3. If a table has already some rows, you cannot add another column that is Not Null
a. True
b. False
4. Which of the following is set to return maximum no of rows possible?
a. Inner Join
b. Full Outer Join
c. Left Outer Join
d. Right Outer Join
5. A select statement cannot have both a Where clause and a Having clause together
a. True
b. False
9. For an ordinary nested sub-query, outer query table reference must be mentioned inside
a. True
b. False
11. Count(*) discards the entire row if any column contains NULL in it
a. True
b. False
15. Which of the following is the only way to return unique rows in a query
a. Unique
b. Order By
c. Group By
d. Distinct
PYTHON
1. What will be the value of the following Python expression?
4+3%5
a) 7
b) 2
c) 4
d) 1
a) Indentation
b) Key
c) Brackets
d) All of the mentioned
i=1
while True:
if i%3 == 0:
break
print(i)
i+=1
a) 1 2 3
b) error
c) 1 2
d) none of the mentioned
2**(3**2)
(2**3)**2
2**3**2
def f(x):
def f1(*args, **kwargs):
print("Sanfoundry")
return x(*args, **kwargs)
return f1
a) any number of
b) 0
c) 1
d) 2
a) Python first searches the built-in namespace, then the global namespace and finally
the local namespace
b) Python first searches the built-in namespace, then the local namespace and finally
the global namespace
c) Python first searches the local namespace, then the global namespace and finally the
built-in namespace
d) Python first searches the global namespace, then the local namespace and finally the
built-in namespace
8. What will be the output of the following Python code?
class tester:
def __init__(self, id):
self.id = str(id)
id="224"
>>>temp = tester(12)
>>>print(temp.id)
a) 12
b) 224
c) None
d) Error
def foo(x):
x[0] = ['def']
x[1] = ['abc']
return id(x)
q = ['abc', 'def']
print(id(q) == foo(q))
a) Error
b) None
c) False
d) True
print("abc. DEF".capitalize())
a) Abc. def
b) abc. def
c) Abc. Def
d) ABC. DEF
>>>list1 = [1, 3]
>>>list2 = list1
>>>list1[0] = 4
>>>print(list2)
a) [1, 4]
b) [1, 3, 4]
c) [4, 3]
d) [1, 3]
i=0
while i < 5:
print(i)
i += 1
if i == 3:
break
else:
print(0)
a) error
b) 0 1 2 0
c) 0 1 2
d) none of the mentioned
def addItem(listParam):
listParam += [1]
mylist = [1, 2, 3, 4]
addItem(mylist)
print(len(mylist))
a) 5
b) 8
c) 2
d) 1
def foo():
try:
return 1
finally:
return 2
k = foo()
print(k)
a) error, there is more than one return statement in a single try-finally block
b) 3
c) 2
d) 1
15. To add a new element to a list we use which Python command?
a) list1.addEnd(5)
b) list1.addLast(5)
c) list1.append(5)
d) list1.add(5)
UBUNTU - Commands
1. Which command creates an empty file if file does not exist?
a) cat
b) touch
c) ed
d) read
2. Which option of rm command is used to remove a directory with all its subdirectories
a) –b
b) –o
c) –p
d) –r
3. Write the command to display the current date in the form dd/mm/yyyy.
a) date +%d/%m/%Y
b) date +”%d/%m/%Y”
c) date +/%d/%m/20%y
d) date +”/%d/%m/20%y”
4. The command syntax to display the file ‘sample.txt’ one page at a time is
a) man sample.txt>more
b) cat sample.txt<more
c) cat sample.txt | more
d) none of the mentioned
a) ls
b) help
c) date
d) ls –l
6. Which command is used to display all the files including hidden files in your current
and its subdirectories ?
a) ls –aR
b) ls –a
c) ls –R
d) ls –l
7. Which tar command option is used to list the files in a tape archive format?
a) cvf
b) tvf
c) xvf
d) ovf
a) The process id is $$
b) The process id is $<pid>$<pid>
c) The process id is <pid><pid>
d) The process id is $$$$
2. What would be the current working directory at the end of the following command
sequence?
$ pwd
/home/user1/proj
$ cd src
$ cd generic
$ cd .
$ pwd
a) /home/user1/proj
b) /home/user1/proj/src
c) /home/user1
d) /home/user1/proj/src/generic
3. Create a new file “new.txt” that is a concatenation of “file1.txt” and “file2.txt”
x = 3; y = 5; z = 10;
if [( $x -eq 3 ) -a ( $y -eq 5 -o $z -eq 10 )]
then
echo $x
else
echo $y
fi
a) 1
b) 3
c) 5
d) Error
5. Shell is ?
a) Command Interpreter
b) Interface between Kernel and Hardware
c) Interface between user and applications
d) Command Compiler
a) /etc/inittab
b) /etc/profile
c) /etc/login
d) /etc/init
a) ../home/file.txt
b) bin/cat
c) cs2204/
d) /usr/bin/cat
8. Which variable is used to display number of arguments specified in command line
a) $0
b) $#
c) $*
d) $?