×

Multiple-Choice Questions

Web Technologies MCQs

Computer Science Subjects MCQs

Databases MCQs

Programming MCQs

Testing Software MCQs

Digital Marketing Subjects MCQs

Cloud Computing Softwares MCQs

AI/ML Subjects MCQs

Engineering Subjects MCQs

Office Related Programs MCQs

Management MCQs

More

Microsoft Foundation Class (MFC) MCQs (Multiple-Choice Questions)

Practice Microsoft Foundation Class (MFC) MCQs (Multiple-Choice Questions) with answers and explanations. These MFC questions cover MFC architecture, CWinApp, CWnd, document/view architecture, message maps, dialogs, controls, resources, device contexts, SDI, MDI, document templates, and other important MFC concepts.

Microsoft Foundation Class (MFC) MCQs

Microsoft Foundation Classes (MFC) is a C++ class library for developing Windows applications. MFC provides classes that encapsulate many Win32 concepts and application features, including windows, dialogs, documents, views, menus, controls, and device contexts.

List of Microsoft Foundation Class (MFC) MCQs

The following MFC multiple-choice questions are useful for beginners, experienced C++ developers, technical interviews, examinations, and Windows application development preparation.

1. What does MFC stand for?

  1. Microsoft Foundation Classes
  2. Microsoft Framework Components
  3. Microsoft Functional Classes
  4. Microsoft Foundation Components

Answer: A) Microsoft Foundation Classes

Explanation:

MFC stands for Microsoft Foundation Classes. It is a C++ class library designed to simplify development of Windows applications.

2. Which programming language is primarily associated with MFC?

  1. Java
  2. C++
  3. Python
  4. Visual Basic

Answer: B) C++

Explanation:

MFC is a C++ class library. It provides C++ wrappers and framework classes for many Windows programming concepts and Win32 APIs.

3. Which MFC class represents the main application object?

  1. CWnd
  2. CView
  3. CWinApp
  4. CDocument

Answer: C) CWinApp

Explanation:

CWinApp is the main application class in MFC. An MFC application normally has one application object derived from CWinApp.

4. Which MFC class provides the base functionality for Windows objects?

  1. CWnd
  2. CFrameWnd
  3. CDialog
  4. CView

Answer: A) CWnd

Explanation:

CWnd provides the basic functionality of Windows window objects in MFC and encapsulates the Win32 window handle represented by HWND.

5. Which MFC class represents an application document in the document/view architecture?

  1. CView
  2. CDocument
  3. CWnd
  4. CFrameWnd

Answer: B) CDocument

Explanation:

CDocument provides the basic functionality for programmer-defined document classes and is responsible for representing application data.

6. Which MFC class represents a view of a document?

  1. CView
  2. CDocument
  3. CWinApp
  4. CDocTemplate

Answer: A) CView

Explanation:

CView provides the basic functionality for view classes. A view displays document data and handles user interaction with that data.

7. Which MFC class is commonly used as the base class for an SDI frame window?

  1. CFrameWnd
  2. CDialog
  3. CView
  4. CDocument

Answer: A) CFrameWnd

Explanation:

CFrameWnd supports frame-window objects. It is commonly used as the base for the main frame window in an SDI MFC application.

8. Which MFC class is commonly used for the main frame window in an MDI application?

  1. CMDIFrameWnd
  2. CView
  3. CDocument
  4. CDialog

Answer: A) CMDIFrameWnd

Explanation:

CMDIFrameWnd provides functionality for the main frame window of an MDI application.

9. Which MFC class represents a dialog box?

  1. CDialog
  2. CFrameWnd
  3. CMenu
  4. CView

Answer: A) CDialog

Explanation:

CDialog encapsulates dialog-box functionality in MFC. Custom dialog classes are commonly derived from CDialog or one of its derived classes.

10. Which MFC class encapsulates a Win32 device context?

  1. CDC
  2. CWnd
  3. CBitmap
  4. CBrush

Answer: A) CDC

Explanation:

CDC encapsulates a Windows device context and provides member functions for drawing and other device-context operations.

11. Which MFC class represents a Windows menu?

  1. CMenu
  2. CMenuBar
  3. CCommandMenu
  4. CWinMenu

