RDBMS and HTML Mock Test - 1549084911357

Download as pdf or txt
Download as pdf or txt
You are on page 1of 20

Shout4Education

Question-wise Details

Section #1

Question 1: Time: 7 Sec Marks: 1/ 1

Consider table Book(bookId, bookName,copies) has following records.

bookId bookName copies

--------- -------------- ------------

n
tio
B1 JAVA 0

B2 4

ca
du
B3 ORACLE 2
4E
ut

Identify the output of the SQL statement given below.


Sh

SELECT COUNT(bookName) FROM Book WHERE copies>0;

Choose the most apprpriate option.

Shout4Education
2 / 21
Shout4Education
Options Response Answer

Question 2: Time: 21 Sec Marks: 1/ 1

Consider the table Products(pid,pname,pcost). Identify the appropriate SQL statement to rename the table to ProductsInfo .

n
Choose most appropriate option.

tio
Options Response Answer

ca
ALTER TABLE Products RENAME
ProductsInfo; du
ALTER TABLE Products UPDATE TO
ProductsInfo;
4E

ALTER TABLE RENAME Products TO


ProductsInfo;
ut

ALTER TABLE Products RENAME TO


ProductsInfo;
o
Sh

Question 3: Time: 42 Sec Marks: 1/ 1

Consider table Product(productId, price). Identify the appropriate SQL statement to display all products whose price range is
2500 and 5000(exclusive 2500 and 5000). Choose two most appropriate options.

Shout4Education
3 / 21
Shout4Education
Options Response Answer

SELECT * FROM Product WHERE


price BETWEEN 2500 AND 5000;

SELECT * FROM Product WHERE


price>2500 AND price<5000;

SELECT * FROM Product WHERE


price>=2500 AND price<=5000;

SELECT * FROM Product WHERE


price BETWEEN 2501 AND 4999;

Candidate responses were captured before updation of the question with restrictions on maximum responses.

n
tio
Question 4: Time: 16 Sec Marks: 1/ 1

ca
Consider table Department(deptId,deptName). Which of the following query is used to display the department details whose
deptname has second letter as 'a' and second last letter as 'e'? Choose most appropriate option.
du
Options Response Answer
4E

SELECT * FROM department WHERE


deptname LIKE '_a%e_';
ut

SELECT * FROM department WHERE


deptname LIKE 'a%e_';
o

SELECT * FROM department WHERE


Sh

deptname LIKE '%a%e_';

SELECT * FROM department WHERE


deptname LIKE 'a%e%';

Question 5: Time: 1 Min 22 Sec Marks: 1/ 1

Consider table Account(accId, acctype, balance). Identify the appropriate SQL statement to display account details in the
ascending order of balance and in the descending order of accId if the balance is same. choose most appropriate option.

Shout4Education
4 / 21
Shout4Education
Options Response Answer

SELECT * FROM Account ORDER BY


balance, accId DESC;

SELECT * FROM Account ORDER BY


balance ASC, accId;

SELECT * FROM Account ORDER BY


accId DESC, balance ASC;

SELECT * FROM Account ORDER BY


accId DESC, balance;

n
Question 6: Time: 49 Sec Marks: 1/ 1

tio
Consider table Students(sid NUMBER(3), sname VARCHAR2(10), scontact NUMBER(10) ) is already created in the database.

ca
It is required to change the data type of the column "scontact" to VARCHAR2(15). Which of the following is Correct for the
above requirement?
du
Note: sid column is primary key.
4E

Choose most appropriate option.


ut

Options Response Answer


o

To change the data type of a column, it


Sh

is important to ensure that the


corresponding column is not having
data for any of the record

There are no criteria to be followed. We


can change the datatype of the column
irrespective of the data

Data type can be changed only for


primary key column

It is not possible to change the data


type of a column

Shout4Education
5 / 21
Shout4Education
Question 7: Time: 18 Sec Marks: 1/ 1

Identify the CORRECT statements with respect to constraints.

