Subscribe Us

Showing posts with label MCQ. Show all posts
Showing posts with label MCQ. Show all posts

C++ Interview Question

 




Q: Is it possible to have Virtual Constructor? If yes, how? If not, Why not possible?

A: There is nothing like Virtual Constructor. The Constructor can’t be virtual as the constructor

is a code which is responsible for creating an instance of a class and it can’t be delegated to

any other object by virtual keyword means.

 

Q: What is constructor ?

A: Constructor creates an object and initializes it. It also creates vtable for virtual functions. It is

different from other methods in a class.

 

Q: What about Virtual Destructor?

A: Yes there is a Virtual Destructor. A destructor can be virtual as it is possible as at runtime

depending on the type of object caller is calling to, proper destructor will be called.

 

Q: What is the difference between a copy constructor and an overloaded assignment operator?

A: A copy constructor constructs a new object by using the content of the argument object. An

overloaded assignment operator assigns the contents of an existing object to another existing

object of the same class.

 

Q: Can a constructor throws an exception? How to handle the error when the constructor fails?

A:The constructor never throws an error.

 

Q: What is default constructor?

A: Constructor with no arguments or all the arguments has default values.

 

Q: What is copy constructor?

A: Constructor which initializes the it's object member variables ( by

shallow copying) with another object of the same class. If you don't implement one in your class

then compiler implements one for you. for example:

(a) Boo Obj1(10); // calling Boo constructor

(b) Boo Obj2(Obj1); // calling boo copy constructor

(c) Boo Obj2 = Obj1;// calling boo copy constructor

 

Q: When are copy constructors called?

A: Copy constructors are called in following cases:

(a) when a function returns an object of that

class by value

(b) when the object of that class is passed by

value as an argument to a function

(c) when you construct an object based on another

object of the same class

(d) When compiler generates a temporary object


Q: Can a copy constructor accept an object of the same class as parameter, instead of reference

of the object?

A: No. It is specified in the definition of the copy constructor itself. It should generate an error if

a programmer specifies a copy constructor with a first argument that is an object and not a

reference.

Q: What is conversion constructor?

A: constructor with a single argument makes that constructor as conversion ctor and it can be

used for type conversion.

for example:

class Boo

{

public:

Boo( int i );

};

Boo BooObject = 10 ; // assigning int 10 Boo object


Q:What is conversion operator??

A:class can have a public method for specific data type conversions.

for example:

class Boo

{

double value;

public:

Boo(int i )

operator double()

{

return value;

}

};

Boo BooObject;

double i = BooObject; // assigning object to variable i of type double.

now conversion operator gets called to assign the value.


Q: How can I handle a constructor that fails?

A: throw an exception. Constructors don't have a return type, so it's not possible to use return

codes. The best way to signal constructor failure is therefore to throw an exception.


Q: How can I handle a destructor that fails?