Answer: A) CMenu

Explanation:

CMenu provides an MFC wrapper for Windows menu resources and menu handles.

12. Which MFC class represents a font?

  1. CFont
  2. CTextFont
  3. CTypeface
  4. CFontObject

Answer: A) CFont

Explanation:

CFont encapsulates a Windows font object and provides functions for creating and managing fonts.

13. Which MFC class represents a brush?

  1. CBrush
  2. CFill
  3. CBackground
  4. CBrushObject

Answer: A) CBrush

Explanation:

CBrush encapsulates a Windows brush object, which can be selected into a device context for filling areas.

14. Which MFC class represents a pen used for drawing?

  1. CPen
  2. CLine
  3. CDrawPen
  4. CPenStyle

Answer: A) CPen

Explanation:

CPen encapsulates a Windows pen object. It can be used to control the appearance of lines drawn through a device context.

15. Which MFC class encapsulates a bitmap?

  1. CBitmap
  2. CImageMap
  3. CGraphic
  4. CBitmapView

Answer: A) CBitmap

Explanation:

CBitmap encapsulates a Windows bitmap object and provides functions for loading, creating, and managing bitmap resources.

16. Which MFC class represents a point?

  1. CPoint
  2. CPosition
  3. CXY
  4. CPointObject

Answer: A) CPoint

Explanation:

CPoint is an MFC geometry class representing a point using horizontal and vertical coordinates.

17. Which MFC class represents a rectangle?

  1. CRect
  2. CBox
  3. CRectangle
  4. CWindowRect

Answer: A) CRect

Explanation:

CRect represents a rectangle and provides operations for manipulating its coordinates, dimensions, and relationships with other rectangles.

18. Which MFC class represents a size?

  1. CSize
  2. CDimension
  3. CWidthHeight
  4. CMeasure

Answer: A) CSize

Explanation:

CSize represents the dimensions of an object using width and height values.

19. Which MFC class is commonly used to represent a string?

  1. CString
  2. CStringObject
  3. CText
  4. CStdString

Answer: A) CString

Explanation:

CString is an MFC string class that provides convenient operations for storing and manipulating strings.

20. Which class is the root class of the MFC class hierarchy?

  1. CWnd
  2. CObject
  3. CWinApp
  4. CBase

Answer: B) CObject

Explanation:

CObject is the root of the principal MFC class hierarchy and provides common functionality such as runtime-class support and serialization support for appropriate derived classes. Not every MFC-related type derives from CObject.

21. Which MFC class is derived from CWinThread and represents the main application object?

  1. CWnd
  2. CWinApp
  3. CFrameWnd
  4. CDocument

Answer: B) CWinApp

Explanation:

CWinApp is derived from CWinThread. The application object represents the primary application thread and controls application initialization and termination.

22. Which member function is commonly overridden in a CWinApp-derived class to initialize an MFC application?

  1. InitInstance
  2. StartApplication
  3. InitializeApp
  4. OnStart

Answer: A) InitInstance

Explanation:

InitInstance is commonly overridden in a class derived from CWinApp to perform application-specific initialization.

23. What does the MFC document/view architecture primarily separate?

  1. CPU and memory
  2. Data and its presentation
  3. Menus and toolbars
  4. Threads and processes

Answer: B) Data and its presentation

Explanation:

The document/view architecture separates the application's data from how that data is displayed and manipulated. The document manages the data, while the view presents it to the user.

24. Which MFC class is responsible for storing or managing application data in the document/view model?

  1. CView
  2. CDocument
  3. CFrameWnd
  4. CWnd

Answer: B) CDocument

Explanation:

The document class represents the application's data. It can also handle persistence-related operations such as loading and saving document data.

25. Which MFC class displays document data and handles user interaction with it?

  1. CView
  2. CDocument
  3. CWinApp
  4. CDocTemplate

Answer: A) CView

Explanation:

A view acts as the user's window onto the document data. It displays the data and processes appropriate user interactions.

26. Which MFC class coordinates the creation and management of documents, views, and frame windows?

  1. CDocTemplate
  2. CView
  3. CWinApp
  4. CWnd

Answer: A) CDocTemplate