(i) A table can have only one FOREIGN KEY

(ii) A column with UNIQUE constraint cannot have NULL value

choose most appropriate option.

Options Response Answer

n
only (i)

tio
only (ii)

ca
both (i) and (ii)

neither (i) nor (ii)


du
4E

Question 8: Time: 1 Min 31 Sec Marks: 0/ 1


ut

Consider table Item(itemId, category, unitprice). Identify the appropriate SQL statement to display the category and count of
items in each category in the ascending order of item count. It should display the item details only if the count of item is greater
o

than 1.
Sh

Choose most appropriate option.

Shout4Education
6 / 21
Shout4Education
Options Response Answer

SELECT category,count(itemId) FROM


item WHERE Count(itemId)>1 GROUP
BY category ORDER BY
COUNT(itemId);

SELECT category,count(itemId) FROM


item HAVING Count(itemId)>1 ORDER
BY COUNT(itemId);

SELECT category,count(itemId) FROM


item GROUP BY category HAVING
Count(itemId)>1 ORDER BY
COUNT(itemId);

n
SELECT category,count(itemId) FROM

tio
item GROUP BY category HAVING
Count(itemId)>1 ORDER BY itemId;

ca
du
Question 9: Time: 11 Sec Marks: 1/ 1
4E

Consider the Tables given below:


ut

Product(productId,productName)
o
Sh

ProductOrder(orderId,productId,quantity)

productId column of ProductOrder is a Foreign key reffering to Product Table. Identify the appropriate SQL statement which will
fetch the ProductId,ProductName,OrderId for all the Product ordered and display 'Yet to be Ordered' if a product has not been
ordered till now.

Choose most appropriate option.

Shout4Education
7 / 21
Shout4Education
Options Response Answer

SELECT
p1.productId,p1.productName,NVL(p2.
orderId,'Yet to be Ordered') FROM
Product p1 INNER JOIN ProductOrder
p2 ON p1.productId=p2.productId;

SELECT
p1.productId,p1.productName,NVL(p2.
orderId,'Yet to be Ordered') FROM
Product p1 LEFT OUTER JOIN
ProductOrder p2 ON
p1.productId=p2.productId;

SELECT

n
p1.productId,p1.productName,NVL(p2.

tio
orderId,'Yet to be Ordered') FROM
Product p1 RIGHT OUTER JOIN

ca
ProductOrder p2 ON
p1.productId=p2.productId; du
SELECT
p1.productId,p1.productName,NVL('Yet
to be Ordered',p2.orderId) FROM
4E

Product p1 LEFT OUTER JOIN


ProductOrder p2 ON
p1.productId=p2.productId;
o ut
Sh

Question 10: Time: 19 Sec Marks: 1/ 1

Shout4Education
8 / 21
Shout4Education
Consider the tables given below.

Customer(customerId,customerName)

Book(bookId, bookName)

Purchase(purchaseId, bookId, customerId)

bookId and customerId in purchase table are foreign keys referring to Book and Customer tables respectively. Which is the
CORRECT SQL statement to retrieve customer name and book name for all books purchased by customers?

n
tio
Choose most appropriate option.

Options Response Answer

ca
SELECT
c.customerName,b.bookName FROM
du
customer c INNER JOIN purchase p
ON c.customerId=p.customerId SELF
4E

JOIN book b ON b.bookid=p.bookid;

SELECT
ut

c.customerName,b.bookName FROM
customer c INNER JOIN purchase p
o

INNER JOIN book b ON


b.bookid=p.bookid AND
Sh

c.customerId=p.customerId;

SELECT
c.customerName,b.bookName FROM
customer c INNER JOIN purchase p
ON c.customerId=p.customerId INNER
JOIN book b ON b.bookid=p.bookid;

SELECT
c.customerName,b.bookName FROM
customer c INNER JOIN purchase p
ON c.customerId=p.customerId;

Question 11: Time: 19 Sec Marks: 1/ 1

Shout4Education
9 / 21
Shout4Education

Consider the table Account (accid, balance, accountType). The following constraints to be enforced.

1. Accid should be unique and Not Null

2. Account type should be 'C' or 'S'. Balance should be greater than 1000 and 3000 for account type 'C' and 'S' respectively

Identify the CORRECT SQL statement to create the Account table with the above mentioned constraints. Choose most
appropriate option.

n
tio
ca
du
4E
o ut
Sh

Shout4Education
10 / 21
Shout4Education
Options Response Answer

CREATE TABLE account( accid


NUMBER(2) CONSTRAINT acc_pk
PRIMARY KEY, balance NUMBER(4),
accountType CHAR, CONSTRAINT
acc_chk CHECK (accountType='S'
AND balance>3000) AND
(accountType='C' AND balance
>1000)) );