A: Write a message to a log-fille. But do not throw an exception. The C++ rule is that you must never throw an exception from a destructor that is being called during the "stack unwinding" process of another exception. For example, if someone says throw Foo(), the stack will be unwound so all the stack frames between the throw Foo() and the } catch (Foo e) { will get popped. This is called stack unwinding. During stack unwinding, all the local objects in all those stack frames are destructed. If one of those destructors throws an exception (say it throws a Bar object), the C++ runtime system is in a no-win situation: should it ignore the Bar and end up in the } catch (Foo e) { where it was originally headed? Should it ignore the Foo and look for a } catch (Bare) { handler? There is no good answer:either choice loses information. So the C++ language guarantees that it will call terminate() at this point, and terminate() kills the process. Bang you're dead.

Q: What is Virtual Destructor?

A: Using virtual destructors, you can destroy objects without knowing their type - the correct

destructor for the object is invoked using the virtual function mechanism. Note that destructors can also be declared as pure virtual functions for abstract classes. if someone will derive from your class, and if someone will say "new Derived", where "Derived" is derived from your class, and if someone will say delete p, where the actual object's type is "Derived" but the pointer p's type is your class.

Q: Can a copy constructor accept an object of the same class as parameter, instead of reference of the object?

A: No. It is specified in the definition of the copy constructor itself. It should generate an error if a programmer specifies a copy constructor with a first argument that is an object and not a reference.

Q: What's the order that local objects are destructed?

A: In reverse order of construction: First constructed, last destructed.

In the following example, b's destructor will be executed first, then a's destructor:

void userCode()

{

Fred a;

Fred b;

...

}

Q: What's the order that objects in an array are destructed?

A: In reverse order of construction: First constructed, last destructed.

In the following example, the order for destructors will be a[9], a[8], ..., a[1], a[0]:

void userCode()

{

Fred a[10];

...

}

Q: Can I overload the destructor for my class?

A: No.

You can have only one destructor for a class Fred. It's always called Fred::~Fred(). It never takes

any parameters, and it never returns anything.

You can't pass parameters to the destructor anyway, since you never explicitly call a destructor (well, almost never).

 

Share:

MS Word MCQ

 





MS WORD

1. Which enables us to send the same letter to different persons?
A. macros        B. template      C. mail merge                        D. none

2. Which key deletes the character to the left of the cursor?
A. End            B. Backspace                         C. Home          D. Delete

3. Which key deletes the character to the right of the cursor?
A. End                        B. Backspace C. Home          D. Delete

4. Which would you choose to save a document with a new name?
A. Press Ctrl+S           B. Click File, Save      C. Click Tools, Options, Save
D. Click File, Save As

5. Which would you choose to move selected text from one place to another?
A. Move and Paste     B. Copy and Paste      C. Cut and Paste       D. Delete and Paste

6. How do you magnify your document?
A. View, Zoom           B. Format, Font          C. Tools, Options        D. Tools, Customize

7. Which enables you to move directly to specific location in a document?
A. Subdocuments       B. Bookmarks                        C. Cross-references     D. Outlines

8. What are inserted as cross-reference in Word?
A. Placeholders           B. Bookmarks                         C. Objects       D. Word fields

9. Which keystroke is used for updating a field?
A. F6                           B. F9               C. F11             D. F12

10. A master document contains ………, each of which contains a pointer to a file on a disk?
A. Placeholders           B. subdocuments       C. bookmarks              D. references

=========================

 

 

 

 

 

 

11. When typing in a word field manually, what must you press to insert the code’s braces?
A. Ctrl + F6                            B. Ctrl + F9                C. Alt + F11                D. Shift + F12

12. A word field may consist of an optional field instruction called a(n) …………..
A. subdocument          B. symbol        C. signal          D. switch

13. Footnotes, endnotes, and indexes are all inserted as ………….
A. bookmarks              B. cross-references      C. hyperlinks   D. word fields

14. Before creating a master document, you must switch to..……
A. Normal View         B. Outline View         C. Web Layout View D. Print Layout View

15. Before moving a subdocument to another location within a master document, you must switch to …………..
A. Normal View         B. Outline View         C. Web Layout View D. Print Layout View

16. Which of the following can be used to navigate documents?
A. frames        B. hyperlinks                          C. web toolbar           D. all of the above

17. Which of the following can be used to divide a web page into areas?
A. frames       B. theme          C. table of contents                 D. none of the above

18. By default, Word automatically formats each heading in a table of contents as ………..
A. bookmarks              B. cross-references      C. hyperlinks                         D. word-fields

19. The ability to combine name and addresses with a standard document is called ……….
A. document formatting              B. database management
C. mail merge                                 D. form letters

20. Which feature is used for monitoring all document changes?
A. Edit Document      B. Monitor Change     C. Track Change      D. Track all

=========================

 

 

 

 

21. When sharing data in Office, the ……… document is the document in which the data was first entered.
A. source           B. destination             C. original              D. primary

22. Which command is used to establish a link between a source document and a destination document?
A. Tools, Link, Documents                  B. Tools, Link
C. Edit, Link                                           D. Edit, Paste Special

23. Which option enables automatic updates in destination documents?
A. embedding             B. objects        C. links           D. relationships

24. Which is an Office feature that makes it easy to edit embedded objects?
A. pasting       B. visual editing          C. tools, update, links             D. edit, links

25. Which is true when you insert an excel worksheet into a word document?
A. word is the destination document   B. excel is the destination document
C. the worksheet is the destination document
D. the document is the source document

26. What would you do when you want to update the data in an embedded worksheet range?
A. double click the worksheet range object
B. right click worksheet range object & choose format object
C. edit the data in the destination document
D. edit the data in the source document.

27. Which can be used for quick access to commonly used commands and tools?
A. Status bar   B. Tool bar                             C. Menu bar                            D. Title bar

28. With which view can you see how text and graphics will appear on the printed page?
A. Normal                   B. Print Layout                     C. Outline                   D. Web Layout

29. Which simplifies the process of formatting text if the same formatting is required in more than one location?
A. Auto Text  B. Format Painter     C. Font dialog box                  D. None of the above

30. Which of the following is best for quick copy operation?
A. Copy and Paste      B. Windows Clipboard  C. Drag and Drop D. Auto Text

31. Which simplifies the process of formatting text if the same formatting is required in more than one location?
A. Auto Text   B. Format Painter C. Font dialog box D. None of the above

32. Which of the following is best for quick copy operation?
A. Copy and Paste      B. Windows Clipboard          C. Drag and Drop    D. Auto Text

33. Which of the following operations moves text from clipboard?
A. Copy          B. Paste          C. Drag and Drop       D. Cut

34. Which of the following provides a list ofx synonyms?
A. Find command       B. Replace Command             C. Thesaurus                         D. Spelling and Grammar

35. Which of the following helps to reduce spelling error in the document?
A. Auto Format          B. Auto Correct         C. Smart Tags                         D. Auto Text

36. Auto text and Auto correct are ___________ tools.
A. styling        B. editing                    C. designing                D. none of the above

37. Which of the following enables you to make multiple changes in a document at once?
A. find command        B. Replace command              C. Drag and Drop       D. copy command

38. Which of the following commands should you always use before submitting a document to others?
A. find command    B. Replace command     C. Spelling and Grammar     D. Thesaurus

39. Which of the following enables you to paste data multiple times?
A. windows clipboard            B. office clipboard  C. both A and B            D. none of the above

40. Which of the following do you use to change margins?
A. formatting toolbar              B. page setup dialog box       C. Standard toolbar
D. paragraph dialog box


 

 

 

41. Which do you press to force a page break?
A. CTRL+ALT            B. CTRL+ break          C. CTRL+ Enter     D. none of the above

42. Which do you choose to create footer?
A. format, header and footer               B. view, footer
C. insert, header and footer                 D. view, header and footer

43. Which do you choose to create header?
A. format, header and footer             B. view, header
C. insert, header and footer               D. view, header and footer

44. Which do you choose to shade words and paragraph?
A. format, borders and shading             B. insert, borders and shading
C. view, shading                                       D. none of the above

45. to view headers and footers, you must switch to
A. normal view            B. print layout view    . print preview mode  D. both B and C

46. Which of the following can you change using the page setup dialog box?
A. margins       B. page orientation      C. vertical alignment               D. all of the above

47. By default, your document prints with:
A. 1 inch top and bottom margins             B. a portrait orientation
C. 1.25 inches left and right margins         D. all of the above

48. switching between portrait and landscape modes involves the:
A. header and footer toolbar                   B. print layout view
C. page setup dialog box                           D. none of the above

49. What happens when you insert an AutoShape by simply clicking in the document?
A. it appears near the insertion point            B. it is inserted in its default size
C. is selected                                                       D. all of the above

50. What must be used to control the layering of objects?
A. formatting toolbar          B. picture toolbar
C. drawing toolbar               D. image toolbar

Share:
Powered by Blogger.

Ad Code

Responsive Advertisement

Ad Code

Responsive Advertisement

Featured post

Search This Blog

Recently added book names

THE HTML AND CSS WORKSHOP   | MICROSOFT POWER BI COOKBOOK   | MongoDB in Action, 2nd Edition  | ADVANCED DEEP LEARNING WITH PYTHON   | Cracking Codes with Python An Introduction to Building and Breaking  | Moris Mano Degital Design 3rd Edition  | Beginning App Development with Flutter by Rap Payne  |react hooks in Action - John Larsen   | Artificial Intelligence A Modern Approach Third Edition Stuart Russel  | Data Structures and Algorithms - Narasimha Karumanchi   | Thomas S.M. - PostgreSQL High Availability Cookbook - 2017  | Gunnard Engebreth PHP 8 Revealed Use Attributes the JIT Compiler   | ICSE Class X Computer Application Notes   | INTERNET OF THINGS PROJECTS WITH ESP32   | 100 aptitude trick(102pgs)s   | OBJECT_ORIENTED_PROGRAMMING Question & Answer   | C questions and answer   | Full_Book_Python_Data_Structures_And_Algorithm   | Jira 8 Administration Cookbook Third Edition  | KALI LINUX WIRELESS PENETRATION TESTING BEGINNERS GUIDE THIRD EDITION - Cameron Buchanan, Vivek Ramachandran  HTML5 & javascript By :- Jeanine Meyer   | Python For Beginners Ride The Wave Of Artificial Intelligence   | HackingTheXbox   | Introduction to Algorithms 3rd.Edition - (CLRS)   | The C++ Programming Language - Bjarne Stroustrup   | Modern C++ Programming Cookbook - Marius Bancila   | Java The Complete Reference Eleventh Edition   Data_Communications and Networking 4th Ed Behrouz A Forouzan   | DevOps with Kubernetes - Hideto Saito   | The-Linux-Command-Line-A-Complete-Introduction   | Assembly Language for X86 Processors KIP R. Irvine   | Effective_Modern_C++ - Scott Meyer

Contact Form

Name

Email *

Message *

Followers

Mobile Logo Settings

Mobile Logo Settings
image

Computer Training School Regd. under Govt. of West Bengal Society Act 1961

Header Ads Widget

Responsive Advertisement

Hot Widget

random/hot-posts

Recent in Sports

Popular Posts

Most Popular

Popular Posts

Labels

Blogger templates