InterviewSolution
This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.
| 10101. |
Write the value that will be stored in variable a after execution of the following code if : (i) initial value of a is 8. (ii) initial value of a is 10.int b = 9 ;if(a > b)a = a + 5 ;a = a + 2 ; |
|
Answer» (i) Value of a = 10, if initial value of a is 8 (ii) Value of a = 17, if initial value of a is 10 |
|
| 10102. |
Write the value that will be stored in variable num and sum after execution of following code :int sum = 0, num = -2;do{ sum = sum + num;num++;}while (num < 1); |
|
Answer» num = 1, sum = -2. |
|
| 10103. |
Write the value that will be stored in variable a after execution of the following code if :(i) initial value of a is 8.(ii) initial value of a is 10.int b = 9;if (a > b) a = a + 5;a = a + 2; |
|
Answer» (i) Value of a is 10 (ii) Value of a is 17 |
|
| 10104. |
Write the code given below using 'for' loop instead of 'while' loop :int i = 1;while (i < = 5){if(i * i ==4)jTextField1. setText (" " + i);i = i + 1;} |
|
Answer» int i; for(i = 1; i <= 5; i++) { if(i * i == 4) jTextField1.setText(" "+i); |
|
| 10105. |
Write the code given below using 'for' loop instead of 'while' loop :int i = 1;while (i < = 5){if (i * i == 4)jTextField1. setText (" " + i);i = i + 1;} |
|
Answer» Following code using for loop : int i; for (i = 1; i < 5; i++) { if (i * i == 4) jTextField1.setText (" " + i); } |
|
| 10106. |
What values will be displayed in JOptionPane when the following code is executed?int a = 5, b = 2,while (a < 20){ a = a + b; b = a - b;JOptionPane. showMessageDialog (null,a);} |
|
Answer» No values will be displayed in JoptionPane because it will give exception in thread "main", due to null. |
|
| 10107. |
What values will be displayed in JOptionPane when the following code is executed ?int a = 5, b = 2;while (a < 20){a = a + b;b = a – b;JOptionPane. showMessageDialog (null,a);} |
|
Answer» 7 12 19 31 |
|
| 10108. |
Identify the error in the following code :switch (c){case 9.0 : a = a + 2 ;break ;case 8.0 : a = a + 3 ;break ; } |
|
Answer» Default case is missing in the given switch code which is optional but necessary. When user gives a wrong choice then default case’s statement is executed. |
|
| 10109. |
Name SQL Single Row functions (for each of the following) that(i) returns a number.(ii) returns lowercase letters.(iii) returns names of days. For example : "Monday", ,,Tuesday".(iv) returns weekday number. For example : 1 for Sunday,2 for Monday, 3 for Tuesday. |
|
Answer» (i) ASCII ( ) (ii) LCASE ( ) (iii) DAYNAME () (iv) DAYOFWEEK ( ) |
|
| 10110. |
Name SQL Single Row functions (for each of the following) that (i) returns a number. (ii) returns lowercase letters. (iii) returns names of days.For example: “Monday”, “Tuesday”. (iv) returns weekday number.For example : 1 for Sunday, 2 for Monday, 3 for Tuesday. |
|
Answer» (i) ASCII () function returns a number. (ii) LCASE () function returns lowercase letters . (iii) DAYNAME () function returns names of days. (iv) DAYOFWEEK () function returns weekday number |
|
| 10111. |
Name SQL Single Row functions (for each of the following) that(i) returns a number.(ii) returns lowercase letters.(iii) returns names of days. For example : "Monday", "Tuesday".(iv) returns weekday number. For example : 1 for Sunday, 2 for Monday, 3 for Tuesday |
|
Answer» (i) length()/ instr()/ round()/ truncate() or any other correct Single Row Function that returns a number (ii) lower() / lcase () (iii) dayname () (iv) dayofweek () |
|
| 10112. |
'Class' table has columns RNO and NAME.The following statements are executedSET AUTOCOMMIT = 0;INSERT INTO CLASS VALUES (5, 'Rajiv');COMMIT;UPDATE CLASS SET NAME ='Rajeev' WHERE ID = 5;SAVEPOINT A;INSERT INTO CLASS VALUES (6, 'Chris');SAVEPOINT B;INSERT INTO CLASS VALUES (7, 'Feroze');SELECT * FROM CLASS;ROLLBACK TO B;SELECT * FROM CLASS;What will be the output of both the above given SELECT statements ? |
||||||||||||||
|
Answer» Output for first select statement :
|
|||||||||||||||
| 10113. |
‘Class’ table has columns RNO and NAME. The following statements are executed:SET AUTOCOMMIT = 0 : INSERT INTO CLASS VALUES (5, ‘Rajiv’) : COMMIT ; UPDATE CLASS SET NAME = ‘Rajeev’ WHERE ID = 5 ; SAVEPOINT A ; INSERT INTO CLASS VALUES (6, ‘Chris’) ; SAVE POINT B ; INSERT INTO CLASS VALUES (7, ‘Feroze’) ; SELECT * FROM CLASS ;ROLLBACK TO B ;SELECT * FROM CLASS ;What will be the output of both the above given SELECT statements? |
||||||||||||||
|
Answer» Output for the 1st SELECT * FROM Class ; statement -
Output for the llnd SELECT * FROM Class; statement
|
|||||||||||||||
| 10114. |
Define a class Candidate in C++ with the following specification :Private Members :A data members Rno(Registration Number) type longA data member Cname of type stringA data members Agg_marks (Aggregate Marks) of type floatA data members Grade of type charA member function setGrade () to find the grade as per the aggregate marks obtained by the student. Equivalent aggregate marks range and the respective grade as shown below.Aggregate MarksGrade>=80ALess than 80 and >=65BLess than 65 and >=50CLess than 50DPublic members:A constructor to assign default values to data members:Rno=0,Cname=”N.A”,Agg_marks=0.0A function Getdata () to allow users to enter values for Rno. Cname, Agg_marks and call function setGrade () to find the grade.A function dispResult( ) to allow user to view the content of all the data members. |
|
Answer» class Candidate { long Rno; char Cname[20]; float Agg_marks; char Grade; void setGrade() { if (Agg_marks>= 80) Grade = ‘A’; else if(Agg_marks<80 && Agg_marks>=65) Grade = ‘B’; else if (Agg_marks<65 && Agg_marks>=50) Grade =’C’; else Grade=’D’; } public: Candidate() { Rno=0; Strcpy(Cname,”N.A.”); Agg_marks=0.0; } void Getdata () { cout<<”Registration No”; cin>>Rno; cout<<”Name”; cin>>Cname; cout<<Aggregate Marks”; cin>>Agg_marks; setGrade(); } void dispResult() { cout<<”Registration No”<<Rno; cout<<”Name”<<Cname; cout<<Aggregate Marks”<<Agg_marks; } |
|
| 10115. |
'Class' table has columns RNO and NAME.The following statements are executedSET AUTOCOMMIT = 0;INSERT INTO CLASS VALUES (5, 'Rajiv'); COMMIT;UPDATE CLASS SET NAME = 'Rajeev' WHERE ID = 5;SAVEPOINT A;INSERT INTO CLASS VALUES (6, 'Chris'); SAVEPOINTB;INSERT INTO CLASS VALUES (7, 'Feroze'); SELECT * FROM CLASS;ROLLBACK TO B;SELECT * FROM CLASS;What will be the output of both the above given SELECT statements ? |
||||||||||||||||||||||||||||
|
Answer» (Case 1 : If RNO is treated as ID, the following solution should be accepted:) Output of SELECT statement 1 :
Output of SELECT statement 2 :
(Case 2 : If RNO is NOT treated as ID, the following should be accepted:) Output of SELECT statement 1 :
Output of SELECT statement 2 :
|
|||||||||||||||||||||||||||||
| 10116. |
Gives the table 'Player' with the following columns : Table : PlayerPCODEPOINTS1502NULL340Write the output of the following statements :(i) SELECT AVG (POINTS) FROM Player;(ii) SELECT COUNT (POINTS) FROM Player |
|
Answer» (i) AVG(POINTS)/45 (ii) COUNT(POINTS)/2 |
|
| 10117. |
Name two Data types that require data to be enclosed in quotes. |
|
Answer» char/varchar/date |
|
| 10118. |
Rewrite the following code using for loop:int attempt=0;while(attempt<=3){String login=jTextField1.getText();String pwd=jTextField2.getText();if(login.equals("XII") && pwd.equals("IP")){jOptionPane1.showMessageDialog(null, "Welcome");break;}elsejOptionPane1.showMessageDialog(null, "Pl try again");attempt++;} |
|
Answer» for(int attempt=0;attempt<=3;attempt++) { String login=jTextField1.getText(); String pwd=jTextField2.getText(); if(login.equals("XII") && pwd.equals("IP")) { jOptionPane1.showMessageDialog(null, "Welcome"); break; } else jOptionPane1.showMessageDialog(null, "Pl try again"); } |
|
| 10119. |
Name the Data type that should be used to store AccountCodes like "A1001" of Customers. |
|
Answer» char/varchar |
|
| 10120. |
In the table “Student”, Priya wanted to increase the Marks (Column Name: Marks) of those students by 5 who have got Marks below 33. She has entered the following statement:SELECT Marks + 5 FROM StudentWHERE Marks <33 :Identify errors (if any) in the above statement. Rewrite the correct SQL statement. |
|
Answer» Correct SQL statement : UPDATE Student SET Marks = Marks +5 WHERE Marks <33 ; |
|
| 10121. |
I. Help Manish in identifying the incorrect variable name with justification from the following:i. [email protected]; ii. fee; iii. userid; iv. avg marks;II. Write Java code to declare a variable named Price of integer type. Assign a value 10 to this variable. Overwrite the value of price with its double value. Decrease the value of price by 5. |
|
Answer» I. (i) [email protected]; // Special symbols like "@" is not allowed in variable name (iv) avg marks;// Spaces are not allowed in variable name II. int price; price=10; price=price*2; price=price-5; |
|
| 10122. |
Mention any two example of common Database Management System. |
|
Answer» MySQL, Ingres, Postgres, Oracle etc. |
|
| 10123. |
I. Help Manish in identifying the incorrect variable name with justification from the following:i. [email protected]; ii. fee; iii. userid; iv. avg marks;II. Write Java code to declare a variable named Price of integer type. Assign a value 10 to this variable. Overwrite the value of price with its double value. Decrease the value of price by 5. |
|
Answer» I. (i) [email protected]; // Special symbols like "@" is not allowed in variable name (iv) avg marks;// Spaces are not allowed in variable name II. int price; price=10; price=price*2; price=price-5; |
|
| 10124. |
(i) Ms. Sangeeta wants to add few descriptive lines in the HTML code which should not be displayed on the webpage rather should remain inactive during execution. Suggest her the solution along with example.(ii) How HTML is different from XML? Mention any two point of difference. |
|
Answer» (i) She should use comments in HTML. Any text to make comments in HTML, should be preceded by <! and should end with -> Example: <body> <!- This is only used for comment -> Welcome </body> (ii)
|
|
| 10125. |
What is MySQL used for? Abhay wants to start learning MySQL. From where can he obtain the MySQL software? |
|
Answer» MySQL is a Relational Database Management System (RDBMS), used for adding, accessing and processing data in a database. Abhay can download the MySQL software setup from Internet. |
|
| 10126. |
What is MySQL used for? Abhay wants to start learning MySQL. From where can he obtain the MySQL software? |
|
Answer» MYSQL is Open Source Relational Database Management System. It is used for adding accessing and managing data in a database. Abhay can download the MYSQL from its official website mysql.com or just by searching it on Google to get the links for third part platforms also. |
|
| 10127. |
In the table "Student", Priya wanted to increase the Marks (Column Name : Marks) of those students by 5 who have got Marks below 33. She has entered the following statement : SELECT Marks+5 FROM Student WHERE Marks<33;Identify errors (if any) in the above statement. Rewrite the correct SQL statement. |
|
Answer» Error : UPDATE should be used instead of SELECT Correct SQL statement: UPDATE Student SET Marks= Marks+5 WHERE Marks<33;. |
|
| 10128. |
Rewrite the following code using switch case:int day=Integer.parseInt(jTextField1.getText());if(day>=1 && day<=5)jOptionPane1.showMessageDialog(this, "Working Day");else if(day>=6 && day<=7)jOptionPane1.showMessageDialog(this, "Off Day");elsejOptionPane1.showMessageDialog(this, "Invalid Entry"); |
|
Answer» int day=Integer.parseInt(jTextField1.getText()); switch(day) { case 1: case 2: case 3: case 4: case 5: jOptionPane1.showMessageDialog(this, "Working Day"); break; case 6: case 7: jOptionPane1.showMessageDialog(this, "Off Day"); break; default: jOptionPane1.showMessageDialog(this, "Invalid Entry"); } |
|
| 10129. |
What will be the output of the following : (i) SELECT ROUND(22.417) + POW(4,3) ;(ii) SELECT LOWER (SUBSTR (TRIM (‘KENDRIYA VIDYALAYA SANGATHAN’), 4,10));(iii) SELECT LEFT(TRIM(‘IPL2014-12APR’),5);(iv) SELECT CONCAT(CONCAT(‘INFORM’,’ATICS’),’PRACTICES’); |
|
Answer» (i) 86. (ii) driya vidy (iii) IPL20 (iv) INFORMATICSPRACTICES |
|
| 10130. |
What is MySQL used for ? Abhay wants to start learning MySQL. From where can he obtain the MySQL software ? |
Answer»
(ii) For obtaining MySQL , Abhay has the following options :
|
|
| 10131. |
After creating the “employee” database, you want to use it. Write the command that you should give. |
|
Answer» USE employee; |
|
| 10132. |
Write the purpose of HTML. Distinguish between tag and tag. |
|
Answer» HTML is used to create web page(s). <P> tag is used to introduce a paragraph while <BR> tag is used to introduce a line break on a web page. Note: as paragraph tag and as line break tag to be accepted as difference |
|
| 10133. |
Rewrite the following code using switch statement :if (code == 'A')allowance = 3500;else if (code == 'B')allowance = 3200;elseallowance = 2000; |
|
Answer» switch(code) { case ‘A’ : allowance = 3500; break ; case ‘B’ : allowance = 3200; break ; default : allowance = 2000; } Note: 65 in place of ‘A’ and 66 in place of ‘B’ should be accepted |
|
| 10134. |
Distinguish between ComboBox and ListBox. When would you prefer using them over Radiobutton and Checkbox ? |
|
Answer» A ComboBox allows selection of one item from a set of items . while List Box provides a scroll able set of items from which one or more item(s) may be selected. When the number of items are more Combo box or List Box would be preferred over Radio button and Check box. |
|
| 10135. |
What is MySql? Write any two features? |
|
Answer» My SQL is Structured Query Language based open source Data Base Management System. Two features of MySQL are: (i) Cross-Platform support. (ii) Free to download and use. |
|
| 10136. |
Distinguish between ComboBox and ListBox. When would you prefer using them over Radiobutton and Checkbox? |
||||||
|
Answer» Differences between ComboBox and ListBox are as follows :
When you need to select multiple option then you would prefer using ListBox over CheckBox and when you need to select only one option then you would prefer using ComboBox over Radio Button. |
|||||||
| 10137. |
How is HAVING clause similar to WHERE clause? How is HAVING clause different from WHERE clause? Explain with the help of examples of each. |
|
Answer» Similarity: Having and Where both can be said to be as decision structures which are used in SQL to take an action to the data base or more specifically on any table of data base by matching a some sort of strings or values based on the values already present in the database. Difference : A WHERE clause is used is filter records from a result. The filter occurs before airy groupings are made. A HAVING clause is used to filter values from a group. |
|
| 10138. |
While creating a table named “Employee”, Mr. Rishi got confused as which data type he should chose for the column “EName” out of char and varchar. Help him in choosing the right data type to store employee name. Give valid justification for the same. |
|
Answer» Varchar would be the suitable data type for EName column as char data type is a fixed length data type while varchar is a variable length data type. Any employee‟s name will be of variable length so it‟s advisable to choose varchar over char data type. |
|
| 10139. |
What is a NULL value? |
|
Answer» In My SQL, the empty values are represented as NULL in a table. When we perform arithmetic calculations to a NULL value it will still remain null because mathematical operations cannot be performed on NULL value. |
|
| 10140. |
Given below is the 'Department' table :DEPCODEDEPNAME101ADMIN102RECEPTION103PERSONNELSET AUTOCOMMIT = 0;UPDATE Department SET DEPNAME = 'OFFICE' WHERE DEPNAME = 'ADMIN';INSERT INTO Department VALUES (104, 'HRD');UPDATE Department SET DEPNAME = 'FRONT OFFICE' WHERE DEPNAME = RECEPTION';COMMIT;DELETE FROM Department WHERE DEPNAME = 'FRONT OFFICE';ROLLBACK;SELECT * FROM Department;What will be the output of the above given SELECT statement? |
|
Answer» 101 OFFICE 102 FRONT OFFICE 103 PERSONNEL 104 HRD |
|
| 10141. |
Write the values of c and d after execution of following code : int a = 1;int b = 2,int c,int d;c = ++b;d = a++;c++; |
|
Answer» Output c = 4, d = 2. |
|
| 10142. |
Which command is used to change column size from VARCHAR (10) to VARCHAR (50)? |
|
Answer» ALTER command with MODIFY command should be used for this purpose. |
|
| 10143. |
Explain the following statement with the help of example :"In a transaction either all the SQL statements be committed or all rolled back." |
|
Answer» It means that when the set of SQL statements are executed, then there are two cases: Case-1 : All statements executed successfully. Case-2: Some instructions got successfully executed, some gives a sort of error. In case-1, the required action with the database will take place as per the executions of all of the instructions one by one. In case-2, even if some of the instructions are executed, but then too the action of them will be rolled back and hence will have no effect on the database. |
|
| 10144. |
Given below is the 'Department' table :DEPCODEDEPNAME101ADMIN102RECEPTION103PERSONNELSET AUTOCOMMIT = 0;UPDATE Department SET DEPNAME = 'OFFICE' WHERE DEPNAME = 'ADMIN' ;INSERT INTO Department SET DEPNAME = 'FRONT OFFICE' WHERE DEPNAME = 'RECEPTION';COMMIT;DELETE FROM Department WHERE DEPNAME = 'FRONT OFFICE';ROLLBACK;SELECT * FROM Department;What will be the output of the above give SELECT statement ? |
|
Answer» 101 OFFICE 102 FRONT OFFICE 103 PERSONNEL 104 HRD |
|
| 10145. |
In a hospital, the patients are allocated to wards. A database named 'Hospital' is created. One table in this database is: Ward with WardId, WardName, ' NumOfBeds as columns and WarId' as the primary key. Write another suitable table you could expect to see in the 'Hospital' database, with 3 suitable columns identifying Primary key and Foreign key in the table that you expect. |
|
Answer» CREATE TABLE PATIENT ( PID INT NOT NULL, PNAME VARCHAR(50), WardId INT NOT NULL, PRIMARY KEY(PID), FOREIGN KEY (WardId) REFERENCES Ward(WardId) ); |
|
| 10146. |
How is a database related to a table? |
|
Answer» A collection of tables used to store data to gain certain meaningful and beneficial outcome is termed as data base. |
|
| 10147. |
In a hospital, patients are allocated to wards. A database named 'Hospital' is created. One table in this database is : WARD with WardId, WardName, NumOfBeds as columns and WardId as the primary key.Write another suitable table you could expect to see in 'Hospital' database, with 3 suitable columns identifying Primary key and Foreign key. |
|
Answer» CREATE TABLE PATIENT ( PID INT NOT NULL, PNAME VARCHAR(50), WardId INT NOT NULL, PRIMARY KEY(PID), FOREIGN KEY (WardId) REFERENCES Ward(WardId) ); |
|
| 10148. |
Mr. Suman, a programmer in New Era Programming World has designed a registration page for a hobby club as shown below:Fee for different hobbies are as follows:HobbyFeeDancing1000Drawing1500Music2000Singing2500Help him in writing the code to do the following:(i) As per the hobby chosen in the hobby combo box, fee should be displayed in the respective text field named t1 as per the criteria given above after clicking on “Check Fee” button.(ii) If a candidate belongs to “Jr. Category” then a discount of 10% should be given in displayed in the text field.(iii) After clicking on the “Net Fee” button, Net Fee should be calculated and displayed in the respective text field as per the given formula:Net Fee = Fee – Discount(iv) Write suitable java code to close the application.(v) Write java statement to add a new hobby “Reading” in the combo box at run time. |
|
Answer» (i) int x=c1.getSelectedIndex(); int fee=0; if(x==0) fee=1000; else if(x==1) fee=1500; else if(x==2) fee=2000; else if(x==3) fee=2500; t2.setText(""+fee); (ii) double disc=0; int fee=Integer.parseInt(t2.getText()); if(r2.isSelected()) disc=fee*10/100; t3.setText(""+disc); (iii) double disc=Double.parseDouble(t3.getText()); int fee=Integer.parseInt(t2.getText()); double net=fee-disc; t4.setText(""+net); (iv) System.exit(0); (v) c1.addItem("Reading"); |
|
| 10149. |
Ariya wants to add another column'Gender' in the already existing table 'CUSTOMERS'. She has written the following statement. However, it has errors. Rewrite the correct statement.'MODIFY TABLE CUSTOMERS GENDER' char(1); |
|
Answer» ALTER TABLE CUSTOMERS ADD GENDER char(l); |
|
| 10150. |
Re-write the above given code through if-else statements.switch(application){case 0 : jTextField1.setText("RDBMS");case 1 : jTextField1.setText("BROWSER");case 2 : jTextField1.setText("OS"); break;case 3 : jTextField1.setText("PHOTO EDITOR"); break;default : jTextField1.setText("Application Software"); break;} |
|
Answer» if(application= =0) jTextField1.setText("RDBMS"); else if(application= =1) jTextField1.setText("BROWSER"); else if(application= =2) jTextField1.setText("OS"); else if(application= =3) jTextField1.setText("PHOTO EDITOR"); else jTextField1.setText("Application Software"); |
|