C ++ MULTIPLE CHOICE QUESTION

Slides:



Advertisements
Similar presentations
 2003 Prentice Hall, Inc. All rights reserved. 1 Chapter 13 - Exception Handling Outline 13.1 Introduction 13.2 Exception-Handling Overview 13.3 Other.
Advertisements

Exception Handling The purpose of exception handling is to permit the program to catch and handle errors rather than letting the error occur and suffer.
 2006 Pearson Education, Inc. All rights reserved. Exception Handling in C++ CS-2303, C-Term Exception Handling in C++ CS-2303 System Programming.
C++ Exception Handling
1 Lecture 11 Interfaces and Exception Handling from Chapters 9 and 10.
Exception Handling Introduction Exception handling is a mechanism to handle exceptions. Exceptions are error like situations. It is difficult to decide.
CS Advanced C++ Exception Handling Topic #5.
Virtual Functions Junaed Sattar November 10, 2008 Lecture 10.
Dale Roberts Exception Handling Dale Roberts, Lecturer Computer Science, IUPUI Department of Computer and Information Science,
CPSC 252 Exception Handling Page 1 Exceptions and exception handling Client programmers can make errors using a class attempting to dequeue an item from.
Object Oriented Programming
C++ Exceptions STL Vector. Example int Quotient (int numer, int denom} { if (denom != 0) return (numer/denom); else //What to do?? }
Exception Handling. 2 Two types of bugs (errors) Logical error Syntactic error Logical error occur  Due to poor understanding of the problem and solution.
HANDLING EXCEPTIONS Chapter 9. Outline  Learn about the limitations of traditional error-handling methods  Throw exceptions  Use try blocks  Catch.
CS-1030 Dr. Mark L. Hornick 1 Basic C++ State the difference between a function/class declaration and a function/class definition. Explain the purpose.
Exceptions in C++. Exceptions  Exceptions provide a way to handle the errors generated by our programs by transferring control to functions called handlers.
Exceptions and Assertions Chapter 15 – CSCI 1302.
CSE 332: C++ Statements C++ Statements In C++ statements are basic units of execution –Each ends with ; (can use expressions to compute values) –Statements.
Exception Handling in Java Topics: Introduction Errors and Error handling Exceptions Types of Exceptions Coding Exceptions Summary.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Chapter 23 - Exception Handling Outline 23.1Introduction.
Exception Handling in C++. Outline What exceptions are and when to use them Using try, catch and throw to detect, handle and indicate exceptions, respectively.
Exception Handling Outline 23.1 Introduction
LECTURE LECTURE 14 Exception Handling Textbook p
C++ Namespaces, Exceptions CSci 588: Data Structures, Algorithms and Software Design All material not from online sources copyright © Travis Desell, 2011.
Exception Handling How to handle the runtime errors.
2.4 Exceptions n Detects try { //code that may raise an exception and/or set some condition if (condition) throw exceptionName; //Freq. A string } n Handles.
Eighth Lecture Exception Handling in Java
Chapter 2 Objects and Classes
C++ LANGUAGE MULTIPLE CHOICE QUESTION SET-3
C++ Lesson 1.
Exception handling.
Java Exceptions a quick review….
Exception Handling in C++
C++ Exceptions.
IS 0020 Program Design and Software Tools
Chapter 16 Exception Handling
Abstract Class Abstract Class is a class which contains atleast one Pure Virtual function in it. Abstract classes are used to provide an Interface for.
CS212: Object Oriented Analysis and Design
CMSC202 Computer Science II for Majors Lecture 16 – Exceptions
CS 2704 Object Oriented Software Design and Construction
Andy Wang Object Oriented Programming in C++ COP 3330
Jim Fawcett CSE687 – Object Oriented Design Spring 2001
Review 1.
Exceptions David Rabinowitz.
JAVA MULTIPLE CHOICE QUESTION.
C++ INTERVIEW QUESTIONS
Introduction to C++ Systems Programming.
Object-Oriented Programming (OOP) Lecture No. 45
Why exception handling in C++?
C++ History C++ was designed at AT&T Bell Labs by Bjarne Stroustrup in the early 80's Based on the ‘C’ programming language C++ language standardised in.
EXCEPTION HANDLING.
Exceptions C++ Interlude 3
Exception Handling Chapter 9.
Exceptions with Functions
Chapter 17 Templates and Exceptions Part 2
Overview of Memory Layout in C++
Exception Handling Chapter 9 Edited by JJ.
Data Abstraction: The Walls
Andy Wang Object Oriented Programming in C++ COP 3330
Advanced C++ Exception Handling
Exceptions and Templates
Exception Handling.
Standard Version of Starting Out with C++, 4th Edition
Exceptions, Templates, and the Standard Template Library (STL)
By Hector M Lugo-Cordero September 3, 2008
Errors and Exceptions Error Errors are the wrongs that can make a program to go wrong. An error may produce an incorrect output or may terminate the execution.
CS410 – Software Engineering Lecture #5: C++ Basics III
Exception Handling.
ENERGY 211 / CME 211 Lecture 24 November 14, 2008.
CECS 130 Final Exam Review Session
Presentation transcript:

C ++ MULTIPLE CHOICE QUESTION

Check your Knowledge Press to Start www.prolearninghub.com

1. The default executable generation on UNIX for a C++ program is ___ a.exe a a.out out.a www.prolearninghub.com

2. ____ is also called as abstract class. Virtual class Pure virtual class Derive class None of these www.prolearninghub.com

3. Define pure virtual function? Function which does not have definition of its own. Function which does have definition of its own. Function which does not have any return type. None of these www.prolearninghub.com

4. Identify the correct statement? A) We cannot make an instance of an abstract base class B) We can make an instance of an abstract base class Both A & B None of the mentioned www.prolearninghub.com