CREATE TABLE account( accid


NUMBER(2) CONSTRAINT acc_pk1
PRIMARY KEY, balance NUMBER(4)
CONSTRAINT acc_chk

n
CHECK(balance>1000 OR balance
>3000), accountType CHAR

tio
CONSTRAINT acc_chk CHECK
(accountType='S' OR accounTtype='C')

ca
);

CREATE TABLE account( accid


du
NUMBER(2) CONSTRAINT acc_pk
PRIMARY KEY, balance NUMBER(4),
accountType CHAR, CONSTRAINT
4E

acc_chk1 CHECK (accountType='S'


AND balance>3000), CONSTRAINT
ut

acc_chk2 CHECK (accountType='C'


AND balance >1000) );
o

CREATE TABLE account( accid


Sh

NUMBER(2) CONSTRAINT acc_pk


PRIMARY KEY, balance NUMBER(4),
accountType CHAR, CONSTRAINT
acc_chk CHECK ( (accountType='S'
AND balance>3000) OR
(accountType='C' AND balance
>1000)) );

Question 12: Time: 1 Min 2 Sec Marks: 0/ 1

Shout4Education
11 / 21
Shout4Education
Consider the below tables.

Customer(customerId,customerName) - customerId is primary key Account(accountId,accountType,balance,customerId) -


accountId is primary key and customerId is foreign key.

Which is the CORRECT SQL statement to retrieve customerId, customerName, accountId and balance for all customers. It
should also display the details of the customers who are not having any account.

Choose most appropriate option.

n
tio
Options Response Answer

SELECT

ca
c.customerId,c.customerName,a.accou
ntId,a.balance FROM customer c
RIGHT OUTER JOIN account a ON
du
c.customerId=a.customerId;

SELECT
4E

c.customerId,c.customerName,a.accou
ntId,a.balance FROM account a LEFT
ut

OUTER JOIN customer c ON


c.customerId=a.customerId;
o

SELECT
Sh

c.customerId,c.customerName,a.accou
ntId,a.balance FROM customer c
INNER JOIN account a ON
c.customerId=a.customerId;

SELECT
c.customerId,c.customerName,a.accou
ntId,a.balance FROM account a RIGHT
OUTER JOIN customer c ON
c.customerId=a.customerId;

Question 13: Time: 30 Sec Marks: 1/ 1

Shout4Education
12 / 21
Shout4Education
Which of the following are the CSS selectors?

a) Element Selector

b) Form Selector

c) Class Selector

Choose most appropriate option.

Options Response Answer

n
a and b

tio
a and c

ca
b and c

a, b and c
du
4E

Question 14: Time: 14 Sec Marks: 1/ 1


ut

Assume below code present in the HEAD tag of a HTML page.


o
Sh

<style> #myclass{ background-color: lightgrey; color:blue; } </style>

Identify the appropriate HTML code to Use the Style given Above. Choose most appropriate option.

Shout4Education
13 / 21
Shout4Education
Options Response Answer

<h1 id="myclass">Welcome to My

Homepage</h1>

<h1 style="myclass">Welcome to My

Homepage</h1>

n
tio
<h1 class="myclass">Welcome to My

ca
Homepage</h1>
du
<h1 class=".myclass">Welcome to My
4E