Explanation:

CDocTemplate coordinates the relationships between document, view, and frame-window classes for a particular document type.

27. Which document template class is typically used for an SDI application?

  1. CMultiDocTemplate
  2. CSingleDocTemplate
  3. CSdiTemplate
  4. CSingleViewTemplate

Answer: B) CSingleDocTemplate

Explanation:

CSingleDocTemplate is the document-template class used for applications with a single document at a time, such as a typical SDI application.

28. Which document template class is typically used for an MDI application?

  1. CSingleDocTemplate
  2. CMultiDocTemplate
  3. CMdiTemplate
  4. CMultiViewTemplate

Answer: B) CMultiDocTemplate

Explanation:

CMultiDocTemplate supports multiple documents of a particular type in an MDI application.

29. What does SDI stand for in MFC application architecture?

  1. Single Data Interface
  2. Single Document Interface
  3. System Document Interface
  4. Standard Document Integration

Answer: B) Single Document Interface

Explanation:

SDI stands for Single Document Interface. An SDI application typically works with one document at a time within its main frame window.

30. What does MDI stand for?

  1. Multiple Document Interface
  2. Managed Document Interface
  3. Multiple Data Integration
  4. Microsoft Document Interface

Answer: A) Multiple Document Interface

Explanation:

MDI stands for Multiple Document Interface. An MDI application can manage multiple document windows within a main frame window.

31. Which MFC class provides support for a scrolling view?

  1. CScrollView
  2. CScrollableWnd
  3. CScrollWnd
  4. CViewScroll

Answer: A) CScrollView

Explanation:

CScrollView is derived from CView and provides support for scrolling within a view.

32. Which MFC class is useful for a view based on a dialog-template resource?

  1. CFormView
  2. CDialogView
  3. CFormDialog
  4. CViewForm

Answer: A) CFormView

Explanation:

CFormView provides a form-based view whose controls can be laid out using a dialog-template resource.

33. Which mechanism does MFC use to associate Windows messages and commands with class member functions?

  1. Message maps
  2. Virtual tables only
  3. Resource maps
  4. Command arrays

Answer: A) Message maps

Explanation:

MFC uses message maps to connect Windows messages and command identifiers with member functions that handle them.

34. Which macro begins the message map declaration for an MFC class?

  1. BEGIN_MESSAGE_MAP
  2. START_MESSAGE_MAP
  3. DECLARE_MESSAGE_MAP
  4. BEGIN_MFC_MAP

Answer: A) BEGIN_MESSAGE_MAP

Explanation:

BEGIN_MESSAGE_MAP starts the implementation of a message map. It is normally paired with END_MESSAGE_MAP.

35. Which macro is commonly placed in the class declaration to declare that a class has a message map?

  1. DECLARE_MESSAGE_MAP
  2. DEFINE_MESSAGE_MAP
  3. MESSAGE_MAP_DECLARE
  4. DECLARE_MFC_MAP

Answer: A) DECLARE_MESSAGE_MAP

Explanation:

DECLARE_MESSAGE_MAP is placed in an MFC class declaration when the class uses a message map.

36. Which macro is used to map a command message to a member function?

  1. ON_COMMAND
  2. ON_MESSAGE_COMMAND
  3. MAP_COMMAND
  4. COMMAND_HANDLER

Answer: A) ON_COMMAND

Explanation:

ON_COMMAND maps a command identifier to a member function in an MFC message map.

37. Which message-map macro is commonly used to handle a button click notification?

  1. ON_BN_CLICKED
  2. ON_BUTTON_CLICK
  3. ON_CLICK_BUTTON
  4. ON_CONTROL_CLICK

Answer: A) ON_BN_CLICKED

Explanation:

ON_BN_CLICKED maps the button's BN_CLICKED notification to a handler function.

38. Which MFC function is commonly overridden to draw the contents of a view?

  1. OnDraw
  2. DrawView
  3. RenderView
  4. PaintDocument

Answer: A) OnDraw

Explanation:

OnDraw is a member function of CView and is commonly overridden to render document data in the view.

39. Which MFC class is commonly used to represent a toolbar?

  1. CToolBar
  2. CBar
  3. CToolWindow
  4. CButtonBar