5. Abstract class is used: A) Base class only B) Derived class Both A and B None of the mentioned www.prolearninghub.com

6. Which of the following correctly declare an array? Int array[10]; Array array []; Arr array[]; None of these www.prolearninghub.com

7. An array is: Series of element of same type Series of element Series of element of different type None of these www.prolearninghub.com

8. To access the 100th element in a array. What should we write? www.prolearninghub.com

9. To access the first element of the array we should write: www.prolearninghub.com

10. What will be the output of this program? #include <stdio.h> using namespace std; int array1[] = {1200, 200, 2300, 1230, 1543}; int array2[] = {12, 14, 16, 18, 20}; int temp, result = 0; int main() { for (temp = 0; temp < 5; temp++) { result += array1[temp]; } for (temp = 0; temp < 4; temp++) { result += array2[temp]; } cout << result; return 0; } 6553 6533 64522 12200 www.prolearninghub.com

11. What will be the output for this program? #include <stdio.h> using namespace std; int main () { Int array[] = {0, 2, 4, 6, 7, 5, 3}; int n, result = 0; for (n = 0; n < 8; n++) { result += array[n]; } cout << result; return 0; } 2 20 27 30 www.prolearninghub.com

12. What is meaning of following declaration? int(*p[5])(); p is pointer to function p is array of pointer to function. p is pointer to such function which return type is array. p is pointer to array of function www.prolearninghub.com

13. A 32 bit generic pointer has: 2 bits 4 bits 6 bits 8 bits www.prolearninghub.com

14. What is the output of this program? #include <iostream> using namespace std; int main() { int a[2][4] = {3, 6, 9, 12, 15, 18, 21, 24}; cout << *(a[1] + 2) << *(*(a + 1) + 2) << 2[1[a]]; return 0; 15 18 21 21 21 21 24 24 24 Compile time error www.prolearninghub.com

15. What is the output of this program? #include <iostream> using namespace std; int main() { int arr[] = {4, 5, 6, 7}; int *p = (arr + 1); cout << *p; return 0; 4 5 6 7 www.prolearninghub.com

16. What is the output of this program? #include <iostream> using namespace std; int main() { int arr[] = {4, 5, 6, 7}; int *p = (arr + 1); cout << arr; return 0; } 4 5 Address of art 6 www.prolearninghub.com

17. What is template? A template is used to manipulate the class A template is used for creating the attributes None of the mentioned www.prolearninghub.com

18. Select the correct statement about string template? Used to replace string Used to replace string with another Used to delete a string None of mentioned www.prolearninghub.com

19. Which one is correct declaration of template? None of the mentioned www.prolearninghub.com

20. What keyword we used to handle an exception? Try Throw Catch None of the mentioned www.prolearninghub.com

21. Which keyword we use to catch an exception? Throw Catch try None of these www.prolearninghub.com

