DAV Informatics Practices Pre-Mid Term Examination 2019

1. Answer the following

a) What is the difference between WAN and LAN?
The networks spread across countries are known as WAN.
Small computer networks that are confined to a localized area are known as LAN.
b) What is a domain name? How is it different from URL?
A domain name is a unique name assigned to a website. The URL is the address of a document on the website.
c) Identify the following devices:
(i) An intelligent device that connects several nodes to form a network and redirects the received information only to intended node(s).
Switch
(ii) Mr. Vikash, an IT help-desk executive needs to remotely login a customer’s PC to provide him technical support. Name the remote access software.
Telnet
d) Expand the following terms:
(i) FSF Free Software Foundation
(ii) PPP Point to Point Protocol
e) What is open source software? Give two examples.
Open Source Software refers to software whose source code is available to customers and it can be modified or redistributed without any limitation. Examples include Linux, Mozilla, MySQL, Apache Server, PostgreSQL, Pango, OpenOffice, Tomcat, PHP, Python.

2. Answer the following

a) Find the output of the following code fragment:

int s = 14;
if(s < 20)
    System.out.print("Under");
else
    System.out.print("Over");
System.out.print("the limit");

OUTPUT:
Underthe limit
b) Rewrite the following program segment using while loop:

int i, j;
for(i = 1, j = 2; i <= 6; i++, j += 2)
    System.out.println(i++);
System.out.println("Finished!!!");

Code in while loop:

int i = 1, j = 2;
while(i <= 6){
    System.out.println(i++);
    i++;
    j += 2;
}
System.out.println("Finished!!!");

c) Write Java code that takes value for a number (n) in jTextField1 and double its value which has to be displayed in jTextField2.
int n = Integer.parseInt(jTextField1.getText());
n *= 2;
jTextField2.setText(Integer.toString(n));

d) Mr. Sahil, a programmer in a VISA processing company, has written the following code:

int ch = Integer.parseInt(jTextField1.getText());
switch(ch){
    case 1:
    jTextField2.setText("Short Term Single Entry Visa Granted");
    case 2:
    jTextField2.setText("Short Term Multiple Entry Visa Granted");
    case 3:
    jTextField2.setText("Long Term Single Entry Visa Granted");
    case 4:
    jTextField2.setText("Long Term Multiple Entry Visa Granted");
    default:
    jTextField2.setText("Invalid Entry");
}

No matter what value is being entered in the text field jTextField1, this program always gives a message “Invalid Entry”. Help Mr. Sahil in identifying the problem and its reason. Also suggest him a suitable correction in the code.

Mr. Sahil is getting this output because he has not given the ‘break’ statement in each case of the switch statement.
Following would be the correct code:

int ch = Integer.parseInt(jTextField1.getText());
switch(ch){
    case 1:
    jTextField2.setText("Short Term Single Entry Visa Granted");
    break;
    case 2:
    jTextField2.setText("Short Term Multiple Entry Visa Granted");
    break;
    case 3:
    jTextField2.setText("Long Term Single Entry Visa Granted");
    break;
    case 4:
    jTextField2.setText("Long Term Multiple Entry Visa Granted");
    break;
    default:
    jTextField2.setText("Invalid Entry");
}

Q3. Answer the following

a) Mention any two examples of common Database Management Systems.
MySQL, Oracle.
b) Write the full forms of the following:
(i) DDL – Data Definition Language
(ii) DML – Data Manipulation Language
c) Ms. Archana, a class XI student has just started learning MySQL. Help her in understanding the basic difference between ALTER and UPDATE commands with suitable examples. Also suggest her suitable commands for the following purpose:
(i) To display the list of the database already existing in MySQL.
(ii) To use the database named ‘city’.
(iii) To remove the pre-existing database named ‘clients’.
(iv) To remove all the records of the table named ‘club’ at one go along with its structure permanently.
The ALTER command is used to change the table structure of an existing table.
Example: alter table employee add(telephone integer);
The UPDATE command is used to update data rows in tables.
Example: update employee  set gross = gross * 2;
(i) show databases;
(ii) use city;
(iii) drop database clients;
(iv) drop table club;
d) Table ’emp’ is shown below:

ID Name Age Address Salary Phone
1 Siddharth 25 A-4, Ashok Vihar, Delhi 62000 98110766656
2 Chavi 23 B-21, Model Town, Delhi 71000 99113423989
3 Karan 26 KC-24, North Avenue, Bhopal 65000 98105393578
4 Raunaq 22 A-152, Gomti Nagar, Lukhnow 89000 99101393576
5 Kunal 27 B-5/45, Uday Park, Delhi 80000 97653455654

Write commands in SQL for the following:
(i) To display the list of all the employees below 25 years age.
select * from emp where age < 25;
(ii) To list names and respective salaries in descending order of salary.
select name, salary from emp order by salary desc;
(iii) To display salary of employees with names starting with ‘K’.
select name, salary from emp where name like 'K%';
(iv) To list names and addresses of those persons who have ‘Delhi’ in their address.
select name, address from emp where address like '%Delhi';

Q4. Answer the following

a) Ms. Meena is unable to understand the statement “Java is a case-sensitive language”. Help her in understanding the above mentioned statement by giving suitable examples.
Java is a case-sensitive language because letters in uppercase are treated differently than the letters in lowercase. For example, keywords like void, double, class are always written in lowercase letters. Identifiers like ‘hello’ is different than ‘Hello’.
b) Ms. Rachel is designing a frame in Netbeans in which she has used four radio button controls. She wants only one radio button out of four should be selected at a time. Which property of the radio button should be selected to achieve the same?
The buttonGroup property of the radio button should be selected.
c) Anju, a beginner in Java programing has written the following code with some mistakes:

int k = 0;
string s = "Save Earth";
int l = s.length;
for(int i = 0; k < l; i++){
    jTextArea1.append(s + \n);
    k++;
};

Help her in identifying and correcting the errors.

int k = 0;
String s = "Save Earth";
int l = s.length();
for(int i = 0; i < l; i++){
    jTextArea1.append(s + "\n");
    k++;
}

Convert the correct code into do-while looping statement.

int k = 0;
int i = 0;
String s = "Save Earth";
int l = s.length();
do{
    jTextArea1.append(s + "\n");
    k++;
    i++;
}while(i < l);

OR

Observe the given code:

int ctr = 10;
while(ctr > 5){
    ctr = ctr - 2;
}

Attempt the following questions based on the above code:
(i) How many times the above loop will run and what will be the value of ‘ctr’ immediately after exiting from the loop?
The loop will run 3 times.
The value of ‘ctr’ will be 4 after exiting from the loop.
(ii) Out of entry-controlled or exit-controlled loop, the above loop will come under which category and why?
The above loop is entry-controlled because the condition is checked before the loop body is executed.

Q5. Answer the following

a) Write SQL query to create a table ‘books’ with the following structure:

FULL NAME Data Type Size Constraint
BOOK_ID Integer 2 Primary Key
BOOK_NAME Varchar 20
CATEGORY Varchar 10
ISSUE_DATE Date
create table books(
    book_id integer(2) not null primary key,
    book_name varchar(20),
    category varchar(10),
    issue_date date
);

OR

Write the output of the following queries:
(i) select concat(char(77, 89), char(83, 67, 72, 79, 79, 76));
MYSCHOOL
(ii) select round(25.77, -1), truncate(25.77, -1);
30 20

b) Chhavi has created a table named ‘orders’. She has been asked to increase the value of a column named ‘salesamount’ by 20. She has written the following query for the same:
alter table orders add salesamount = salesamount + 20;
Is it the correct query? Justify your answer.
The code is incorrect because Chhavi should have used the update command to modify data in the table. Below is the correct code:
update orders set salesamount = salesamount + 20;
c) Identify the error and rewrite the correct query:
select * from student where name = 'A%';
Correct code:
select * from student where name like 'A%';

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.