CS MCQ
CS MCQ
a. f.read()
b. f.read(5)
c. f.reads(5)
a. open( )
b. new( )
c. Open( )
a. True
b. False
Q4. Which mode create new file if the file does not exist?
a. write mode
b. append mode
Q5. Which statement will return one line from a file (file object is
‘f’)?
a. f.readline( )
b. f.readlines( )
c. f.read( )
d. f.line( )
Show Answer
a. String
b. List
c. Dictionary
d. Tuple
a. End of File
c. End on File
d. End or File
a. read( )
b. writelines( )
c. pickle( )
d. dump( )
a. f.reads( )
b. f.read( )
c. f.read(all)
d. f.read( * )
a. ap
b. a
c. w
d. app
Q11. Which of the following options can be used to read the first
line of a text file data.txt?
a. f = open(‘data.txt’); f.read()
b. f = open(‘data.txt’,’r’); f.read(n)
d. f = open(‘data.txt’); f.readlines()
Show Answer
a. Bytes
b. Bites
c. bits
a. write
b. writelines
c. pickle
d. dump
Q15. Let the file pointer is at the end of 3rd line in a text file
named “data.txt”. Which of the following option can be used to
read all the remaining lines?
a. f.read( )
b. f.read(all)
c. f.readline( )
d. f.readlines( )
Show Answer
a. pickle
b. unpickle
c. pandas
d. math
a. FileNotFoundError
b. FileFoundError
c. FileNotExistError
a. read( )
b. readline( )
a. a
b. r+
c. ar+
d. w
Q22. readlines( ) function returns all the words of the file in the
form of List. (T/F)
a. True
b. False
f=open("Data.txt" , "r")
a. File Name
b. File Handle
c. Mode of file
d. File Handling
a. f = open(“data.txt” , “a”)
b. f = Open(“data.txt” , “ab”)
c. f = new(“data.txt” , “a”)
d. open(“data.txt” , “a”)
import pickle
f=open("data.dat",'rb')
d=_____________________.load(f)
f.close()
a. unpickle
b. pickling
c. pickle
d. pick
Show Answer
f=open("A.txt")
a. FileNotFoundError
b. NotFoundError
c. FileNotFound
d. FoundError
Show Answer
Q31. Almost all the files in our computer stored as _______ File.
a. Text
b. Binary
c. CSV
a. True
b. False
a. Text
b. Binary
c. CSV
a. 1
b. 2
c. 0
Show Answer
a. True
b. False
Show Answer
a. True
b. False
a. 0
b. 1
c. 2
d. 3
Show Answer
a. get( )
b. tell( )
c. cur( )
d. seek( )
Show Answer
a. True
b. False
Show Answer
a. f.seek(-10, 0)
b. f.seek(10, 0)
c. f.seek(-10, 1)
Show Answer
a. end
b. beginning
Show Answer
b. beginning
a. file
b. variable
c. comment
d. token
Show Answer
a. Binary
b. Text
Show Answer
a. Binary
b. Text
c. CSV
Q54. Which of the following file can be opened in any text editor?
a. Binary
b. Text
Show Answer
a. End of File
b. End of Line
c. End of Statement
d. End of program
Show Answer
a. \n
b. \N
c. \t
d. \l
Show Answer
b. Binary File
c. CSV File
Show Answer
a. File
b. Variable
Show Answer
a. File name
b. Access mode
>>> f = open("test.txt","w")
>>> f.mode
a. ‘w’
b. ‘r’
c. ‘a’
d. ‘w+’
Q64. Write the output of the following:
>>> f = open("test.txt","w")
>>> f.name
a. ‘test’
b. ‘test.txt’
c. ‘test.dat’
a. write
b. append
c. read
Show Answer
Q69. Which of the following mode will create a new file, if the file
does not exist?
a. ‘a’
b. ‘a+’
c. ‘+a’
Show Answer
Q70. Which of the following mode will open the file in binary and
read-only mode.
a. ‘r’
b. ‘rb’
c. ‘r+’
d. ‘rb+’
Q71. Which of the following mode will opens the file in read, write
and binary mode?
a. ‘wb+
b. ‘+wb’
Show Answer
myObject=open(“myfile.txt”, “a+”)
a. append and read
Show Answer
Q73. Ravi opened the file myfile.txt in append mode. In this file
the file object/file handle will be at the __________
Show Answer
Q74. Ravi opened the file myfile.txt in write mode. In this file the
file object/file handle will be at the ______________
Show Answer
Q75. Ravi opened the file myfile.txt in read mode. In this file the
file object/file handle will be at the _______________
Q76. Ravi opened a file in a certain mode. After opening the file,
he forgot the mode. One interesting fact about that mode is ” If
the file already exists, all the contents will be overwritten”. Help
him to identify the correct mode.
a. read mode
b. write mode
c. append mode
Show Answer
Q78. Which of the following function is used to close the file?
a. close( )
b. end( )
c. quit( )
d. exit( )
Show Answer
a. object handle
b. file handle
c. read handle
d. write handle
Show Answer
Q80. Which of the following is the valid way to open the file?
Show Answer
Show Answer
Q82. Mohan wants to open the file to add some more content in
the already existing file. Suggest him the suitable mode to open
the file.
a. read mode
b. append mode
c. write mode
1. Growing
2. Throwing
3. Executing
4. Handling
3. The statements inside the finally block are always executed regardless of whether an exception
occurred in the try block or not.
1. True
2. False
3. Depend on code
4. None of the above
1. except, try
2. try, except
3. EOF, Error
4. program, compile
1. False
2. True
3. Some times
4. None of the above
1. Logic
2. Expression
3. Error
4. Module
7. What keeps track of the exact position where the error has occurred.
1. Compiler
2. Interpreter
3. Both 1 and 2
4. None of the above
1. user-defined
2. built-in
3. Both 1 and 2
4. None
1. Value Error
2. Import Error
3. Type Error
4. All the above
10. An exception is a Python ………… that represents an error.
1. Class
2. Method
3. Object
4. All the above
Chapter -3(stack)
4. Pushing an element into stack already having five elements and stack size of 5, then
stack becomes ___________
a) Overflow
b) Crash
c) Underflow
d) User flow
Top
[6] You can replace any element position in the stack. (True/False)
[7] The peek operation refers to accessing/inspecting the top element in the stack.
(True/False)
[9] While popping the element from the stack, a condition will be raised, this condition is
known as ____________.
Push, Pop
[1] What do you mean by data structure? Explain your answer with a
suitable example.
”Hide_Answer”
”Hide_Answer”
Ans.: LIFO is one of the principle to access data from a data structure. It stands
for Last In First Out. It refers to the item which is inserted last will be access frist.
So the top element will be accessed first.
Example:
1. Books in the shelf
2. Stack of coins
3. Pile of chairs
4. Bangles on woman’s wrist
[3] Enlist a few of the fields where you feel a stack is used in real life.
”Hide_Answer”
Ans.: The stack is used in many fields in our routine life. Some examples are:
1. Browsers History
2. Mobile Phone Call log
3. Tubewell boring machine
4. Undo and redo commands in software
[4] What are the basic operations that can be performed on the stack?
Ans.: There are two basic operations can be performed on the stack:
1. Push – Inserting an element
2. Pop – Deleting an element
[5] What are the underflow and overflow conditions?
Ans.: Underflow is the condition which occurs when stack is empty while trying to
delete elements. Overflow is the condition which occurs while inerting an element
when memory is exhausted.
[6] Write steps on how you implement stack?
1. Alinear list of elements in which deletion can be done from one end (front) and
insertion can take
place only at the other end (rear) is known as a ?
a) Queue
b) Stack
©) Tree
d) Linked list
14. A data structure in which elements can be inserted or deleted at/from both
the ends but not in the
middle is?
a) Queue
b) Circular queue
¢) Dequeue
d) Priority queue
Show Answer
a. Syntax error
b. Logical error
c. Runtime error
d. All of the above
Show Answer
a. Syntax error
3. Look at the following code and select the correct description of error shown while
executing it:
X = int(input(“Enter a Number”))
R = X*X
print “Square =”,R
Show Answer
a. Interpreter
b. Compiler
c. Exception
d. Module
Show Answer
c. Exception
5. (i) generally all exceptions are generated when a program is syntactically correct
(ii) SyntaxError is not considered as exception.
Show Answer
Show Answer
d. Raised
a. SyntaxError
b. ValueError
c. ZeroDivisionError
d. ExportError
Show Answer
d. ExportError
a. NameError
b. IOError
c. ImportError
d. EOFError
Show Answer
b. IOError
a. NameError
b. ValueError
c. TypeError
d. ZeroDivisionError
Show Answer
a. NameError
a. IOError
b. ValueError
c. TypeError
d. ZeroDivisionError
Show Answer
d. ZeroDivisionError
a. TypeError
b. ValueError
c. NameError
d. SyntaxError
Show Answer
b. ValueError
12. It is raised when user accidently hits the Delete or Esc key while executing a
program
a. TypeError
b. ValueError
c. KeyboardInterrupt
d. IOError
Show Answer
c. KeyboardInterrupt
a. NameError
b.ImportError
c. TypeError
d. IndentationError
Show Answer
b.ImportError
a. IndentationError
b. IOError
c. SyntaxError
d. TypeError
Show Answer
a. IndentationError
15. It is raised when the result of a calculation exceeds the maximum limit for
numeric data type
a. ZeroDivisionError
b. OverFlowError
c. TypeError
d. ValueError
Show Answer
b. OverFlowError
16. The process of creating exception object and handing it over to runtime system is
called
a. Catching Exception
b. Throwing Exception
c. Raising Exception
d. Asserting Exception
Show Answer
b. Throwing Exception
17. Searching and executing appropriate exception handler that can handle the
raised exception
a. Catching exception
b. Throwing exception
c. Handling exception
d. Asserting exception
Show Answer
a. Catching exception
Show Answer
19. Which of the following describes the exception handling process correctly?
a. Exception raised -> searches for exception handler -> create exception object
-> execute code of exception handler
b. Exception raised -> create exception object -> searches for exception handler
-> execute code of exception handler
c. Create exception object -> exception raised -> searcher for exception handler -
> execute code of exception handler
d. Create exception object -> searches for exception handler -> exception raised
-> execute code of exception handler
Show Answer
c. Create exception object -> exception raised -> searcher for exception handler ->
execute code of exception handler
a. Try block
b. Except block
c. Finally block
d. Else block
Show Answer
a. Try block
a. Try block
b. Except block
c. Finally block
d. Else block
Show Answer
b. Except block
22. The statement written inside _____ block is always executed regardless of
whether an exception has occurred or not
a. Try
b. Except
c. Else
d. Finally
Show Answer
d. Finally
23. Which of the following statement is not true about try..except block?
Show Answer
c. The statement inside the except block is always executed regardless of whether
exception has occurred in try block or not
(i) The statement inside else block is executed regardless of whether there
except block is executed or not.
(ii) If an exception is encountered, further execution of the code inside the try
block is stopped and control is transferred to except block
Show Answer
Show Answer
c. Finally block can be placed anywhere after end of try clause, such as before or after
all except and else block
a. Try
b. Except
c. Finally
d. Else
Show Answer
b. Except
Show Answer
a. Try
b. Catch
c. Except
d. Finally
Show Answer
b. Catch
29. If the exception is not handled by any of the except clauses, then it is re-raised
after the execution of the finally block.
a. True
b. False
c. Cant say
d. None of these
Show Answer
a. True
Show Answer
d. All of above
a. Ensures that program does not terminate abnormally due to any error
b. Provide standardize solutions for commonly occurring errors (exceptions)
c. Both (a) and (b)
d. Only (a)
e. None of these
Show Answer
32. What will happen If finally and except blocks are not positioned properly
Show Answer
33. Each try block must always be followed by at least one block that is either except
or a finally block.
a. True
b. False
c. May be
d. None of these
Show Answer
a. True
34. The ______ block is generally used to while working with files, clean up memory
resources
a. Try
b. Except
c. Finally
d. Else
Show Answer
c. Finally
try:
X = int(input(“enter a number”))
except ___________:
print(“please enter only numbers”)
else:
print(“Squeare =”,X*X)
a. IOException
b. ValueError
c. ZeroDivisionError
d. TypeError
Show Answer
b. ValueError
36. Consider the given code and fill in the blank space with appropriate exception
object name.
try:
X = int(input(“enter a number”))
R = X*Y
except ___________ :
Print(“Please check Y is not defined”)
else:
Print(“Result =”,R)
a. TypeError
b. NameError
c. IOerror
d. IndexError
Show Answer
b. NameError
L=[12,32,40]
print(L[4])
a. IndexError
b. ZeroDivisionError
c. IOError
d. TypeError
Show Answer
a. IndexError
38. Look at the given code and fill in the blank space
try:
num1 = 10
num2 = 0
q = num1/num2
except ___________:
print(“Division is not possible as num2 is set to 0”)
____________:
print(“quotient = “,q)
a. ZeroDivisionError, finally
b. ZeroDivisionError, else
c. ValueError, finally
d. ValueError, else
Show Answer
b. ZeroDivisionError, else
39. Rajesh has written following line of code to import python pandas library but he is
getting error while executing. Help him in handling and correcting given code.
Import panda as pd
S = pd.Series[12,23,34]
a.
try:
import panda as pd
S = pd.Series[12,23,34]
except NameError:
print(“Please check the name of module you are importing”)
b.
try:
import panda as pd
S = pd.Series[12,23,34]
except ImportError:
print(“Please check the name of module you are importing”)
c.
try:
import panda as pd
S = pd.Series[12,23,34]
except IOError:
print(“Please check the name of module you are importing”)
d.
try:
import panda as pd
S = pd.Series[12,23,34]
except SyntaxError:
print(“Please check the name of module you are importing”)
Show Answer
b.
try:
import panda as pd
S = pd.Series[12,23,34]
except ImportError:
print(“Please check the name of module you are importing”)
40. Consider the following code and select the type of error it will generate.
a. SyntaxError
b. Runtime error
c. Logical Error
d. No Error will be generated
Show Answer
Get computer network mcq helpful for all competitive exams, cucet computer science,
informatics practices and other IT based entrance.
Show Answer
Show Answer
d. Hierarchy
a. LAN
b. WAN
c. MAN
d. PAN
Show Answer
d. PAN
a. Bus
b. Ring
c. Star
d. Tree
Show Answer
c. Star
Show Answer
b. Metropolitan area network
Show Answer
Show Answer
8. 802.11 represents:
a. Internet Protocol
b. WiFi
c. Bluetooth
d. www
Show Answer
b. WiFi
a. LAN
b. WAN
c. MAN
d. PAN
Show Answer
b. WAN
10. The device that regenerates a signal being transmitted on the network is
called
a. Router
b. Modem
c. Gateway
d. Repeater
Show Answer
d. Repeater
a. Hub
b. Switch
c. Router
d. Modem
Show Answer
b. Switch
12. is
a. Tree topology
b. Bus topology
c. Star topology
d. Ring topology
Show Answer
b. Bus topology
13. Your school is planning to link its front office situated in hilly region where
cable connection is not feasible, suggest an economic way to connect it
with reasonably high speed
a. Bluetooth
b. FM
c. Satellite
d. None of these
Show Answer
c. Satellite
14. Refer the given diagram and identify which of the device acts as a Server?
a. A
b. B
c. C
d. D
Show Answer
c. C
Show Answer
16. Govt Hr Sec School has a computer network. The network is in one
building. What kind of network it is?
a. LAN
b. WAN
c. MAN
d. PAN
Show Answer
a. LAN
17. When you connect two mobiles using Bluetooth to transfer a picture or file,
which type of network is found?
a. LAN
b. WAN
c. MAN
d. PAN
Show Answer
d. PAN
a. Client
b. Server
c. Communication channel
d. Adapter
Show Answer
b. Server
a. Ring
b. Mesh
c. Tree
d. All of above
Show Answer
c. Tree
a. Router
b. Gateway
c. Modem
d. Both (a) and (b)
Show Answer
Show Answer
Show Answer
a. TCP/IP
b. IP
c. MAC
d. TCP
Show Answer
b. IP
24. IPV4 is
a. Version of IP Address
b. Version of TCP Address
c. Version of MAC address
d. Version of WiFI
Show Answer
a. Version of IP Address
Show Answer
Show Answer
27. (i) MAC address once assigned to network adapter can not be changed
(ii) IP address assigned to a node in a network can be changed
conditionally
Show Answer
July 9, 2022
Get MCQ based on Data Communication best suitable for all competitive exams,
entrance exams, computer science, CUET, informatics practices or any other IT
perusal.
a. Message
b. Sender
c. Channel
d. Producer
Show Answer
d. Producer
2. Medium or path through which data or message travels between source and
destination is
a. Protocol
b. Channel or Media
c. Server
d. Bandwidth
Show Answer
b. Channel or Media
a. Protocol
b. Channel or Media
c. Bandwidth
d. Data Transfer Rate
Show Answer
a. Protocol
a. Bandwidth
b. Data Transfer Rate
c. Both (a) and (b)
d. None of these
Show Answer
5. Bandwidth is measured in
Show Answer
c. Hertz
Show Answer
7. Mbps is
Show Answer
8. The number of bits transmitted between source and destination in one second is
___________. It is measured in terms of _______
a. Bandwidth, hertz
b. Data transfer rate, hertz
c. Data communication rate, bandwidth
d. Data transfer rate, bits per second
Show Answer
9. A user wants to upload a text document at the rate of 5 pages per 10 seconds.
What will be the required data rate of the channel? (Assume that 1 page contains
1200 characters and each character is of 8 bits.)
a. 6.25kbps
b. 4.69kbps
c. 19.2 kbps
d. None of these
Show Answer
b. 4.69kbps
hint:
(1200x5x8)/10
=4800 bps
=4800/1024
=4.69kbps
a. Simplex communication
b. Half duplex communication
c. Full duplex communication
d. None of these
Show Answer
a. Wired media
b. Wireless media
c. Both (a) and (b)
d. None of these
Show Answer
b. Wireless media
12. When data travels through physical link made of wire/cable between two nodes is
referred as
a. Guided transmission
b. Wired media
c. Unguided transmission
d. Wireless media
e. Both (a) and (b)
Show Answer
13. Which of the following is best suitable for long distance wired data
communication?
Show Answer
c. Fiber-Optic cable
1.
14. Look at the image given below and identify the wired transmission media:
Show Answer
b. Co-axial cable
Show Answer
a. 191.656.0.1
b. 802.11
c. IPV4
d. 6404
Show Answer
b. 802.11
Who am I?
a. Simplex communication
b. Half Duplex communication
c. Full Duplex communication
d. None of these
Show Answer
Show Answer
a. Malfunctioned Software
b. Malcontent Software
c. Malaysian Software
d. Malicious Software
Show Answer
d. Malicious Software
a. Viruses
b. Worms
c. Trojan
d. Cookies
Show Answer
d. Cookies
3. (i) virus is a piece of software code that is created to hamper system resources
and activated as soon as infected file is opened by user
(ii) Virus behaves uniformly without caring of reason or motivation behind their
creation
Show Answer
4. I
Am a malware
Am standalone program and capable of working on my own.
Nimda, Code Red are some of my examples
Who am I?
a. Firewall
b. Worms
c. Trojan
d. Spyware
Show Answer
b. Worms
5. __________ looks like a legitimate software which once installed acts like a
virus.
a. Worm
b. Trojan
c. Spyware
d. Cookies
Show Answer
b. Trojan
a. Spyware
b. Adware
c. Trojan
d. Worms
Show Answer
b. Adware
7. The virtual keyboard of an operating system that uses a fixed QWERTY key
layout is called
a. On-Screen Keyboard
b. Online Virtual Keyboard
c. Virtual Qwerty Keyboard
d. Virtual Keypad
Show Answer
a. On-Screen Keyboard
8. The virtual keyboard that randomizes the key layout every time it is used
a. On-Screen Keyboard
b. Online Virtual Keyboard
c. Virtual Qwerty Keyboard
d. Virtual Keypad
Show Answer
9. A malware once designed, can take many routes to reach your computer. Which
of the followings you think is not correct channel of distribution of malware:
a. Downloaded from the Internet into hard drive of computer by user unintentionally
b. Removable storage media infected with malware get transferred to other systems that
they are plugged into
c. Links or attached files with unsolicited email we receive can be malware
d. All are correct
Show Answer
10. Raju has been asked to identify common sign of some malware infection. Help
him out to find so from given option:
Show Answer
11. Act of repeatedly sending advertisement links and invitation emails to a large
number of users is called:
a. Stacking
b. Hacking
c. Spamming
d. Denial of Service
Show Answer
c. Spamming
12. HTTPS is
Show Answer
Show Answer
14. It acts as a network filter and continuously monitors and controls the incoming
and outgoing traffic.
a. Antivirus
b. Firewall
c. SSL
d. Sandbox
Show Answer
b. Firewall
a. Super cookies
b. Worm cookies
c. Nimda cookies
d. Zombie cookies
Show Answer
d. Zombie cookies
16. _______ is a malware that records the key pressed by user on the keyboard.
Using which one can get very sensitive and personal information of user like
password emails etc.
a. Spyware
b. Snooping
c. Key logger
d. Denial of Service
Show Answer
c. Key logger
a. Sandbox detection
b. Data mining technique
c. Firewall
d. Heuristics
Show Answer
c. Firewall
18. It’s a kind of system used by antivirus where a new application or file is executed
in a virtual machine (environment) to detect any malicious activity by observing
its behavior
a. Data mining
b. Sandbox
c. Heuristics
d. VDF (Virus Definition File)
Show Answer
b. Sandbox
a. Virus polymorphic
b. Sandbox
c. Virus Signature
d. None of these
Show Answer
c. Virus Signature
20. Method of comparing source code of a suspected program with already known
virus present in database of antivirus is known as
a. Sandbox detection
b. Real time protection
c. Heuristics
d. Firewall
Show Answer
c. Heuristics
Database Concept mcq computer science class 12, CUET mcq computer science,
helpful for all competitive exams entrance exams and IT preparation
a. UNIQUE
b. FOREIGN
c. CHECK
d. All of above
Show Answer
b. FOREIGN
2. Which is the correct difference between Primary key and Foreign key?
a. A table can have multiple primary key and single foreign key
b. A primary key cannot ignore NULL value but Foreign key can
c. A Primary key can have duplicate data but foreign key does not
d. None of the above
Show Answer
b. A primary key cannot ignore NULL value but Foreign key can
3. Which one of the following refers to the copies of the same data (or
information) occupying the memory space at multiple places.
a. Data Repository
b. Data Inconsistency
c. Data Mining
d. Data Redundancy
Show Answer
d. Data Redundancy
a. Degree
b. Row
c. Column
d. All of the above
Show Answer
a. Degree
5. Consider attributes ID, CITY and NAME. Which one of this can be
considered as a primary key?
a. NAME
b. ID
c. CITY
d. CITY, ID
Show Answer
b. ID
a. Access
b. Oracle
c. SQL Server
d. All of these
Show Answer
d. All of these
a.
a. cardinality = 7, degree = 8
b. cardinality = 9, degree = 8
c. cardinality = 7, degree = 56
d. cardinality = 8, degree = 7
Show Answer
d. cardinality = 8, degree = 7
a. 4 tuples
b. 4 attributes
c. 4 state
d. 4 relations
Show Answer
b. 4 attributes
a. E. F Codd
b. Richard Stallman
c. Guido Van Rossum
d. John Von Neumann
Show Answer
a. E. F Codd
a. Admno
b. Rno
c. Name
d. Class
Show Answer
a. Admno
a. System software
b. Application software
c. General software
d. Both (a) and (c)
Show Answer
b. Application software
12. Which one of the following refers to the copies of the same data (or
information) occupying the memory space at multiple places.
a. Data Repository
b. Data Inconsistency
c. Data Mining
d. Data Redundancy
Show Answer
d. Data Redundancy
Show Answer
a. Entity
b. Column
c. Cardinality
d. None of the above
Show Answer
c. Cardinality
a. Entity
b. Row
c. Column
d. Both (b) and (c)
Show Answer
c. Column
a. Primary key
b. Foreign key
c. Unique key
d. Candidate key
Show Answer
b. Foreign key
a. Relation attribute
b. Attribute, relation
c. Degree, relation
d. Relation tuple
Show Answer
b. Attribute, relation
a. Data System
b. Memory System
c. File System
d. Drive
Show Answer
c. File System
Show Answer
a. Information
b. Relation
c. Database
d. Tuple
Show Answer
b. Relation
21. I
ensure every tuple is unique in relation
can be applied to only one attribute in a relation
can not accept NULL values
who am I?
a. Primary key
b. Unique key
c. Foreign key
d. Candidate key
Show Answer
a. Primary key
a. Inventory Management
b. Banking
c. Online Shopping
d. All of the above
Show Answer
Show Answer
a. 0
b. 1
c. Null
d. Equal to degree
Show Answer
a. 0
a. Record
b. Relation
c. Relational
d. Referential
Show Answer
c. Relational
a. Single cell
b. Single row
c. Single column
d. None of the above
Show Answer
b. Single row
Show Answer
28. Restriction on the type of data that can be inserted into the table is
a. Database Schema
b. Database Instance
c. Database Constraint
d. Database Key
Show Answer
c. Database Constraint
29. A tuple is a unique entity whereas attribute values can be duplicated in the
table
a. True
b. False
c. Depends upon type of record
d. Depends upon the database key
Show Answer
a. True
Show Answer
31. Which of the following represent a valid file system to store records
a. Access
b. MySQL
c. CSV files
d. All of above
Show Answer
c. CSV files
32. According to case of Q 33, Roll No 4 may not be interested in sport; can a
NULL value be assigned to that student’s preference attribute?
a. Yes
b. No
c. Not Sure
d. Depends upon you
Show Answer
a. Yes
33. A school has a rule that each student must participate in a sport activity. So each
one should give only one preference for sport activity. So each one should give
only one preference for sport activity. Suppose there are five students in a class,
each having a unique rollno. The class representative has prepared a list of sports
preferences as shown below:
Rolln Preference
o
1 Cricket
2 Football
3 Hockey
4 NULL
5 Volley ball
Null Kabaddi
Kabaddi was not chosen by any student. Is it possible to have this tuple in the
Sport preference relation?
a.
a. Yes
b. No
c. Not Sure
d. Depends upon you
Show Answer
b. No
a. Ccode, Cname
b. Ccode, Cadd
c. Cname, Cadd
d. Ccode
Show Answer
b. Ccode, Cadd
35. For the case given in Q34, The organization wants to receive details of
SALE of a particular Customer. Name the tables and the key which are
required to retrieve this detail.
a. Customer, ccode
b. Sale, ccode
c. Customer and sale, ccode
d. Customer and sale, saleid
Show Answer
36. For the given tables of Q37, find the alternate key in table STUDENT.
a. Rollno
b. Reg_id
c. Class
d. Name
Show Answer
a. Rollno
STUDENT PROJECT
ASSIGNEN
D
4 Jaikaran 12 R04
Find Foreign Key in PROJECT ASSIGNED table
a. Reg_id
b. Proj_no
c. Both reg_id and Proj_no
d. No Foreign Key defined
Show Answer
a. Reg_id
a. Table
b. Query
c. Report
d. Hosting
Show Answer
b. Query
39. In which of the following case NULL value cannot be assigned to the
column ROLLNO.
Show Answer
40. ___________ is used to get the common tuples from two tables.
a. Minus
b. Union
c. Catesian Product
d. Intersection
Show Answer
d. Intersection
SQL MCQ class 12
techtipnow.in/sql-mcq-class-12
July 4, 2022
Get Most Important MCQ for SQL with answers. These SQL MCQ class 12 are very
helpful for all students learning RDBMS, SQL or preparing for CUET, GATE or any IT or
Computer Science competitive.
Show Answer
c. Create Query
Show Answer
c. Many
Show Answer
Show Answer
b. A primary key cannot ignore NULL value but Foreign key can
Show Answer
Show Answer
Show Answer
Show Answer
a. The retrieval of information stored in database
Show Answer
b. DML
10. A table can not have more than one UNIQUE keys.
a. True
b. False
c. Depends upon Primary key
d. Depends upon RDBMS
Show Answer
b. False
Show Answer
Show Answer
a. IS NULL
13. Select correct SQL statement to increase price of books by 10% in book table.
a. UPDATE book SET price = price*0.1;
b. UPDATE book SET price = price + price*0.1;
c. UPDATE book WHERE price = price*0.1;
d. UPDATE book WHERE price = price + price*0.1;
Show Answer
14. For given table ‘sales’ what will be output of following code
SELECT Sname FROM sales WHERE Rank > 4 ORDER BY Sname;
a. Sname
Safiq
b. Sname
Amber
Safiq
c. Sname
Safiq
Amber
d. SName
Jagan
Jakir
Mohan
Show Answer
Show Answer
17. For given table student in Q15 list different games offered by school.
a. Select Game from Student;
b. Select Unique(Game) from Student;
c. Select Distinct(Game) from Student;
d. Select Game from student where Distinct(Game);
Show Answer
18. For given table Library (Bno, Title, Qty, Price) Display list of books with price
ranges 150 to 200 and qty should not be null.
a. Select Title, Price from Library Where Price between 150 Or 200 And qty = NOT
NULL
b. Select Title, Price from Library Where Price between 150 And 200 Or qty = NOT
NULL
c. Select Title, Price from Library Where Price between 150 Or200 And qty IS NOT
NULL
d. Select Title, Price from Library Where Price between 150 And 200 And qty IS NOT
NULL
Show Answer
d. Select Title, Price from Library Where Price between 150 And 200 And qty IS NULL
19. Consider the ‘Club’ (coachid, coachname, sport, dateofapp, pay). List name of all
coaches with their date of appointment in descending order.
a. Select * from club order by dateofapp DESC
b. Select coachname, dataofapp from club order by dateofapp DESC
c. Select coachname, dataofapp from club order by dateofapp DSC
d. Select * from club order by dateofapp DSC
Show Answer
20. An attribute A of datatype varchar(20) has the value “Keshav”. The attribute B of
data type char(20) has value “Meenakshi”. How many characters are occupied in
attribute A and attribute B?
a. 20, 6
b. 6, 20
c. 9,6
d. 6,9
Show Answer
b. 6, 20
21. “Select Distinct Brand From Product;” What does this given query do?
a. It gives all the tuples having dept_name
b. It gives the dept_name attribute values of all tuples without repetition
c. It gives all the dept_name attribute of all the tuples
d. It gives all the dept_name attribute of all the tuples
Show Answer
22. Suchita is creating a table Employee with fields eno, ename, salary. She doesn’t
want the salary column to be remain unfilled i.e. she wants to make entry in this
field mandatory. Which constraint she should use at the time of creating employee
table.
a. Check
b. Default
c. Not Null
d. Primary Key
Show Answer
c. Not Null
23. Chaman want to change the default value of DISCOUNT in the CUSTOMER table
from 10 to 15. Write most appropriate command to do the same.
a. Alter Table Customer Add Discount int default(15);
b. Alter Table Customer Modify Discount int Default(15);
c. Alter Table Customer Change Discount Default from 10 to 15;
d. All of the above
Show Answer
b. Alter Table Customer Modify Discount int Default(15);
24. Write a query to display the name of customers whose name contains ‘a’ as third
alphabet from customer table (cno, cname, cadd, mobile).
a. Select cname from customer where cname like ‘%%a’;
b. Select cname from customer where cname like ‘_ a’;
c. Select cname from customer where cname like ‘ _ _a%’;
d. Select * from customer where cname like ‘_ _a’;
Show Answer
25. Raju is trying to delete all records of table ‘emp’. For this he wrote:
DELETE ALL FROM EMP;
But he is getting error while executing this code. Help him in writing correct code
a. DELETE FROM EMP;
b. DELETE * FROM EMP;
c. DELETE EMP;
d. DELETE ALL EMP;
Show Answer
Show Answer
a. DDL
Show Answer
b. SELECT
28. SQL command used to display the list of tables stored in database
a. SELECT TABLES
b. VIEW TABLES
c. SHOW TABLES
d. LIST TABLES
Show Answer
c. SHOW TABLES
29. Which of the following type of table constraints will prevent the entry of duplicate
rows?
a. Unique
b. Distinct
c. Primary Key
d. NULL
Show Answer
Show Answer
d. Yyyy/mm/dd
31. Which of the following is not a valid data type to store alphanumeric data in
MySQL?
a. Char
b. Varchar
c. Text
d. Memo
Show Answer
d. Memo
32. Which two constraints when applied together will produce a Primary Key
constraint?
a. Foreign Key + Unique Key
b. NOT NULL + Foreign Key
c. NOT NULL + Unique Key
d. Primary Key can not be replaced by combining other constraints
Show Answer
c. NOT NULL + Unique Key
33. To store Mobile number in a table which data type should be preferred?
a. Int
b. Char(n)
c. Varchar(n)
d. Float
Show Answer
b. Char(n)
34. Reena wants to see the the fieldnames and its data type of table ‘department’.
What code she should write?
a. Select * from department;
b. View department;
c. Show table department;
d. Describe department;
Show Answer
d. Describe department;
35. Jaikaran want to remove primary key assigned to bookid from book table. Help
him in writing suitable code.
a. Drop primary key from book
b. Alter table book modify bookid drop primary key;
c. Alter table book drop primary key;
d. Alter table book drop primary key (bookid);
Show Answer
36. Which of the following is not a valid operator used in SQL to set criteria in query?
a. IN
b. LIKE
c. IS NOT NULL
d. ==
Show Answer
d. ==
37. Write SQL command to display name of all employees containing ‘aa’ as a
substring in name.
a. Select name from employee where name like ‘aa%’;
b. Select name from employee where name like ‘aa%’ ;
c. Select name from employee where name like ‘%aa%’ ;
d. Select name from employee where name like ‘_aa’;
Show Answer
38. Supriya has following code to insert a record in table ’salesman’, but
getting error. Help her in writing appropriate code.
INSERT EMP VALUES(‘203’,’RAJU’, ‘DELHI’);
Show Answer
Show Answer
a. UNIQUE
Show Answer
41. DML is
a. Database Manipulation Language
b. Data Manipulation Language
c. Data Maintenance Language
d. Database Maintenance Language
Show Answer
b. Data Manipulation Language
42. Char(n) and varchar(n) are used to store _ length and variable data
a. Variable, fixed
b. Fixed, variable
c. Equal, equal
d. None of these
Show Answer
b. Fixed, variable
43. Which of the following provides the ability to query information from the database
and insert
tuples into, delete tuples from, and modify tuples in the database?
a. DML(Data Manipulation Language)
b. DDL(Data Definition Language)
c. Query
d. Relational Schema
Show Answer