22. Finally keyword is used for: A) It used to execute at the starting of the program B) It will be executed at the end of the program even if the exception raised. Both a and b None of the mentioned www.prolearninghub.com

23. In nested try blocks, if both inner and outer catch handlers are not able to handle the exception, then ________. Compiler executes only executable statements of main(). Compiler issues compile time errors about it. Program will be executed without any interrupt. Program will be terminated abnormally. www.prolearninghub.com

24. Return type of uncaught_exception() is ________________ . int bool char * double www.prolearninghub.com

25. Can we write throw clause inside catch handler? Yes No www.prolearninghub.com

26. Which of the following statements are true about Catch handler? It must be placed immediately after try block T. It can have multiple parameters. There must be only one catch handler for every try block. Generic catch handler can be placed anywhere after try block. www.prolearninghub.com

27. Catch handler can have multiple parameters. False True www.prolearninghub.com

28. What is the output of this program? #include <iostream> #include <exception> using namespace std; int main () { try { int* myarray = new int[1000]; cout << "allocated"; } catch (exception& e) { cout << "Standard exception: " << e.what() << endl; return 0; Allocated Standard exception Depend on the memory Error www.prolearninghub.com

29. Which statement is true about user defined exception? Inheriting and overriding exception class functionality. Overriding class functionality. Inheriting class functionality None of the mentioned www.prolearninghub.com

30. Which exception is thrown by dynamic_cast? Bad_cast bad_typeid bad_exception bad_alloc www.prolearninghub.com

31. An exception can be of only built-In type. True False www.prolearninghub.com

32. Irrespective of exception occurrence, catch handler will always get executed. True False www.prolearninghub.com

33. What will happen when an exception is uncaught? Error arise Program will run Execute continuously None of the mentioned www.prolearninghub.com

34. _____ can catch all type of exceptions? Catch-all handler Catch handler Catch none handler None of these www.prolearninghub.com

35.  If inner catch handler is not able to handle the exception then__________ . Compiler will look for outer try handler Program terminates abnormally Compiler will check for appropriate catch handler of outer try block None of these www.prolearninghub.com

36. What is the output of this program? #include <iostream> using namespace std; int main(){ int i;char *arr[] = {"C", "C++", "Java", "VBA"}; char *(*ptr)[4] = &arr;cout << ++(*ptr)[2]; return 0; } Ava Java C++ Compile time error www.prolearninghub.com

37. Function called from within a try block____ throw exception? Always Maybe Never None of these www.prolearninghub.com

38. Which operator is used in catch-all handler? Ellipses operator Ternary operator String operator Unary operator www.prolearninghub.com

39. What function will be called when we have a uncaught exception? Terminate Throw Catch None of these www.prolearninghub.com

40. How can we be ensured that function throw specified exception? Defining multiple try and catch block inside a function Defining generic function within try block Defining function with throw clause It is not possible in CPP to restrict a function www.prolearninghub.com

41. What will not be called when terminate is arise in constructor: Main Destructor Class None of these www.prolearninghub.com

42. In nested try block, if inner catch handler gets executed, then _____________ . Program execution stops immediately. Outer catch handler will also get executed. Compiler will jump to the outer catch handler and then executes remaining executable statements of main (). Compiler will execute remaining executable statements of outer try block and then the main (). www.prolearninghub.com

43. We can replace throw () with? For Return Break Exit www.prolearninghub.com

44. Throwing an unhandled exception causes standard library function then _______ to be invoked. Stop () Abborted () terminate() Abandon() www.prolearninghub.com

45. Choose the most suitable option for returning the logical error in program. Use constructor and destructor Set a global error indicator Use break keyword none of the mentioned www.prolearninghub.com

Improve the exception safety 46. RAII is used for? Improve the exception safety Terminate the program Exit from the block None of mentioned www.prolearninghub.com

47. How many levels are there in exception safety? 1 2 3 4 www.prolearninghub.com

48. Error handling alternative can: Terminate the program Use the stack Exit from the block None of these www.prolearninghub.com

49. What will happen when an exception is not processed? It will eat up lot of memory and program size Terminate the program Crash the compiler None of the mentioned www.prolearninghub.com

50. Inheritance is a way to: (Choose all that apply) 1) Make general class into more specific classes 2) Pass arguments to the object of the class 3) Add features in existing class without rewriting it 4) Improve data hiding and encapsulation 2;3 1;3 1;4 2;4 www.prolearninghub.com

The Results