This section includes 7 InterviewSolutions, each offering curated multiple-choice questions to sharpen your Current Affairs knowledge and support exam preparation. Choose a topic below to get started.
| 1. |
What is meant by ‘Efficiency’? |
|
Answer» The ability to do things well, successfully, without wasting time. |
|
| 2. |
What is meant by ‘Perseverance’? |
|
Answer» Ability to continue to do something, even when it is difficult. |
|
| 3. |
The story ‘Deep Water’ has made you realise that with determination and perseverance one can accomplish the impossible. Write a paragraph in about 100 words on how a positive attitude and courage will aid you to achieve success in life? |
|
Answer» Determination and perseverance is a combination of attributes and abilities that drive people to set goals for themselves and then to take the initiative to achieve these goals. Douglas was able to overcome his fear of water by the values of positive attitude and courage. Initially he was afraid of water but his grit and determination made him get an instructor to train him and overcome his fear. Determination today leads to our success tomorrow. It is that innate quality in our soul, which comes to surface when we face difficult tasks. It is a reflection of our values taught to us by society and circumstances and enables us to overcome all obstacles. |
|
| 4. |
What is similar between tuples and lists. And what is difference between tuples and list. |
|
Answer» The key difference between the tuples and lists is that while the tuples are immutable objects the lists are mutable. This means that tuples cannot be changed while the lists can be modified. Tuples are more memory efficient than the lists. |
|
| 5. |
Given the following Dictionary dict{1:'A',2:'B',3:'C',6:'D',4:'E'}? what is the output of the command print(dict[6]) |
| Answer» It will show syntax error because you cannot use numerical as key in dictionary instead you have to use any alphabet | |
| 6. |
Consider the following code and answer the questions that follow: Book={1:'Thriller', 2:'Mystery', 3:'Crime', 4:'Children Stories'} Library ={'5':'Madras Diaries','6':'Malgudi Days'} i. Ramesh needs to change the title in the dictionary book from ‘Crime’ to ‘Crime Thriller’. He has written the following command: Book[‘Crime’]=’Crime Thriller’ But he is not getting the answer. Help him choose the correct command: a. Book[2]=’Crime Thriller’ b. Book[3]=’Crime Thriller’ c. Book[2]=(’Crime Thriller’) d. Book[3] =(‘Crime Thriller’) ii. The command to merge the dictionary Book with Library the command would be: a. d=Book+Library b. print(Book+Library) c. Book.update(Library) d. Library.update(Book) iii. What will be the output of the following line of code: print(list(Library)) a. [‘5’,’Madras Diaries’,’6’,’Malgudi Days’] b. (‘5’,’Madras Diaries’,’6’,’Malgudi Days’) c. [’Madras Diaries’,’Malgudi Days’] d. [‘5’,’6’] iv. In order to check whether the key 2 is present in the dictionary Book, Ramesh uses the following command: 2 in Book He gets the answer ‘True’. Now to check whether the name ‘Madras Diaries’ exists in the dictionary Library, he uses the following command: ‘Madras Diaries’ in Library But he gets the answer as ‘False’. Select the correct reason for this: a. We cannot use the in function with values. It can be used with keys only. b. We must use the function Library.values() along with the in operator c. We can use the Library.items() function instead of the in operator d. Both b and c above are correct.v. With reference to the above declared dictionaries, predict the output of the following code fragmentsCode 1Code 2Library = BookLibrary = Book. Copy (1)Library. pop (2)Library. Pop (2)Print (Library)Print (Library)Print (Book)Print (Book)a) Code 1 Code 2{1: 'Thriller', 2: 'Mystery', 3: 'Crime', 4: 'Children Stories'}{1: 'Thriller', 3: 'Crime', 4: 'Children Stories'}{1: 'Thriller', 2: 'Mystery', 3: 'Crime', 4: 'Children Stories'}{1: 'Thriller', 3: 'Crime', 4: 'Children Stories'}b.Code 1Code 2{2:’Mystery’}{1: 'Thriller', 3: 'Crime', 4: 'Children Stories'}{1: 'Thriller', 2: 'Mystery', 3: 'Crime', 4: 'Children Stories'}{1: 'Thriller', 3: 'Crime', 4: 'Children Stories'}c) Code 1Code 2{1: 'Thriller', 3: 'Crime', 4: 'Children Stories'}{1: 'Thriller', 3: 'Crime', 4: 'Children Stories'}{1: 'Thriller', 2: 'Mystery', 3: 'Crime', 4: 'Children Stories'}{1: 'Thriller', 3: 'Crime', 4: 'Children Stories'}d) Code 1Code 2{1: 'Thriller', 3: 'Crime', 4: 'Children Stories'}{1: 'Thriller', 3: 'Crime', 4: 'Children Stories'}{1: 'Thriller', 2: 'Mystery', 3: 'Crime', 4: 'Children Stories'}{1: 'Thriller', 2: 'Mystery', 3: 'Crime', 4: 'Children Stories'} |
|
Answer» i. Correct Answer: b ii. Correct Answer: d iii. Correct Answer: d iv. Correct Answer: b v. Correct Answer: c |
|
| 7. |
In a Database, there are two tables with the instances given below: Table: STUDENTSADMNONAMECLASSSECRNOADDRESSPHONE1211MEENA12AD4A-2632456781212VANI10AD1B-2554567891213MEENA12BA1NULLNULL1214KARISH10BB3AB - 2344567890 Table : SPORTSADM NO.GAMECOACH NAMEGRADE1215CRICKETMR. RAVIA1213 VOLLEYBALLMR. AMANDEEPB1211VOLLEYBALLMR. GOVARDHANA1212BASKETBALLMR TEWARIBI Choose the command to display name and game of those students whose address is available in students’ table.a. SELECT NAME, GAME FROM STUDENTS, SPORTS WHERE STUDENTS.ADMNO=SPORTS.ADMNO AND ADDRESS IS NOT NULL; b. SELECT NAME, GAME FROM STUDENTS, SPORTS WHERE STUDENTS.ADMNO=SPORTS.ADMNO AND ADDRESS IS NULL; c. SELECT NAME, GAME FROM STUDENTS, SPORTS WHERE STUDENTS.ADMNO=SPORTS.ADMNO, ADDRESS IS NULL; d. SELECT NAME, GAME FROM STUDENTS, SPORTS WHERE STUDENTS.ADMNO=SPORTS.ADMNO NOT ADDRESS IS NULL;II Identify the statement to delete a column phone from the table students. a. ALTER TABLE STUDENTS DROP PHONE; b. DROP PHONE; c. UPDATE DROP PHONE; d. DELETE FROM STUDENTS WHERE DROP PHONE;III Choose the command to display Name of the students who are studying in class 12 and their corresponding Coach names a. SELECT NAME, COACHNAME FROM STUDENTS, SPORTS WHERE CLASS LIKE “12%” AND STUDENTS.ADMNO =SPORTS.ADMNO; b. SELECT NAME, COACHNAME FROM STUDENTS, SPORTS WHERE CLASS LIKE “12%” AND STUDENTS.ADMNO= SPORTS.ADMNO; c. SELECT NAME, COACHNAME FROM STUDENTS, SPORTS WHERE CLASS LIKE “12%” AND ADMNO.STUDENTS =ADMNO.SPORTS; d. SELECT NAME, COACHNAME FROM STUDENTS, SPORTS WHERE CLASS LIKE= “12%” AND STUDENTS.ADMNO =SPORTS.ADMNO;VI which two select queries will give the same output A. SELECT NAME, GRADE FROM STUDENTS,SPORTS WHERE ADDRESS IS NULL AND STUDENTS.ADMNO =SPORTS.ADMNO ; B. SELECT NAME, GRADE FROM STUDENTS,SPORTS WHERE ADDRESS IS NOT NULL AND STUDENTS.ADMNO =SPORTS.ADMNO ; C SELECT NAME, GRADE FROM STUDENTS,SPORTS WHERE ADDRESS IS NULL OR STUDENTS.ADMNO=SPORTS.ADMNO ; D. SELECT ST.NAME, SP.GRADE FROM STUDENTS ST,SPORTS SP WHERE ADDRESS IS NULL AND ST.ADMNO=SP.ADMNO ; a. A AND B b. B AND C c. A AND D d. C AND DV. Choose the command to count the number of students who play volleyball a. SELECT COUNT(*) FROM STUDENTS,SPORTS WHERE GAME=”VOLLEYBALL” AND STUDENTS.ADMNO=SPORTS.ADMNO ; b. SELECT COUNT(GAME) FROM STUDENTS,SPORTS WHERE GAME=”VOLLEYBALL” AND STUDENTS.ADMNO=SPORTS.ADMNO ; c. SELECT COUNT(*) FROM STUDENTS,SPORTS WHERE GAME=”VOLLEYBALL” ; d. SELECT COUNT(*) FROM STUDENTS,SPORTS WHERE SPORTS=”VOLLEYBALL” AND STUDENTS.ADMNO=SPORTS.ADMNO |
|
Answer» I a. SELECT NAME, GAME FROM STUDENTS, SPORTS WHERE STUDENTS.ADMNO=SPORTS.ADMNO AND ADDRESS IS NOT NULL; II a. ALTER TABLE STUDENTS DROP PHONE; III Correct Answer: c. A AND D IV a. SELECT NAME, COACHNAME FROM STUDENTS,SPORTS WHERE CLASS LIKE “12%” AND STUDENTS.ADMNO=SPORTS.ADMNO ; V a. SELECT COUNT(*) FROM STUDENTS,SPORTS WHERE GAME=”VOLLEYBALL” AND STUDENTS.ADMNO=SPORTS.ADMNO |
|
| 8. |
Krrishnav is looking for his dream job but has some restrictions. He loves Delhi and would take a job there if he is paid over Rs.40,000 a month. He hates Chennai and demands at least Rs. 1,00,000 to work there. In any another location he is willing to work for Rs. 60,000 a month. The following code shows his basic strategy for evaluating a job offer. Code: pay= _________ location= _________ if location == "Mumbai": print ("I’ll take it!") #Statement 1 elif location == "Chennai": if pay < 100000: print ("No way") #Statement 2 else: print("I am willing!") #Statement 3 elif location == "Delhi" and pay > 40000: print("I am happy to join") #Statement 4 elif pay > 60000: print("I accept the offer") #Statement 5 else: print("No thanks, I can find something better")#Statement 6 On the basis of the above code, choose the right statement which will be executed when different inputs for pay and location are given. i. Input: location = "Chennai”, pay = 50000 a. Statement 1 b. Statement 2 c. Statement 3 d. Statement 4ii. Input: location = "Surat" ,pay = 50000 a. Statement 2 b. Statement 4 c. Statement 5 d. Statement 6iii. Input- location = "Any Other City", pay = 1 a Statement 1 b. Statement 2 c. Statement 4 d. Statement 6iv. Input location = "Delhi", pay = 500000 a. Statement 6 b. Statement 5 c. Statement 4 d. Statement 3v. Input- location = "Lucknow", pay = 65000 i. Statement 2 ii. Statement 3 iii. Statement 4 iv. Statement 5 |
|
Answer» 1. Correct Answer : ii. Statement 2 2. Correct Answer: d. Statement 6 3. Correct Answer: d. Statement 6 4. Correct Answer: c. Statement 4 5. Correct Answer: d. Statement 5 |
|
| 9. |
A company ABC Enterprises has four blocks of buildings as shown:Center to center distance between various blocksB3 TO B150 MB1 TO B260 MB2 TO B425 MB4 TO B3170 MB3 TO B2125 MB1 TO B490 MNumber of computers in each block :B1150 MB215MB315MB425MComputers in each block are networked but blocks are not networked. The company has now decided to connect the blocks also.I. Suggest the most appropriate topology for the connections between the blocks. a. Ring topology b. Star topology c. Mesh topology d. Bus topologyII. The company wants internet accessibility in all the blocks. The suitable and cost-effective technology for that would be: a. Satellite b. Lease line c. Telephone line d. BroadbandIII Which one of the following devices will you suggest for connecting all the computers with in each of their blocks? a. Switch/Hub b. Modem c. Telephone d. RepeaterVI Which one of the following devices will you suggest for connecting all the computers with in each of their blocks? a. Switch/Hubb. Modem c. Telephone d. RepeaterV Suggest the most appropriate location of the server, to get the best connectivity for maximum number of computers. a. BLOCK B2 b. BLOCK B1 c. BLOCK B4 d. BLOCK B3 |
|
Answer» I. Correct Answer: b. Star topology II. Correct Answer: d. Broadband III. Correct Answer: a. Switch/Hub IV. Correct Answer: d. Radio waves V. Correct Answer: b. BLOCK B1 |
|
| 10. |
Ankita is writing a program to perform some operations in Queue. She has created three Insert_in_Queue(Student), Delete_from_Queue(Student) and Print_Queue(Student) methods/functions in Python to add a new Student name, delete a Student name and print list of student from a queue, considering them to act as insert, delete and print operations of the Queue data structure. She is not getting the desired result. Help her to get the desired result from the given python code. def Insert_in_Queue(queue): a=input("enter student name: ") queue.____________ # Statement-1def Delete_from_Queue (queue): if (____________): # Statement-2 print("Queue empty") else: print("Deleted element is: ",queue[0]) del queue[___] #Statement-3 def Print_Queue(queue): if not ________: #Statement-4 print(queue[__:___ ]) # Statement-5i. What Ankita should write to complete the Statement-1 to store the student name? a. queue.append(a) b. queue=append(a) c. queue.append=a d. append(a).queueii. Fill in the blank in Statement-2 to check whether the queue is empty or not? a. isEmpty(Queue) b. isEmpty(q) c. Queue.isEmpty d. Empty.Queue iii. Fill in the blank in Statement-3 with index number.a. delete(0) b. del queue[0] c. delete.queue(0) d. queue.delete[0] iv. Select the correct option to complete the statement at statement-4. a. isEmpty( ) b. Empty( ) c. len( ) = 0v. Specify the range to print all queue elements in statement-5? a. print(queue=[0:len=(queue)]) b. print(queue[0:len(queue)]) c. print(queue[[0:len]]) d. print(queue[0=len(queue)]) |
|
Answer» i. Correct Answer: a queue.append(a) ii. Correct Answer: a isEmpty(Queue) iii. Correct Answer: b) del queue[0] iv. Correct Answer : a isEmpty( ) v. Correct Answer : b. print(queue[0:len(queue)]) |
|
| 11. |
Radha Shah is a programmer, who has recently been given a task to write a python code to perform the following CSV file operations with the help of two user defined functions/modules: a. CSVOpen() : to create a CSV file called BOOKS.CSV in append mode containing information of books – Title, Author and Price. b. CSVRead() : to display the records from the CSV file called BOOKS.CSV where the field title starts with 'R'. She has succeeded in writing partial code and has missed out certain statements, so she has left certain queries in comment lines. import csv def CSVOpen(): with open('books.csv','______',newline='') as csvf: #Statement-1 cw=______ #Statement-2 ______ #Statement-3 cw.writerow(['Rapunzel','Jack',300]) cw.writerow(['Barbie','Doll',900]) cw.writerow(['Johnny','Jane',280]) def CSVRead():try: with open('books.csv','r') as csvf: cr=______ #Statement-4 for r in cr: if ______: #Statement-5 print(r) except: print('File Not Found') CSVOpen() CSVRead()You as an expert of Python have to provide the missing statements and other related queries based on the following code of Radha. Answer from the below mentioned questions.I. Choose the appropriate mode in which the file is to be opened in append mode (Statement 1) a. w+ b. ab c. r+ d. aII. Which statement will be used to create a csv writer object in Statement 2. a. csv.writer(csvf) b. csv.writer(csvf) c. csvf.writer() d. cs.writer(csvf)III. Choose the correct option for Statement 3 to write the names of the column headings in the CSV file, BOOKS.CSV. a. cw.writerow('Title','Author','Price') b. cw.writerow(['Title','Author','Price']) c. cw.writerows('Title','Author','Price') d. cw.writerows(['Title','Author','Price'])IV. Which statement will be used to read a csv file in Statement 4. a. cs.read(csvf) b. csv.reader(csvf) c. csvf.read() d. csvf.reader(cs)V. Fill in the appropriate statement to check the field Title starting with ‘R’ for Statement 5 in the above program. a. r[0][0]=='R' b. r[1][0]=='R' c. r[0][1]=='R'd. d) r[1][1]=='R' |
|
Answer» I. Correct Answer: d. a II. Correct Answer: b. csv.writer(csvf) III. Correct Answer: b. cw.writerow(['Title','Author','Price']) IV. Correct Answer: b. csv.reader(csvf) V. Correct Answer: a. r[0][0]=='R' |
|
| 12. |
Amritya Seth is a programmer, who has recently been given a task to write a python code to perform the following binary file operations with the help of two user defined functions/modules: a. AddStudents() to create a binary file called STUDENT.DAT containing student information – roll number, name and marks (out of 100) of each student. b. GetStudents() to display the name and percentage of those students who have a percentage greater than 75. In case there is no student having percentage > 75 the function displays an appropriate message. The function should also display the average percent. He has succeeded in writing partial code and has missed out certain statements, so he has left certain queries in comment lines. You as an expert of Python have to provide the missing statements and other related queries based on the following code of Amritya. Answer from the below mentioned questions.import pickle def AddStudents(): _______ #1 statement to open the binary file to write data while True: Rno = int(input("Rno :")) Name = input("Name : ") Percent = float(input("Percent :")) L = [Rno, Name, Percent] ________ #2 statement to write the list Linto the file Choice = input("enter more (y/n): ") if Choice in "nN": break F.close()def GetStudents(): Total=0 Countrec=0 Countabove75=0 with open("STUDENT.DAT","rb") as F: while True: try: ____________ #3 statement to read from the file Countrec+=1 Total+=R[2] if R[2] > 75: print(R[1], " has percent = ",R[2]) Countabove75+=1 except: break if Countabove75==0:print("There is no student who has percentage more than 75") average=Total/Countrec print("average percent of class = ",average) AddStudents() GetStudents()i. Which of the following commands is used to open the file “STUDENT.DAT” for writing only in binary format? (marked as #1 in the Python code) a. F= open("STUDENT.DAT",'wb') b. F= open("STUDENT.DAT",'w') c. F= open("STUDENT.DAT",'wb+') d. F= open("STUDENT.DAT",'w+')ii. Which of the following commands is used to write the list L into the binary file, STUDENT.DAT? (marked as #2 in the Python code) a. pickle.write(L,f) b. pickle.write(f, L) c. pickle.dump(L,F) d. f=pickle.dump(L) pickle.dump(L,F) iii. Which of the following commands is used to read each record from the binary file STUDENT.DAT? (marked as #3 in the Python code) a. R = pickle.load(F) b. pickle.read(r,f)c. r= pickle.read(f) d. pickle.load(r,f) iv. Which of the following statement(s) are correct regarding the file access modes?a. ‘r+’ opens a file for both reading and writing. File object points to its beginning. b. ‘w+’ opens a file for both writing and reading. Adds at the end of the existing file if it exists and creates a new one if it does not exist. c. ‘wb’ opens a file for reading and writing in binary format. Overwrites the file if it exists and creates a new one if it does not exist.d. ‘a’ opens a file for appending. The file pointer is at the start of the file if the file exists. v. Which of the following statements correctly explain the function of seek() method? a. tells the current position within the file. b. determines if you can move the file position or not. c. indicates that the next read or write occurs from that position in a file. d. moves the current file position to a given specified position |
|
Answer» i. Correct Answer : a. F= open("STUDENT.DAT",'wb') ii. Correct Answer : c. pickle.dump(L,F) iii. Correct Answer : a. R = pickle.load(F) iv. Correct Answer : d v. Correct Answer : d |
|
| 13. |
Rohit, a student of class 12, is learning CSV File Module in Python. During examination, he has been assigned an incomplete python code (shown below) to create a CSV File 'Student.csv' (content shown below). Help him in completing the code which creates the desired CSV File.CSV File 1,AKSHAY,XII,A 2,ABHISHEK,XII,A 3,ARVIND,XII,A 4,RAVI,XII,A 5,ASHISH,XII,AIncomplete Code import ......... #Statement-1 fh = open(........, ..........., newline='') #Statement-2 stuwriter = csv.......... #Statement-3 data = [ ] header = ['ROLL_NO', 'NAME', 'CLASS', 'SECTION'] data.append(header) for i in range(5): roll_no = int(input("Enter Roll Number : ")) name = input("Enter Name : ") Class = input("Enter Class : ") section = input("Enter Section : ") rec = [ .......... ] #Statement-4 data.append(...........) #Statement-5stuwriter. ....... (data) #Statement-6 fh.close()1. Identify the suitable code for blank space in the line marked as Statement-1. a) csv file b) CSV c) csv d) cvs2. Identify the missing code for blank space in line marked as Statement-2. a) "Student.csv","wb" b) "Student.csv","w" c) "Student.csv","r" d) "Student.cvs","r3. Choose the function name (with argument) that should be used in the blank space of line marked as Statement-3. a) reader(fh) b) reader(MyFile) c) writer(fh) d) writer(MyFile)4. Identify the suitable code for blank space in line marked as Statement-4. a) 'ROLL_NO', 'NAME', 'CLASS', 'SECTION' b) ROLL_NO, NAME, CLASS, SECTION c) 'roll_no','name','Class','section' d) roll_no,name,Class,section5. Identify the suitable code for blank space in the line marked as Statement-5. a) data b) record c) rec d) insert6. Choose the function name that should be used in the blank space of line marked as Statement-6 to create the desired CSV File? a) dump() b) load() c) writerows() d) writerow() |
|
Answer» 1. c. csv 2. b. "Student.csv","w" 3. c. writer(fh) 4. d. roll_no,name,Class,section 5. c. rec 6. c. writerows() |
|
| 14. |
Rohit, a student of class 12th, is learning CSV File Module in Python. During examination, he has been assigned an incomplete python code (shown below) to create a CSV File 'Student.csv' (content shown below). Help him in completing the code which creates the desired CSV File. CSV File 1,AKSHAY,XII,A 2,ABHISHEK,XII,A 3,ARVIND,XII,A 4,RAVI,XII,A 5,ASHISH,XII,AIncomplete Code import_____ #Statement-1 fh = open(_____, _____, newline='') #Statement-2 stuwriter = csv._____ #Statement-3 data = [] header = ['ROLL_NO', 'NAME', 'CLASS', 'SECTION'] data.append(header) for i in range(5):roll_no = int(input("Enter Roll Number : ")) name = input("Enter Name : ") Class = input("Enter Class : ") section = input("Enter Section : ") rec = [_____] #Statement-4 data.append(rec) stuwriter. _____ (data) #Statement-5fh.close()i. Identify the suitable code for blank space in line marked as Statement-1. a) csv file b) CSV c) csv d) Csv ii. Identify the missing code for blank space in line marked as Statement-2? a) "School.csv","w" b) "Student.csv","w" c) "Student.csv","r" d) "School.csv","r" "Student.csv","w" iii. Choose the function name (with argument) that should be used in the blank space of line marked as Statement-3 a) reader(fh) b) reader(MyFile) c) writer(fh) d) writer(MyFile)iv. Identify the suitable code for blank space in line marked as Statement-4. a) 'ROLL_NO', 'NAME', 'CLASS', 'SECTION' b) ROLL_NO, NAME, CLASS, SECTION c) 'roll_no','name','Class','section' d) roll_no,name,Class,sectionc) co.connect()v. Choose the function name that should be used in the blank space of line marked as Statement-5 to create the desired CSV File? a) dump() b) load() c) writerows() d) writerow() |
|
Answer» 1. Correct Answer : c) csv 2. Correct Answer : b) "Student.csv","w" 3. Correct Answer : c) writer(fh) 4. Correct Answer : d) roll_no,name,Class,section 5. Correct Answer : c) writerows() |
|
| 15. |
Which of the following is not a function / method of csv module in Python? a. read() b. reader() c. writer() d. writerow() |
|
Answer» Answer is a. read() |
|
| 16. |
Write a program to find that the entered year is a leap year or not. |
|
Answer» #include #include void main() { int year; printf("Enter a year: "); scanf("%d", &year); if(((year%4==0) && ((year%400==0) || (year%100!==0)) { printf("%d is a leap year", &year); } else { printf("%d is not a leap year", &year); } getch(); } |
|
| 17. |
Compare the usefulness of default argument and function overloading, supporting your answer with appropriate examples. |
|
Answer» Default values can be provided the function prototype itself and the function may be called even if an argument is missing. But there is one limitation with it, if you want to default a middle argument, then all the argument on its right must also be defaulted. For instance, consider the following function prototype: float amount(float p, int time=2, float rate=0.08); cout<<amount(2000,0.13); Here, C++ will take 0.13 to be the argument value for time and hence invoke amount() with values 2000, 0(0.13 converted to int) and 0.08 Function overloading can handle all possible argument combinations. It overcomes the limitation of default argument but also compiler is saved from the trouble of testing the default value. Example: float area(float a) { return a*a; } float area(float a,float b) { retur a*b; } |
|
| 18. |
Write the output of the following C++ code. Also, write the name of feature of Object Oriented Programming used in the following program jointly illustrated by the functions [I] to [IV]:#include<iostream.h>void Line() //Fuction [I]{for(int L=1;L<=80;L++) cout<<"-";cout<<end1;}void Line(int N) //Fuction [II]{ for(int L=1;L<=N;L++) cout<<"*";cout<<end1;}void Line(char C,A,int N) //Fuction [III]{ for(int L=1;L< = N;L++) cout<<C;cout<<end1;}void Line(int M,int N) //Fuction [IV]{for(int L=1;L< = N;L++) cout<<M*L;cout<<end1;}void main(){int A = 9,B = 4,C = 3;char K = '#';Line(K,B);Line(A,C);} |
|
Answer» Output: # # # # 9 18 27 The name of feature of Object Oriented Programming used in the above program jointly illustrated by the functions [I] to [IV] is known as ‘function overloading’. |
|
| 19. |
Write definitions for two versions of an overloaded function. This function’s 1st version sum() takes an argument, int array, and returns the sum of all the elements of the passed array. The 2nd version of sum() takes two arguments, an int array and a character (‘E’ or ‘O’). If the passed character is ‘E’, it returns the sum of even elements of the passed array and is the passed character is ‘O’, it returns the sum of odd elements. In case of any other character, it returns 0 (zero). |
|
Answer» int sum(int a[ ]) { int n,sum=0; cout<<"Enter n:"; cin>>n; for(int i=0;i<n;i++) { sum=sum+a[i]; } return sum; } // int sum(int a[ ],char c) { int even=0,odd=0; switch(c) { case 'E': for(int i=0;i<5;i++) { if(a[i]%2==0) { even = even+a[i]; } } return even; case 'O': for(int j=0;j<5;j++) { if(a[j]%2!=0) { odd=odd+a[j]; } } return odd; } } |
|
| 20. |
Write about reusability. |
|
Answer» 1. Few lines of code may be repeatedly used in different contexts. Duplication of the same code can be eliminated by using functions which improves the maintenance and reduce program size. 2. Some functions can be called multiple times with different inputs. |
|
| 21. |
The execution of the program begins at .......... function. |
|
Answer» The execution of the program begins at main function. |
|
| 22. |
The default data type returned by a function is ........... (a) float (b) double (c) int (d) char |
|
Answer» The default data type returned by a function is int |
|
| 23. |
One of the following is not involved in the creation and usage of a user defined function. (a) Define a function (b) Declare a function (c) invoke a function (d) None of these |
|
Answer» (d) None of these |
|
| 24. |
What is a derived data type? Give an example. |
|
Answer» The derived data type or user defined data type is created by using basic data types. For example, structure |
|
| 25. |
Mention the use of isalpha() and toupper() character functions. |
|
Answer» 1. isalpha(): Returns a non-zero value if the argument is a A-Z or a-z letters. For example, isalpha(‘a’) output: 1 means true isalpha(‘5’) output: 0 means false 2. toupper( ): It converts the lower case alphabet character to upper case. For example, toupper(‘a’) output: A |
|
| 26. |
Classify various data types in C++. |
|
Answer» Data types are classified into built in or basic data types and user defined or derived data types. |
|
| 27. |
Give the command for Copy and Paste in Word Processor. |
|
Answer» The copy command is Ctrl + C and Ctrl + V is for Paste in Word Processor. |
|
| 28. |
Write the shortcut keys for cut and paste operation in MS Word. |
|
Answer» The sequence of short cut keys to cut and paste is Ctrl+X for cut and Ctrl+V for paste. |
|
| 29. |
Write the purpose of Isalpha() and Toupper() built in function, |
|
Answer» 1. isalpha() returns a non-zero value if argument is A-Z or a-z letters. For example, isalpha(‘a’) output: true isalpha(‘5’) output: false 2. toupper () function converts the lower case alphabet character to upper case. For example, toupper(‘a’) output: A |
|
| 30. |
Explain two types of variable according to its scope and life. |
|
Answer» 1. Local scope: A variable declared inside a block can be used only in the block. It cannot be used any other block. eg: #include<iostream> using namespace std; int sum(int n1 ,int n2) { int s; s = n1 + n2; return (s); } int main() { int n1 ,n2; cout<<“Enter 2 numbers cin>>n1>>n2; cout<<“The sum is “<<sum(n1 ,n2); } Here the variable s is declared inside the function sum and has local scope; 2. Global scope: A variable declared outside of all blocks can be used any where in the program. #include<iostream> using namespace std; int s; int sum(int n1,int n2) { s = n1 + n2; return(s); } int main() { int n1 ,n2; cout<<“Enter 2 numbers cin>>n1>>n2; cout<<“The sum is “<<sum(n1 ,n2); } Here the variable s is declared out side of all functions and we can use variable s any where in the program. |
|
| 31. |
One of the following is not necessary in the function declaration. What is it? (a) name of the function (b) return type (c) number and type of arguments (d) name of the parameters |
|
Answer» (d) name of the parameters |
|
| 32. |
.......... key word is used to specify a function returns nothing. |
|
Answer» void key word is used to specify a function returns nothing. |
|
| 33. |
Supplying data to a function from the called function by using ........... |
|
Answer» parameters (arguments) |
|
| 34. |
After the execution of a function, it is returned back to the main function by executing .......... keyword. |
|
Answer» After the execution of a function, it is returned back to the main function by executing return keyword. |
|
| 35. |
#include<iostream>#include<cstdlib>using namespace std; int main() {char str1 [] = “123”,str2[] = “45”; int a,b; a = atoi(str1); b = atoi(str2); cout<<a+b;}What will be the output and give the reason? |
|
Answer» The output is 123 + 45 = 168. Here the conversion function atoi is used to convert the string “123” into integer 123 and “45” into integer 45 so the result. |
|
| 36. |
Name the different methods used for passing arguments to a function. Write the difference between them with examples. |
|
Answer» Methods of calling functions: Two types call by value and call by reference. 1. Call by value: In call by value method the copy of the original value is passed to the function, if the function makes any change will not affect the original value. Example #include<iostream.h> #include<conio.h> void swap(int a, int b) { int temp; temp = a; a =b; b = temp; } main() { cirscr(); int a,b; cout<<"Enter value for a and b:-"; cin>>a>>b; { cout<<"The value before swap a="<<a<<"and b="<<b; swap(a,b); cout<<"\n The value before swap a="<<a<<"and b="<<b; getch(); } 2. Call by reference: In call by reference method the address of the original value is passed to the function, if the function makes any change will affect the original value. Example #include<iostream.h> #include<conio.h> void swap(int& a, int& b) { int temp; temp = a; a =b; b = temp; } main() { cirscr(); int a,b; cout<<"Enter value for a and b:-"; cin>>a>>b; cout<<"The value before swap a="<<a<<"and b="<<b; swap(a,b); cout<<"\n The value before swap a="<<a<<"and b="<<b; getch(); } |
|
| 37. |
What are the modes of operations in 8253? |
|
Answer» There are five modes of operations in 8253 MODE 1: HARDWARE RETRIGGERABLE ONE-SHOT OUT will be initially high. OUT will go low on the CLK pulse following a trigger to begin the one shot pulse,and will remain low until the Counter reaches zero. OUT will then go high and remain high until the CLK pulse after the next trigger.After writing the Control Word and initial count, the Counter is armed. A trigger results in loading the Counter and setting OUT low on the next CLK pulse,thus starting the one-shot pulse. An initial count of N will result in a one-shot pulse N CLK cycles in duration. The one-shot is retriggerable, hence OUT will remain low for N CLK pulses after any trigger. The one-shot pulse can be repeated without rewriting the same count into the counter. GATE has no effect on OUT.If a new count is written to the Counter during a one shot pulse, the current one-shot is not affected unless the counter is retriggered. In that case, the Counter is loaded with the new count and the one shot pulse continues until the new count expires. MODE 2: RATE GENERATOR This Mode functions like a divide-by-N counter. It is typically used to generate a Real Time Clock interrupt.OUT will initially be high. When the initial count has decremented to 1, OUT goes low for one CLK pulse. OUT then goes high again, the Counter reloads the initial count and the process is repeated.Mode 2 is periodic; the same sequence is repeated indefinitely. For an initial count of N, the sequence repeats every N CLK cycles. GATE e1 enables counting; GATE e 0 disables counting. If GATE goes low during an output pulse,OUT is set high immediately. A trigger reloads the Counter with the initial count on the next CLK pulse; OUT goes low N CLK pulses after the trigger. Thus the GATE input can be used to synchronize the Counter.After writing a Control Word and initial count, the Counter will be loaded on the next CLK pulse. OUT goes low N CLK Pulses after the initial count is written.This allows the Counter to be synchronized by software also.Writing a new count while counting does not affect the current counting sequence. If a trigger is received after writing a new count but before the end of the current period, the Counter will be loaded with the new count on the next CLK pulse and counting will continue from the new count. Otherwise, the new count will be loaded at the end of the current counting cycle. In mode 2, a COUNT of 1 is illegal. MODE 3: SQUARE WAVE MODE Mode 3 is typically used for Baud rate generation.Mode 3 is similar to Mode 2 except for the duty cycle of OUT. OUT will initially be high. When half the initial count has expired, OUT goes low for the remainder of the count. Mode 3 is periodic; the sequence above is repeated indefinitely. An initial count of N results in a square wave with a period of N CLK cycles. GATEe1 enables counting; GATE e 0 disables counting. If GATE goes low while OUT is low, OUT is set high immediately; no CLK pulse is required. A trigger reloads the Counter with the initial count on the next CLK pulse. Thus the GATE input can be used to synchronize the Counter. After writing a Control Word and initial count, the Counter will be loaded on the next CLK pulse. This allows the Counter to be synchronized by software also.Writing a new count while counting does not affect the current counting sequence. If a trigger is received after writing a new count but before the end of the current half-cycle of the square wave, the Counter will be loaded with the new count on the next CLK pulse and counting will continue from the new count. Otherwise, the new count will be loadedat the end of the current half-cycle.Mode 3 is implemented as follows:Even counts: OUT is initially high. The initial count is loaded on one CLK pulse and then is decremented by two on succeeding CLK pulses. When the count expires OUT changes value and the Counter is reloaded with the initial count. The above process is repeated indefinitely. Odd counts: OUT is initially high. The initial count minus one (an even number) is loaded on one CLK pulse and then is decremented by two on succeeding CLK pulses. One CLK pulse after the count expires,OUT goes low and the Counter is reloaded with the initial count minus one. Succeeding CLK pulses decrement the count by two. When the count expires, OUT goes high again and the Counter is reloaded with the initial count minus one. The above process is repeated indefinitely. So for odd counts,OUT will be high for (N a 1)/2 counts and low for(N b 1)/2 counts. MODE 4: SOFTWARE TRIGGERED STROBE OUT will be initially high. When the initial count expires,OUT will go low for one CLK pulse and then go high again. The counting sequence is ``triggered''by writing the initial count. GATE e1 enables counting; GATE e 0 disables counting. GATE has no effect on OUT.After writing a Control Word and initial count, the Counter will be loaded on the next CLK pulse. This CLK pulse does not decrement the count, so for an initial count of N, OUT does not strobe low until N a1 CLK pulses after the initial count is written.If a new count is written during counting, it will be loaded on the next CLK pulse and counting will continue from the new count. If a two-byte count is written,the following happens: 1) Writing the first byte has no effect on counting. 2) Writing the second byte allows the new count to be loaded on the next CLK pulse.This allows the sequence to be ``retriggered'' by software. OUT strobes low N a 1 CLK pulses after the new count of N is written.231164±11 MODE 5: HARDWARE TRIGGERED STROBE (RETRIGGERABLE) OUT will initially be high. Counting is triggered by arising edge of GATE. When the initial count has expired,OUT will go low for one CLK pulse and the n go high again.After writing the Control Word and initial count, the counter will not be loaded until the CLK pulse after at rigger. This CLK pulse does not decrement the count, so for an initial count of N, OUT does not strobe low until N a 1 CLK pulses after a trigger. A trigger results in the Counter being loaded with the initial count on the next CLK pulse. The counting sequence is retriggerable. OUT will not strobe low for N a 1 CLK pulses after any trigger. GATE has no effect on OUT.If a new count is written during counting, the current counting sequence will not be affected. If a trigger occurs after the new count is written but before the current count expires, the Counter will be loaded with the new count on the next CLK pulse and counting will continue from there. |
|
| 38. |
Briefly explain default arguments Default arguments. |
|
Answer» A default value can be set for a parameter (argument) of a function. When the user does not give a value the function will take the default value. An important thing remember, is an argument cannot have a default value unless all arguments on its right side must have default value. Functions with valid default arguments are given below
Functions with invalid default arguments are given below
|
|
| 39. |
“Arguments used in call statement are formal arguments”. State true or false. |
|
Answer» The statement is False. |
|
| 40. |
Mode of operation of 8237 |
|
Answer» MODE OF OPERATION OF 8237 SINGLE TRANSFER MODE In Single Transfer mode the device is programmed to make one transfer only.The word count will be decremented and the address decremented or incremented following each transfer. When the word count ``rolls over'' from zero to FFFFH, a Terminal Count (TC) will cause an Auto initialize if the channel has been programmed to do so. DREQ must be held active until DACK becomes active in order to be recognized. If DREQ is held active through out the single transfer, HRQ will go in active and release the bus to the system. It will again go active and, upon receipt of a new HLDA, an other single transfer will be performed. In 8080A, 8085AH, 8088, or 8086 system, this will ensure one full machine cycle execution between DMA transfers. Details of timing between the 8237A and other bus control protocols will depend upon the characteristics of the microprocessor involved. BLOCK TRANSFER MODE In Block Transfer mode the device is activated by DREQ to continue making transfers during the service until a TC, caused byword count going to FFFFH, or an external End of Process (EOP) is encountered. DREQ need only be held active until DACK becomes active. Again, an Auto initialization will occur at the end of the service if the channel has been programmed for it. DEMAND TRANSFER MODE In Demand Transfer mode the device is programmed to continue making transfers until a TC or external EOP is encountered or until DREQ goes inactive. Thus transfers may continue until the I/O device has exhausted its data capacity. After the I/O device has had a chance to catch up, the DMA service is re-established by means of a DREQ. During the time between services when the microprocessor is allowed to operate, the intermediate values of address and word count are stored in the 8237 A Current Address and Current Word Count registers. Only an EOP can cause an Auto initialize at the end of the service. EOP is generated either by TC or by an external signal. DREQ has to be low before S4 to prevent another Transfer. CASCADE MODE This mode is used to cascade more than one 8237A together for simple system expansion. The HRQ and HLDA signals from the additional 8237A are connected to the DREQ and DACK signals of a channel of the initial 8237A. This allows the DMA requests of the additional device to propagate through the priority network circuitry of the preceding device. The priority chain is preserved and the new device must wait for its turn to acknowledge requests. Since the cascade channel of the initial 8237A is used only for prioritizing the additional device, it does not output any address or control. |
|
| 41. |
What is 8254 system interface ? |
|
Answer» 8254 SYSTEM INTERFACE The 8254 is a component of the Intel Microcomputer Systems and interfaces in the same manner as all other peripherals of the family. It is treated by the system's software as an array of peripheral I/O ports; three are counters and the fourth is a control register for MODE programming.Basically, the select inputs A0,A1 connect to the A0, A1 address bus signals of the CPU. The CS can be derived directly from the address bus using a linear select method. Or it can be connected to the output of a decoder, such as an Intel 8205 for larger systems |
|
| 42. |
The parameter used to call a function is called ........... |
|
Answer» Actual parameter |
|
| 43. |
In Three-Way Handshaking process, the situation where both the TCP’s issue an active open is ___________(a) Mutual open(b) Mutual Close(c) Simultaneous open(d) Simultaneous close |
|
Answer» Correct choice is (c) Simultaneous open The best I can explain: In simultaneous open situation, two nodes send an SYN signal to each other and start a TCP connection. Here, both TCP nodes transmit a SYNC+ACK segment to each other and a connection is established between them. This doesn’t happen usually, because both sides have to know which port on the other side to send to. |
|
| 44. |
Input handshaking signals |
|
Answer» Input Handshaking signals 1. IBF(Input Buffer Full)-It is an output indicating that the input latch contains information. 2. STB(Strobed Input)-The strobe input loads data into the port latch, which holds the information until it is input to the microprocessor via the IN instruction. 3. INTR(Interrupt request)-It is an output that requests an interrupt. The INTR pin becomes a logic 1 when the STB input returns to a logic 1, and is cleared when the data are input from the port by the microprocessor. 4. INTE(Interrupt enable)-It is neither an input nor an output; it is an internal bit programmed via the port PC4(port A) or PC2(port B) bit position. |
|
| 45. |
.......... parameter is used when the function call does not supply a value for parameters |
|
Answer» default parameter is used when the function call does not supply a value for parameters |
|
| 46. |
Functional description |
|
Answer» The 8254 is a programmable interval timer/counterdesigned for use with Intel microcomputer systems. It is a general purpose, multi-timing element that canbe treated as an array of I/O ports in the system software.The 8254 solves one of the most common problems in any microcomputer system, the generation of accuratetime delays under software control. Instead ofsetting up timing loops in software, the programmerconfigures the 8254 to match his requirements and programs one of the counters for the desired delay.After the desired delay, the 8254 will interrupt theCPU. Software overhead is minimal and variablelength delays can easily be accommodated.Some of the other counter/timer functions commonto microcomputers which can be implemented withthe 8254 are: # Real time clock # Event-counter # Digital one-shot # Programmable rate generator # Square wave generator # Binary rate multiplier # Complex waveform generator # Complex motor controller |
|
| 47. |
What type display mode ? |
|
Answer» DISPLAY MODE (A) LEFT ENTRY MODE When the data is entered from the left side of the display unit it is called left entry mode. A dress 15 of the RAM contains the right most display character and address 0 of the display RAM contains the left most display character. (B) RIGHT ENTRY MODE In this mode the first entry to be displayed is entered on the rightmost display. The next entry is also placed in the right most display but after the previous display i shift left by one display position. |
|
| 48. |
What are the other modes used in keyboard modes? |
|
Answer» KEYBOARD MODES (A.) SCANNED KEYBOARD MODE WITH 2 KEY LOCKOUT when a key is pressed ,it enters into FIFO (if at least 1 byte is free ),an interrupt is generated to inform CPU about previous key closure, if found no entry is made to the FIFO.If 2 keys are pressed no keys are detected or scanned. (B.) SCANNED KEYBOARD SPECIAL ERROR MODE Validity of this mode depends on N key rollover mode. when 2 keys are pressed simultaneously, error flag is set, it prevents further writing but sends interrupt to CPU for read operation. With command CF=1,error flag can be set. (C.) SENSOR MATRIX MODE debounce logic is inhibited.8 byte FIFO RAM acts as 8 x 8 bit memory matrix . sensor RAM contains status of sensor matrix. |
|
| 49. |
What is data bus buffer? |
|
Answer» DATABUS BUFFER The 8 bit bidirectional data bus connected to data bus of the micro processor. The direction of the data bus are decided by the read and write control signals . in read operation it transmit data to the system bus and in write operation it receives data from system bus. |
|
| 50. |
What is the output modes used in 8279? |
|
Answer» OUTPUT (DISPLAY) MODE 2 output modes for selecting display 1. Display Scan: provides 8 or 16 characters multiplexed displays organised as dual 4 bit or single 8 bit display units 2. Display Entry: it allows options for data entry into the display either left entry or right entry. |
|