0% found this document useful (0 votes)
13 views

IBM Bigdata MCQ 1 With Responses (2)

The document contains a series of multiple-choice questions related to Java, Oracle, Python, and Ubuntu commands. Each section tests knowledge on programming concepts, syntax, and command-line operations. The questions cover topics such as core Java components, exception handling, SQL queries, Python expressions, and shell scripting commands.

Uploaded by

pk.sf25
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views

IBM Bigdata MCQ 1 With Responses (2)

The document contains a series of multiple-choice questions related to Java, Oracle, Python, and Ubuntu commands. Each section tests knowledge on programming concepts, syntax, and command-line operations. The questions cover topics such as core Java components, exception handling, SQL queries, Python expressions, and shell scripting commands.

Uploaded by

pk.sf25
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 17

JAVA

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

2. What will be the output of the following Java code?

class increment {
public static void main(String args[])
{
int g = 3;
System.out.print(++g * 8);
}
}

a) 32
b) 33
c) 24
d) 25

3. What will be the output of the following Java program?

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

5. What will be the output of the following Java code?

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

8. 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);
try
{
if (a == 1)
a = a / a - a;
if (a == 2)
{
int []c = {1};
c[8] = 9;
}
}
catch (ArrayIndexOutOfBoundException e)
{
System.out.println("TypeA");
}
catch (ArithmeticException e)
{
System.out.println("TypeB");
}
}
}

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

10. What will be the output of the following Java program?

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

11. What will be the output of the following Java program?

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

13. Which of these keywords can be used to prevent Method overriding?


a) static
b) constant
c) protected
d) final

14. What will be the output of the following Java code?

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

1. All Foreign Keys are Unique and Not Null.


a. True
b. False
2. Distinct ensures that the table does not contain duplicate values
a. True
b. False

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

6. To join between two rows in a table, you need to use


a. Inner Join
b. Self Join
c. Full Outer Join
d. This is not possible

7. Check constraint implements -----


a. Data Integrity
b. Referential Integrity

8. Foreign Key can contain null value


a. True
b. False

9. For an ordinary nested sub-query, outer query table reference must be mentioned inside
a. True
b. False

10. Select Sum(Salary) from Employee;


a. The query will not execute because there is no Group By Clause
b. It will return the sum considering the entire table – an explicit group example
c. It will return the sum considering the entire table – an implicit group example
d. Sum is an invalid function

11. Count(*) discards the entire row if any column contains NULL in it
a. True
b. False

12. Which of the following is a View Constraint


a. A Where condition
b. With Check Option
c. With Read Only
d. All of these
13. A table can contain ---- Unique Index
a. 1
b. 2
c. 0
d. Unlimited

14. Which if the following is not true


a. Can be used to implements Integrity constraint
b. Can be used to perform internal and implicit auditing
c. Is part of the same transaction in which the trigger is fired
d. None of the above

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

2. Which of the following is used to define a block of code in Python language?

a) Indentation
b) Key
c) Brackets
d) All of the mentioned

3. What will be the output of the following Python code?

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

4. What are the values of the following Python expressions?

2**(3**2)
(2**3)**2
2**3**2

a) 512, 64, 512


b) 512, 512, 512
c) 64, 512, 64
d) 64, 64, 64

5. What will be the output of the following Python code?

l=[1, 0, 2, 0, 'hello', '', []]


list(filter(bool, l))

a) [1, 0, 2, ‘hello’, ”, []]


b) Error
c) [1, 2, ‘hello’]
d) [1, 0, 2, 0, ‘hello’, ”, []]

6. The following python program can work with ____ parameters.

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

7. What is the order of namespaces in which Python looks for an identifier?

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

9. What will be the output of the following Python program?

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

10. What will be the output of the following Python code?

print("abc. DEF".capitalize())

a) Abc. def
b) abc. def
c) Abc. Def
d) ABC. DEF

11. What will be the output of the following Python code?

>>>list1 = [1, 3]
>>>list2 = list1
>>>list1[0] = 4
>>>print(list2)

a) [1, 4]
b) [1, 3, 4]
c) [4, 3]
d) [1, 3]

12. What will be the output of the following Python program?

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

13. What will be the output of the following Python program?

def addItem(listParam):
listParam += [1]

mylist = [1, 2, 3, 4]
addItem(mylist)
print(len(mylist))

a) 5
b) 8
c) 2
d) 1

14. What will be the output of the following Python code?

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

5. Which of the following command output contains userid?

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

UBUNTU – Shell Scripts

1. What will be output of following command:

$ echo "The process id is" $$$$

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”

a) cp file.txt file2.txt new.txt


b) cat file1.txt file2.txt > new.txt
c) mv file[12].txt new.txt
d) ls file1.txt file2.txt | new.txt

4. What is the output of the following program?

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

6. For every successful login, which script will be executed?

a) /etc/inittab
b) /etc/profile
c) /etc/login
d) /etc/init

7. Which of the following represents an absolute path?

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) $?

You might also like