Homepage</h1>
o ut
Sh

Question 15: Time: 27 Sec Marks: 1/ 1

Shout4Education
14 / 21
Shout4Education
Which of the following is/are the inline html elements?

(i) <i>

(ii) <h6>

(iii) <a>

n
Choose most appropriate option.

tio
Options Response Answer

ca
(i) and (iii)

(ii) and (iii)


du
only (i)
4E

(i), (ii) and (iii)


ut

Question 16: Time: 57 Sec Marks: 1/ 1


o
Sh

Shout4Education
15 / 21
Shout4Education
What would be displayed in alert box while executing the below code?

1 <html>
2 <head>
3 <script>
4 var data1=100;
5 var data2="100";
6 if(data1==data2)
7 { // Line - X
8 alert(data1+data2);
9 }
10 else
11 {
12 alert("not equal");
13 }
14 </script>
15 </head>
16 <body>

n
17 </body>
18 </html>

tio
19

ca

du
Choose most appropriate option.
4E

Options Response Answer


ut

100100
o

200
Sh

not equal

Error at Line-X : Cannot compare


number and string type

Question 17: Time: 37 Sec Marks: 1/ 1

Shout4Education
16 / 21
Shout4Education
Which of the following are CORRECT statement?

a) onClick() and onFocus() are DOM events

b) In Java Script, a browser is represented by an implicit object called Document

c) Java Script is used for Server side validation

n
Choose most appropriate option.

tio
Options Response Answer

ca
a and c

only a
du
b and c
4E

a and b
ut

Question 18: Time: 10 Sec Marks: 1/ 1


o
Sh

Shout4Education
17 / 21
Shout4Education
What would be the color of the text "Bengaluru" and "India" while executing the below html and css code? Assume that "Black"
is the default color if there is no style applied.

<html>

<head>

<style> p{ color:red; } .c1{ color:green; } </style>

n
tio
</head>

ca
<body>
du
<p> Bengaluru </p>
4E

<p class="c1"> India </p>


ut

</body>
o
Sh

</html>

Choose most appropriate option.

Shout4Education
18 / 21
Shout4Education
Options Response Answer

Bengaluru - Red,India - Green

Bengaluru - Red,India - Red

Bengaluru - Red,India - Black

Bengaluru - Black,India - Black

Question 19: Time: 44 Sec Marks: 1/ 1

Condsider the javascript code given below. What would be the print values from line 1 and line 2 on execution?

n
tio
1 <html>

ca
2 <body>
3 <p id="id1"></p><!-- line 1-->
4 <p id="id2"></p><!-- line 2-->
5 <script>
du
6 var y=10;
7 myFunction();
8 document.getElementById("id1").innerHTML = y;
4E

9 document.getElementById("id2").innerHTML = window.y;
10 function myFunction()
11 {
12 y=20;
13 y=y+window.y
ut

14 }
15 </script>
16 </body>
o

17 </html>
Sh

18

Choose most appropriate option.

Shout4Education
19 / 21
Shout4Education
Options Response Answer

10 30

10 40

10 10

40 40

Question 20: Time: 10 Sec Marks: 0/ 1

Refer the HTMLcode given below.

n
tio
ca
1 <html> <body>
2 <table border="1">
3 <tr><th>A</th>
du
4 <th colspan="2">B</th>
5 </tr>
6 <tr> <th rowspan="3">C</th>
7 <th>D</th>
4E

8 <th>E</th>
9 </tr>
10 <tr>
11 <th>A</th>
ut

12 <th rowspan="2">B</th>
13 </tr>
14 <tr>
o

15 <th>D</th>
16 </tr>
Sh

17 </table>
18 </body>
19 </html>
20

How many cells will be displayed when the page is displayed on the browser? Choose most appropriate option.

Shout4Education
20 / 21
Shout4Education
Options Response Answer

10

n
tio
ca
du
4E
ut
o
Sh

Shout4Education
21 / 21

You might also like