Answer: A) CToolBar

Explanation:

CToolBar provides functionality for creating and managing toolbar controls in an MFC application.

40. Which MFC class is commonly used to represent a status bar?

  1. CStatusBar
  2. CStatusWindow
  3. CInfoBar
  4. CStatusControl

Answer: A) CStatusBar

Explanation:

CStatusBar provides functionality for creating and managing status bars in MFC frame windows.

41. Which MFC class can be used to create and manipulate a list box control?

  1. CListBox
  2. CListControl
  3. CListWindow
  4. CItemsBox

Answer: A) CListBox

Explanation:

CListBox encapsulates the functionality of a Windows list-box control.

42. Which MFC class encapsulates an edit control?

  1. CEdit
  2. CTextBox
  3. CInput
  4. CEditBox

Answer: A) CEdit

Explanation:

CEdit provides the MFC wrapper for a Windows edit control and supports operations such as setting and retrieving text.

43. Which MFC class encapsulates a button control?

  1. CButton
  2. CButtonControl
  3. CCommandButton
  4. CBtn

Answer: A) CButton

Explanation:

CButton encapsulates a Windows button control and supports operations such as setting button states and handling notifications.

44. Which MFC class is used to access a dialog control through a control ID?

  1. CWnd
  2. CDialog
  3. CView
  4. CDocument

Answer: B) CDialog

Explanation:

An MFC dialog class derived from CDialog can access its child controls using functions such as GetDlgItem or control-member mechanisms such as DDX.

45. What does DDX primarily provide in MFC dialog programming?

  1. Data exchange between controls and member variables
  2. Database encryption
  3. Document indexing
  4. DirectX rendering

Answer: A) Data exchange between controls and member variables

Explanation:

DDX, or Dialog Data Exchange, transfers data between dialog controls and corresponding member variables of a dialog class.

46. What is the purpose of MFC resources such as dialog, menu, icon, and bitmap resources?

  1. They define application interface and other compiled resources
  2. They replace all C++ classes
  3. They execute application threads
  4. They store CPU instructions

Answer: A) They define application interface and other compiled resources

Explanation:

MFC applications commonly use Windows resources for elements such as dialogs, menus, icons, cursors, strings, and bitmaps. These resources can be edited using Visual Studio resource tools.

47. Which MFC macro is associated with runtime class information and dynamic object creation for appropriate classes?

  1. DECLARE_DYNCREATE
  2. DECLARE_RUNTIME
  3. ENABLE_RUNTIME
  4. CREATE_RUNTIME_CLASS

Answer: A) DECLARE_DYNCREATE

Explanation:

DECLARE_DYNCREATE is used in a class declaration when MFC runtime class information and dynamic object creation support are required. It is commonly paired with IMPLEMENT_DYNCREATE.

48. Which MFC class represents a thread of execution?

  1. CWinThread
  2. CThreadObject
  3. CExecutionThread
  4. CAppThread

Answer: A) CWinThread

Explanation:

CWinThread represents a thread of execution in MFC. CWinApp itself is derived from CWinThread.

49. Which MFC class can be used to display a simple message box?

  1. CMessageBox
  2. AfxMessageBox
  3. CDialogMessage
  4. CAlertBox

Answer: B) AfxMessageBox

Explanation:

AfxMessageBox is an MFC global function used to display a message box. It is a function rather than an MFC class.

50. Consider the following MFC view implementation. What is the purpose of the code?

void CMyView::OnDraw(CDC* pDC)
{
    pDC->TextOut(50, 50, _T("Hello MFC"));
}
  1. It creates a new document
  2. It displays "Hello MFC" in the view at the specified coordinates
  3. It creates a dialog box
  4. It terminates the application

Answer: B) It displays "Hello MFC" in the view at the specified coordinates

Explanation:

OnDraw is used to render content in an MFC view. The CDC pointer provides access to the device context, and TextOut draws the specified text at the given coordinates. Therefore, this code displays Hello MFC at position (50, 50) in the view.

Advertisement
Advertisement

Comments and Discussions!

Load comments ↻


Advertisement
Advertisement
Advertisement

Copyright © 2026 www.includehelp.com. All rights reserved.