Infosys Campus Connect - Non - IT Branches (Batch 1) Quiz

Approved & Edited by ProProfs Editorial Team
The editorial team at ProProfs Quizzes consists of a select group of subject experts, trivia writers, and quiz masters who have authored over 10,000 quizzes taken by more than 100 million users. This team includes our in-house seasoned quiz moderators and subject matter experts. Our editorial experts, spread across the world, are rigorously trained using our comprehensive guidelines to ensure that you receive the highest quality quizzes.
| By Infycc
I
Infycc
Community Contributor
Quizzes Created: 2 | Total Attempts: 514
Questions: 50 | Attempts: 147

Settings

This quiz is for Batch 1( NON IT batch) and contains 50 MCQ questions. All the best :)

• 1.

What is the output of the following? a = 4.5 b = 2 print (a//b)

• A.

2.0

• B.

2.5

• C.

2

• D.

Error

A. 2.0
Explanation
The output of the given code is 2.0. In Python, the double slash (//) operator is used for floor division, which returns the largest integer that is less than or equal to the result of the division. In this case, 4.5 divided by 2 is equal to 2.25, and the largest integer less than or equal to 2.25 is 2.0. Therefore, the output is 2.0.

Rate this question:

• 2.

A = True b = False c = False if not a or b:     print (1) elif not a or not b and c:     print (2) elif not a or b or not b and a:     print (3) else:     print (4)

• A.

1

• B.

2

• C.

3

• D.

4

C. 3
Explanation
The correct answer is 3 because the condition in the elif statement is true. The condition "not a or b or not b and a" evaluates to true because the first part "not a" is true, the second part "b" is true, and the third part "not b and a" is also true. Therefore, the code will execute the print statement for the third condition, which is "print (3)".

Rate this question:

• 3.

For i in  range(2):     print (i) for i in range(4,6):     print (i)

• A.

0 1 4 6

• B.

0 1 4 5

• C.

0 1 4 2

• D.

1 2 3 4 5

B. 0 1 4 5
Explanation
The given code consists of two for loops. The first loop iterates over the range from 0 to 1 (exclusive), so it prints 0 and 1. The second loop iterates over the range from 4 to 6 (exclusive), so it prints 4 and 5. Therefore, the output of the code is 0 1 4 5.

Rate this question:

• 4.

A = "hello and welcome to python " b = 13 print (a + b)

• A.

Hello and welcome to python13

• B.

13hello and welcome to python

• C.

Hello and welcome to python 13

• D.

None of the above

D. None of the above
Explanation
The code will result in a TypeError because we cannot concatenate a string and an integer using the "+" operator. The correct answer is None of the above.

Rate this question:

• 5.

List1 = ['physics', 'chemistry', 1997, 2000] list2 = [1, 2, 3, 4, 5, 6, 7] print ("list1[0]: ", list1[0])              #statement 1 print ("list1[0]: ", list1[-2])            #statement 2 print ("list1[-2]: ", list1[1:])           #statement 3 print ("list2[1:5]: ", list2[1:5])  #statement 4

• A.

List1[0]:  physics list1[0]:  2000 list1[-2]:  ['chemistry', 1997, 2000] list2[1:5]:  [2, 3, 4, 5]

• B.

List1[0]:  physics list1[0]:  1997 list1[-2]:  ['chemistry', 1997, 2000] list2[1:5]:  [2, 3, 4, 5]

• C.

List1[0]: chemistry list1[0]:  1997 list1[-2]:  ['chemistry', 1997, 2000] list2[1:5]:  [3,4,5,6]

• D.

List1[0]:  physics list1[0]:  1997 list1[-2]:  ['chemistry', 1997, 2000] list2[1:5]:  [1, 3, 4, 5]

B. List1[0]:  physics list1[0]:  1997 list1[-2]:  ['chemistry', 1997, 2000] list2[1:5]:  [2, 3, 4, 5]
Explanation
The correct answer is list1[0]: physics, list1[0]: 1997, list1[-2]: ['chemistry', 1997, 2000], list2[1:5]: [2, 3, 4, 5]. This is because in statement 1, list1[0] returns the first element of list1 which is 'physics'. In statement 2, list1[-2] returns the second last element of list1 which is 1997. In statement 3, list1[1:] returns a sublist of list1 starting from the second element to the end, which is ['chemistry', 1997, 2000]. In statement 4, list2[1:5] returns a sublist of list2 from the second element to the fifth element, which is [2, 3, 4, 5].

Rate this question:

• 6.

List1 = [1998, 2002, 1997, 2000] list2 = [2014, 2016, 1996, 2009] print ("list1 + list 2 = : ", list1 + list2)   #statement 1 print ("list1 * 2 = : ", list1 * 2 ) #statement 2

• A.

List1 + list 2 = :  [1998, 2002, 1997, 2000, 2014, 2016, 1996, 2009]list1 * 2 = :  [2002, 1997, 2000, 1998, 2002, 1997, 2000,1998]

• B.

List1 + list 2 = :  [1998, 2002, 1997, 2000, 2014, 2016, 1996, 2009] list1 * 2 = :  [1998, 2002, 2000,1997, 1998, 2002, 1997, 2000]

• C.

List1 + list 2 = :  [1998, 2002, 1997, 2000, 2014, 2016, 1996, 2009] list1 * 2 = :  [1998, 2002, 1997, 2000, 1998, 2002, 1997, 2000]

• D.

List1 + list 2 = :  [1998, 2002, 1997, 2000, 2014, 2016, 1996, 2009] list1 * 2 = :  [1998, 2002, 1997, 2000, 1998, 2002, 2000,1997]

C. List1 + list 2 = :  [1998, 2002, 1997, 2000, 2014, 2016, 1996, 2009] list1 * 2 = :  [1998, 2002, 1997, 2000, 1998, 2002, 1997, 2000]
Explanation
The given code demonstrates the concatenation and repetition operations on lists. In statement 1, the '+' operator is used to concatenate list1 and list2, resulting in a new list that contains all the elements from both lists. In statement 2, the '*' operator is used to repeat list1 twice, resulting in a new list that contains the elements of list1 repeated twice.

Rate this question:

• 7.

List1 = [1, 2, 3, 4, 5] list2 = list1 list2[0] = 0; print ("list1= : ", list1)  #statement 2

• A.

List1= :  [0, 2, 3, 4, 5]

• B.

List1= :  [1, 2, 3, 4, 5]

• C.

List1= :  [0, 1, 2, 3, 4]

• D.

List1= :  [0, 2, 3, 4, 1]

A. List1= :  [0, 2, 3, 4, 5]
Explanation
The correct answer is "list1= : [0, 2, 3, 4, 5]". When we assign list2 = list1, it means that both variables are referring to the same list object in memory. Therefore, when we modify list2 by changing the value at index 0 to 0, it also affects list1 because they are both pointing to the same list. Thus, the value at index 0 in list1 is also changed to 0.

Rate this question:

• 8.

X = ['ab', 'cd'] for i in x:     i.upper() print (x)

• A.

['ab', 'cd']

• B.

['AB', 'CD']

• C.

['cd', 'ab']

• D.

['cd', 'AB']

A. ['ab', 'cd']
Explanation
The given code assigns a list of strings, ['ab', 'cd'], to the variable x. Then, it iterates through each element in x using a for loop. Inside the loop, the upper() method is called on each element, which converts the string to uppercase. However, the updated strings are not stored or assigned to any variable. Finally, the original list, x, is printed. Since no changes were made to the original list, the output is still ['ab', 'cd'].

Rate this question:

• 9.

Def greetPerson(*name):      print('Hello', name) greetPerson('Frodo', 'Sauron')

• A.

Hello('Frodo','Sauron')

• B.

Syntax Error

• C.

Hello   ('Frodo', 'Sauron')

• D.

Hello('Sauron'Frodo'')

A. Hello('Frodo','Sauron')
Explanation
The correct answer is "Hello('Frodo','Sauron')". This is because the code defines a function called greetPerson that takes in any number of arguments and prints "Hello" followed by the names. When the function is called with the arguments 'Frodo' and 'Sauron', it will print "Hello Frodo Sauron".

Rate this question:

• 10.

Suppose you need to print pi constant defined in math module. Which of the following code can do this task?

• A.

Print(math.pi)

• B.

Print(pi)

• C.

From math import pi      print(pi)

• D.

From math import pi print(math.pi)

D. From math import pi print(math.pi)
Explanation
The correct answer is "from math import pi
print(math.pi)". This code imports the pi constant from the math module and then prints the value of pi using the "math.pi" syntax.

Rate this question:

• 11.

Which of the following is the use of id() function in python?

• A.

Returns the class of object

• B.

Type of the object

• C.

Memory location of the object

• D.

All of above

C. Memory location of the object
Explanation
The id() function in Python is used to return the memory location of an object. It is a unique identifier assigned to each object in memory. This can be useful in certain situations, such as when comparing two objects to check if they refer to the same memory location. The id() function does not return the class of the object or the type of the object, so these options are incorrect. Therefore, the correct answer is that the id() function returns the memory location of the object.

Rate this question:

• 12.

A = {i: i * i for i in range(6)} print (a)

• A.

Dictionary comprehension doesn’t exist

• B.

{0: 0, 1: 1, 2: 4, 3: 9, 4: 16, 5: 25, 6:36}

• C.

{0: 0, 1: 1, 4: 4, 9: 9, 16: 16, 25: 25}

• D.

{0: 0, 1: 1, 2: 4, 3: 9, 4: 16, 5: 25}

D. {0: 0, 1: 1, 2: 4, 3: 9, 4: 16, 5: 25}
Explanation
The given code is an example of dictionary comprehension in Python. It creates a dictionary where the keys are the numbers from 0 to 5 and the values are the square of each number. The output of the code is the dictionary {0: 0, 1: 1, 2: 4, 3: 9, 4: 16, 5: 25}.

Rate this question:

• 13.

Line =  "What will have so will" L = line.split('a') for i in L:      print(i, end=' ')

• A.

[‘What’, ‘will’, ‘have’, ‘so’, ‘will’]

• B.

Wh t will h ve so will

• C.

What will have so will

• D.

[‘Wh’, ‘t will h’, ‘ve so will’]

B. Wh t will h ve so will
Explanation
The given code splits the string "line" using the character 'a' as the delimiter and stores the resulting substrings in a list called L. Then, it iterates over each element in L and prints it followed by a space. The output of the code is "Wh t will h ve so will". The correct answer, "Wh t will h ve so will", matches the output of the code.

Rate this question:

• 14.

I = 1 while True:     if i % 3 == 0:         break     print(i)     i + = 1

• A.

1 2 3

• B.

1 2

• C.

Syntax Error

• D.

None of these

C. Syntax Error
Explanation
The given code will result in a syntax error. The error occurs on the line "i + = 1" because there shouldn't be a space between the "+" and the "=" sign in the compound assignment operator "+=". The correct syntax should be "i += 1" without any spaces.

Rate this question:

• 15.

List = [1, 2, 3, None, (1, 2, 3, 4, 5), ['Geeks', 'for', 'Geeks']] print len(list)

• A.

11

• B.

12

• C.

5

• D.

6

D. 6
Explanation
The correct answer is 6. The len() function is used to find the length of a list. In this case, the list has 6 elements, so the length of the list is 6.

Rate this question:

• 16.

List = ['a', 'b', 'c', 'd', 'e'] print list[10:]

• A.

[]

• B.

No output

• C.

Error

• D.

None of these

A. []
Explanation
The code tries to access elements in the list starting from index 10 to the end. However, since the list only has 5 elements, there are no elements from index 10 onwards. Therefore, an empty list is returned as the output.

Rate this question:

• 17.

I = 0 while i < 3:     print(i)     i += 1 else:     print(0)

• A.

0 1 2 3 0

• B.

0 1 2 0

• C.

0 1 2

• D.

Error

B. 0 1 2 0
Explanation
The given code snippet is a while loop that starts with i = 0 and continues until i is less than 3. Inside the loop, it prints the value of i and then increments i by 1. After the loop finishes, it executes the else block, which in this case, prints 0. So, the output of this code will be 0 1 2 0.

Rate this question:

• 18.

My_string = 'welcometocampusconnect' for i in range(len(my_string)):     print (my_string)     my_string = 'a'

• A.

Welcometocampusconnectaaaaaaaaaaaa

• B.

Welcometocampusconnect a a a a a a a a a a a a

• C.

Welcometocampusconnect

• D.

A a a a a a a a a a a a

B. Welcometocampusconnect a a a a a a a a a a a a
Explanation
The code starts by initializing the variable "my_string" with the value "welcometocampusconnect". Then, it enters a for loop that iterates over the range of the length of "my_string".

Inside the loop, it first prints the value of "my_string", which is "welcometocampusconnect" in the first iteration.

Then, it assigns the value "a" to "my_string". This means that in the next iteration of the loop, "my_string" will have the value "a".

The loop continues until it reaches the end of the range, printing "welcometocampusconnect" followed by "a" on each iteration.

Rate this question:

• 19.

If (7 < 0) and (0 < -7):     print("Hello") elif (7 > 0) or False:     print("Welcome") else:     print("Infosys")

• A.

Hello

• B.

Welcome

• C.

Infosys

• D.

None of the above

B. Welcome
Explanation
The correct answer is "Welcome" because the condition (7 > 0) evaluates to True and the condition False evaluates to False. Since the condition after "or" is False, the second branch of the if statement is executed and "Welcome" is printed.

Rate this question:

• 20.

Data = 50 try:     data = data/0 except ZeroDivisionError:     print('Cannot divide by 0 ', end = '') else:     print('Division successful ', end = '')   try:     data = data/5 except:     print('Inside except block ', end = '') else:     print('Hello', end = '')

• A.

Cannot divide by 0 Hello

• B.

Cannot divide by 0

• C.

Cannot divide by 0 Inside except block Hello

• D.

Cannot divide by 0 Inside except block

A. Cannot divide by 0 Hello
Explanation
The code first tries to divide the variable "data" by 0, which raises a ZeroDivisionError. The except block is then executed, which prints "Cannot divide by 0". However, since there is no error in the second try-except block, the else block is executed, which prints "Hello". Therefore, the output is "Cannot divide by 0 Hello".

Rate this question:

• 21.

Which of the following statements contains an error?

• A.

SELECT * FROM emp WHERE empid = 493945;

• B.

SELECT empid FROM emp WHERE empid= 493945;

• C.

SELECT empid FROM emp;

• D.

SELECT empid WHERE empid = 56949 AND lastname = ‘SMITH’;

D. SELECT empid WHERE empid = 56949 AND lastname = ‘SMITH’;
Explanation
The statement "SELECT empid WHERE empid = 56949 AND lastname = 'SMITH';" contains an error. The correct syntax for a SELECT statement is "SELECT column_name FROM table_name WHERE condition;" In this statement, the column_name is missing, so it should be "SELECT empid FROM ..." instead.

Rate this question:

• 22.

Which one is correct?

• A.

Primary Key Ì Super Key Ì Candidate Key

• B.

Candidate Key Ì Super Key Ì Primary Key

• C.

Primary Key Ì Candidate Key Ì Super Key

• D.

Super Key Ì Primary Key Ì Candidate Key

C. Primary Key Ì Candidate Key Ì Super Key
• 23.

Which of the following group functions ignore NULL values?

• A.

Max

• B.

Min

• C.

Sum

• D.

All of above

D. All of above
Explanation
All of the group functions mentioned in the options (Max, Min, and Sum) ignore NULL values. When these functions are used to calculate a result from a group of values, any NULL values within the group are automatically excluded from the calculation. Therefore, all of these functions will only consider non-NULL values and provide the desired result.

Rate this question:

• 24.

Empid Name Age Mobile Multivalued Derived Composite Simple

• A.

1-D, 2-C,3-B, 4-A

• B.

1-C, 2-B, 3-D, 4-A

• C.

1-B, 2-A, 3-D, 4-C

• D.

1-A, 2-C, 3-B, 4-D

A. 1-D, 2-C,3-B, 4-A
• 25.

Find the Salary in increasing order of all employees

• A.

SELECT ENAME FROM EMP ORDER BY SALARY

• B.

SELECT ENAME, SALARY FROM EMP

• C.

SELECT ENAME,SALARY FROM EMP ORDER BY SALARY

• D.

SELECT  ENAME, SALARY FROM EMP ORDER BY ENAME

D. SELECT  ENAME, SALARY FROM EMP ORDER BY ENAME
Explanation
The correct answer is "SELECT ENAME, SALARY FROM EMP ORDER BY ENAME". This query will retrieve the names and salaries of all employees from the EMP table and sort them in increasing order based on the employee names.

Rate this question:

• 26.

Which of the following is not a super key in relational schema with attributes V, W, X, Y, Z and primary key VY?

• A.

V XYZ

• B.

V WXZ

• C.

VWXY

• D.

VWXYZ

B. V WXZ
Explanation
A super key is a set of attributes that can uniquely identify each tuple in a relation. In this case, the primary key is VY, which means that V and Y together uniquely identify each tuple. So, any super key that does not contain V or Y as attributes would not be able to uniquely identify each tuple. The super key V WXZ does not contain either V or Y, so it is not a super key in this relational schema.

Rate this question:

• 27.

ON UPDATE CASCADE ensures which of the following

• A.

Normalization

• B.

Data Integrity

• C.

Materialized View

• D.

All of above

B. Data Integrity
Explanation
ON UPDATE CASCADE ensures data integrity. When a row in the referenced table is updated, the update is automatically propagated to the referencing table, ensuring that the foreign key relationship is maintained. This prevents any inconsistencies or orphaned records in the database, maintaining the integrity of the data.

Rate this question:

• 28.

The HAVING clause does which of the following?

• A.

Acts like a WHERE clause but is used for groups rather than rows

• B.

Acts like a WHERE clause but is used for rows rather than columns

• C.

Acts like a WHERE clause but is used for columns rather than groups

• D.

Acts EXACTLY like a WHERE clause.

A. Acts like a WHERE clause but is used for groups rather than rows
Explanation
The HAVING clause is used to filter the results of a GROUP BY query based on a condition applied to the groups, rather than individual rows. It is similar to the WHERE clause, but while the WHERE clause filters rows, the HAVING clause filters groups. It allows you to specify conditions that must be met by the groups in order for them to be included in the result set.

Rate this question:

• 29.

Which of the following scenarios may lead to an irrecoverable error in a database system?

• A.

A transaction writes a data item after it is read by an uncommitted transaction

• B.

A transaction reads a data item after it is read by an uncommitted transaction

• C.

A transaction reads a data item after it is written by a committed transaction

• D.

A transaction reads a data item after it is written by an uncommitted transaction

D. A transaction reads a data item after it is written by an uncommitted transaction
Explanation
If a transaction reads a data item after it is written by an uncommitted transaction, it may lead to an irrecoverable error in a database system. This is because the uncommitted transaction's changes are not yet finalized and may be rolled back. If the second transaction reads the data item before the first transaction is committed or rolled back, it may retrieve inconsistent or incorrect data. This can result in data integrity issues and make it difficult to maintain the consistency and reliability of the database system.

Rate this question:

• 30.

A table on the many side of a one to many or many to many relationship must:

• A.

Be in Second Normal Form (2NF)

• B.

Be in Third Normal Form (3NF)

• C.

Have a single attribute key

• D.

Have a Composite key

D. Have a Composite key
Explanation
In a one to many or many to many relationship, a table on the many side must have a composite key. This means that the table's primary key is made up of multiple attributes, rather than just a single attribute. A composite key is necessary in order to uniquely identify each record in the table, as a single attribute may not be sufficient. By using multiple attributes as the key, it ensures that each combination of values is unique and can be used to establish relationships with the corresponding records in the other table(s) involved in the relationship.

Rate this question:

• 31.

Using the ______ clause retains only one copy of such identical tuples.

• A.

Null

• B.

Unique

• C.

Not Null

• D.

Distinct

D. Distinct
Explanation
The DISTINCT clause is used to eliminate duplicate rows from the result set of a SELECT statement. It retains only one copy of identical tuples, ensuring that each tuple appears only once in the output. Therefore, the correct answer is "Distinct".

Rate this question:

• 32.

To connect oracle database which module is required to be included in python

• A.

Cx_Oracle

• B.

Sqlite3

• C.

MySQLDB

• D.

None of the above

A. Cx_Oracle
Explanation
The correct answer is cx_Oracle. This module is required to be included in Python in order to connect to an Oracle database. cx_Oracle is a Python extension module that enables access to Oracle Database. It provides a high-performance, reliable, and easy-to-use interface for connecting to and interacting with Oracle databases using Python.

Rate this question:

• 33.

Which method of cursor class is used to execute SQL query on database

• A.

Fetchone()

• B.

Execute()

• C.

Close()

• D.

Scroll()

B. Execute()
Explanation
The execute() method of the cursor class is used to execute SQL queries on a database. This method allows the user to pass SQL statements as arguments and execute them against the database. It is commonly used for executing SELECT, INSERT, UPDATE, and DELETE queries. This method returns the result of the query execution, which can then be fetched using other methods like fetchone() or fetchall(). The close() method is used to close the cursor and release any resources associated with it, while the scroll() method is used to scroll through the result set.

Rate this question:

• 34.

"Study the code import cx_Oracle con = cx_Oracle.connect('pythonhol/welcome@localhost/orcl') cur = con.cursor() cur.execute('select * from employee') Which code snippet will print all the reterived records"

• A.

"for con in cur:             print con"

• B.

Print cur.printall()

• C.

"for result in cur:           print result"

• D.

None of the above

C. "for result in cur:           print result"
Explanation
The correct answer is "for result in cur: print result". This code snippet will iterate over the cursor object "cur" and print each retrieved record.

Rate this question:

• 35.

Rollback segments are used for

• A.

Undo changes when a transaction is rolled back

• B.

Ensure other transactions do not see uncommitted changes made to the database

• C.

Recover the database to a consistent state in case of failures

• D.

All of above

A. Undo changes when a transaction is rolled back
Explanation
Rollback segments are used to undo changes when a transaction is rolled back. When a transaction is rolled back, the changes made by that transaction need to be reversed in order to maintain data consistency. Rollback segments store the before-images of the modified data, allowing the system to revert the changes made by the transaction. Therefore, the correct answer is that rollback segments are used to undo changes when a transaction is rolled back.

Rate this question:

• 36.

Connect() method takes what as argument

• A.

• B.

• C.

Connection String

• D.

None of the above

Explanation
The connect() method in this context requires three arguments: username, password, and Connection String. These arguments are necessary to establish a connection to a database or a server. Without providing all three arguments, the connect() method will not be able to establish a successful connection.

Rate this question:

• 37.

Class methods need cls as the first argument

• A.

True

• B.

False

A. True
Explanation
In Python, class methods are defined using the @classmethod decorator and they require the cls parameter as the first argument. This parameter refers to the class itself and allows access to class-level variables and methods. By convention, the first parameter of a class method is named cls, although any valid variable name can be used. Therefore, the statement "Class methods need cls as the first argument" is true.

Rate this question:

• 38.

What is the output of the following snippet of code                 class abc:                                  count=2                                  def __init__(self):                                                    pass                                  def xyz():                                                  print(abc.count)                 a=abc;                 a.xyz()                 abc.count=4                 a.xyz()

• A.

2              4

• B.

2              2

• C.

2              Error

A. 2              4
Explanation
The output of the code snippet is "2 4" because the variable "count" is a class variable with a value of 2. When the method "xyz()" is called, it prints the value of "count" which is 2. Then, the value of "count" is changed to 4. When "xyz()" is called again, it prints the updated value of "count" which is 4.

Rate this question:

• 39.

What is the output of the following snippet of code                 class A:                                  count=2                                  def abc():                                                   pass                 class B(A):                                  def abc():                                                 print(super.count)                 x=B                 x.abc()

• A.

2

• B.

No output

• C.

Error:Super has no attribute count

C. Error:Super has no attribute count
Explanation
The code snippet defines two classes, A and B. Class A has a class variable "count" with a value of 2 and a method "abc()" which does nothing. Class B is a subclass of A and overrides the "abc()" method. In the "abc()" method of class B, it tries to print the value of "super.count". However, since the "count" attribute is not defined in the superclass A, it raises an error stating that "Super has no attribute count". Therefore, the output of the code is "Error: Super has no attribute count".

Rate this question:

• 40.

Super is used to

• A.

Access Base class members

• B.

Access Derived class members

• C.

None of the above

A. Access Base class members
Explanation
The keyword "super" is used in object-oriented programming languages to access the members (methods, variables) of the base class from within the derived class. It allows the derived class to inherit and utilize the functionalities and data defined in the base class. So, the correct answer is "Access Base class members".

Rate this question:

• 41.

What is the output                 class A:                              z=3                                 def __init__(self):                                                 self.x = 1                                                 self.y = 1                                                 A.z=4                                 def getY(self):                                                  return self.y              a = A()              a.y = 45               print(a.getY())               print(a.z)

• A.

Error

• B.

45           4

• C.

1           3

A. Error
Explanation
The code will produce an error because the attribute "y" is not defined in the class A. Although the variable "a" is created as an instance of class A and the attribute "y" is assigned a value of 45, the method getY() is trying to access a non-existent attribute. Therefore, an error will occur when trying to print(a.getY()). The attribute "z" is defined in the class A and is also assigned a value of 4, so the code will print 4 when trying to print(a.z).

Rate this question:

• 42.

Class A():        def __init__(self):                 self.__x = 1        def m1(self):                 print("m1 from A")  class B(A):         def __init__(self):                   self.__y = 1           def m1(self):                print("m1 from B")                super().m1() c = B() c.m1()

• A.

Error in calling super

• B.

M1 from B    followed by  m1 from A

• C.

No method as m1 in B

• D.

Option 4

B. M1 from B    followed by  m1 from A
Explanation
The correct answer is "m1 from B followed by m1 from A". This is because when the method m1 is called on object c, it first looks for the method in class B. Since class B has a method m1, it is executed and "m1 from B" is printed. However, after executing the method in class B, the super() function is called, which allows the method to be inherited from the parent class A. This means that the method m1 from class A is also executed and "m1 from A" is printed. Therefore, the output is "m1 from B followed by m1 from A".

Rate this question:

• 43.

Class ParentClass:                                 def __init__(self):                                                   self.x = 1                                                   self.y = 10                                 def print(self):                                                   print(self.x, self.y) class ChildClass(ParentClass):                                 def __init__(self):                                                  super().__init__()                                                 self.x = 2                                                 self.y = 20  c = ChildClass()  c.print()

• A.

1              10

• B.

1              20

• C.

2              10*

• D.

1              20

D. 1              20
Explanation
The correct answer is 1 20 because when the ChildClass object c is created, the __init__ method of the ParentClass is called using the super() function. This initializes the values of x and y in the ParentClass to 1 and 10 respectively. Then, the __init__ method of the ChildClass is called, which reassigns the value of x to 2 and y to 20. When the print method is called on the ChildClass object c, it prints the values of x and y, which are 1 and 20 respectively.

Rate this question:

• 44.

What is the relationship between car and   class Maruti   class Engine

• A.

IS-A                        HAS-A

• B.

HAS-A                   IS-A

• C.

IS-A                        USES-A

• D.

USES-A                 HAS-A

A. IS-A                        HAS-A
Explanation
The relationship between car and class Maruti is that car HAS-A class Maruti. This means that a car can have a class Maruti, indicating that it belongs to the Maruti brand. On the other hand, the relationship between car and class Engine is that car IS-A class Engine. This means that a car is a type of class Engine, suggesting that the car itself is an engine.

Rate this question:

• 45.

Can private variables be accesses outside the class

• A.

Yes

• B.

NO

B. NO
Explanation
Private variables cannot be accessed outside the class. They are only accessible within the class in which they are declared. Private variables are used to encapsulate data and ensure data integrity by preventing direct access from outside the class. This helps in maintaining the security and integrity of the data.

Rate this question:

• 46.

Which one is not applicable while querying on a view?

• A.

From

• B.

Select

• C.

Order by

• D.

Where

C. Order by
Explanation
When querying on a view, the "Order by" clause is not applicable. This clause is used to sort the result set in ascending or descending order based on one or more columns. However, when querying on a view, the view itself does not store any data, it is just a virtual table that is created by a query. Therefore, there is no need to sort the result set of a view since the underlying tables are already sorted or can be sorted using the "Order by" clause when creating the view.

Rate this question:

• 47.

Which are the join types in join condition:

• A.

Cross join

• B.

Natural Join

• C.

Outer Join

• D.

Join with USING clause

A. Cross join
Explanation
The correct answer is Cross join. A cross join, also known as a Cartesian join, returns the Cartesian product of the two tables being joined. It combines each row from the first table with every row from the second table, resulting in a potentially large number of rows in the output. This type of join does not require any specific join condition and is used when all possible combinations of rows from both tables are needed.

Rate this question:

• 48.

If in JOIN operation, conditions of JOIN operation are not satisfied then results of operation is

• A.

Zero tuples and empty relation

• B.

One tuple from one relation

• C.

Zero tuples from two relation

• D.

Two tuples from empty relations

A. Zero tuples and empty relation
Explanation
If the conditions of a JOIN operation are not satisfied, it means that there are no matching tuples between the two relations being joined. As a result, the operation will produce zero tuples and an empty relation. This means that there will be no output from the JOIN operation, as there are no common values or matching criteria between the two relations.

Rate this question:

• 49.

AN SQL view is said to be updatable, if clause contains only attribute names of relation i.e.

• A.

Define Clause

• B.

Where Clause

• C.

Having Clasue

• D.

Select Clause

B. Where Clause
Explanation
The correct answer is the Where Clause. In an SQL view, the Where Clause is used to specify conditions that filter the rows returned by the view. It allows for the selection of specific rows based on certain criteria. By using attribute names in the Where Clause, the view can be updated because it identifies the specific rows that need to be modified. The other clauses listed (Define, Having, and Select) do not affect the updatable nature of the view.

Rate this question:

• 50.

What type of join is needed when you wish to include rows that do not have matching values?

• A.

Equi-join

• B.

Natural Join

• C.

Outer Join

• D.

All of the above

C. Outer Join
Explanation
An outer join is needed when you wish to include rows that do not have matching values. In an outer join, all rows from one table are included in the result set, even if there is no matching value in the other table. This allows you to retrieve data from one table even if there are no corresponding records in the other table.

Rate this question:

Related Topics