C++ MCQ for all Units - Oops (40), C++ Fundamentals(30), Constants & Data types(30), Decision Making (20), Operators, Functions(20), Arrays(30), Structures(10) & Strings, Pointer(20), File(30)
This document provides an introduction to a programming fundamentals course. It outlines the course objectives of appreciating the need for a programming language, introducing structured programming methodology, and developing a useful physics program. It then details the course contents which will cover basic programming constructs, structured programming, OOP concepts, and an introduction to C++ including variables, control structures, functions, arrays, pointers, and object-oriented programming. Resources and the course policy on assignments, exams, and grading are also included.
C++ is an object-oriented programming language that is a superset of C and was created by Bjarne Stroustrup at Bell Labs in the early 1980s. C++ supports features like classes, inheritance, and object-oriented design while also being compatible with C. Some key characteristics of C++ include its support for object-oriented programming, portability, modular programming, and C compatibility. C++ programs are made up of tokens like identifiers, keywords, literals, punctuators, and operators.
This document contains 60 multiple choice questions with answers about computers and technology. The questions cover topics such as computer components, operating systems, software, hardware, file formats, networking, and internet terminology. The correct answers are provided for each question.
This document defines object-oriented programming and compares it to structured programming. It outlines the main principles of OOP including encapsulation, abstraction, inheritance, and polymorphism. Encapsulation binds code and data together for security and consistency. Abstraction hides implementation details and provides functionality. Inheritance allows classes to acquire properties from other classes in a hierarchy. Polymorphism enables different types to perform the same methods.
The document discusses the different types of operators in C++, including unary, binary, ternary, arithmetic, logical, comparison, assignment, bitwise, and special operators like scope resolution (::), endl, and setw. It provides examples of how each operator is used, such as increment/decrement for unary, addition/subtraction for binary, conditional operator ?: for ternary, and manipulating bits with bitwise operators. The document also explains how scope resolution allows accessing global variables from inner blocks and how endl and setw are used for formatting output displays.
This document contains lecture notes on Java programming divided into 6 units. Unit 1 provides an introduction to Java including an overview of data types, variables, arrays, operators, control statements, classes and objects, and input/output. It also covers inheritance, abstract classes, and the object class. Subsequent units cover topics like string handling, packages, interfaces, exception handling, multithreading, applets, event handling, AWT, Swings, and JDBC. Examples of Java programs and potential errors are also provided.
This document introduces Edgar Barbosa, a senior security researcher who has worked on hardware-based virtualization rootkits and detecting such rootkits. It then provides an overview of control flow analysis (CFA), a static analysis technique used to analyze program execution paths. CFA involves constructing a control flow graph (CFG) from a disassembled binary. The document discusses basic block identification, CFG properties, and challenges like self-modifying code. It also introduces other CFA concepts like dominator trees, natural loops, strongly connected components, and interval analysis.
Let us c (by yashvant kanetkar) chapter 1 solutionHazrat Bilal
This document contains solutions to various questions related to C programming language concepts. It discusses valid and invalid variable names in C, identifies errors in sample C code statements, evaluates expressions and shows the hierarchy of operations, and provides answers to multiple choice questions about C fundamentals. Sample C code is also provided to demonstrate calculating areas and perimeters of shapes, employee salaries, percentages and conversions between measurement units.
Computer Networks Multiple Choice Questions (MCQs) cover a wide range of topics related to the fundamental principles, protocols, and technologies that govern the communication and connectivity of computer systems. These questions are designed to test the knowledge and understanding of individuals in the field of computer networking. Below is a description outlining the common themes covered by MCQs in this domain:
Network Basics:
MCQs may assess the understanding of basic networking concepts such as nodes, links, topology, and communication models.
Questions might cover the differences between local area networks (LANs) and wide area networks (WANs), as well as their applications.
Protocols and Standards:
Questions often focus on network protocols, such as TCP/IP, HTTP, FTP, and their roles in data transmission.
Familiarity with networking standards and organizations like the IEEE and the Internet Engineering Task Force (IETF) is commonly tested.
Networking Devices:
MCQs may inquire about the functionality of networking devices like routers, switches, hubs, and their roles in network infrastructure.
Understanding the purpose and operation of devices like modems and gateways may also be examined.
IP Addressing and Subnetting:
Questions might cover topics related to IP addressing, subnetting, and the differences between IPv4 and IPv6.
Subnet masks, network classes, and CIDR notation could be focal points in these questions.
Data Link Layer and Switching:
Understanding the data link layer and its protocols (e.g., Ethernet) is often tested.
Questions may address concepts related to MAC addresses, switching techniques, and VLANs (Virtual Local Area Networks).
Routing and Routing Protocols:
Questions may assess knowledge of routing algorithms and protocols such as RIP, OSPF, and BGP.
Understanding the routing table, routing metrics, and the role of routers in forwarding data is essential.
Wireless Networking:
Topics related to wireless communication standards (e.g., Wi-Fi), security protocols, and frequency bands may be covered.
Questions might address challenges and solutions in wireless networking environments.
Network Security:
MCQs may focus on security protocols, firewalls, encryption, and authentication mechanisms.
Understanding common security threats and countermeasures is typically part of these questions.
Network Management and Troubleshooting:
Questions may assess knowledge of network management protocols (e.g., SNMP) and troubleshooting techniques.
Understanding tools for monitoring, diagnosing, and resolving network issues is crucial.
Emerging Technologies:
Some MCQs may explore contemporary topics such as cloud computing, virtualization, and the Internet of Things (IoT) in the context of networking.
This document contains a quiz on C++ programming concepts like classes, objects, inheritance, operator overloading, and strings. It has 67 multiple choice questions covering topics like data types, linkages, class members, constructors, destructors, operator functions, and string functions. The questions aim to test the reader's understanding of important C++ programming concepts.
This document discusses functions in C++. It defines a function as a block of code that performs a specific task and can be reused. The key points made are:
- Functions allow for modular and reusable code. They group statements and give them a name to be called from other parts of a program.
- The document demonstrates simple functions in C++ through examples, including defining, declaring, calling, passing arguments to, and returning values from functions.
- Other function concepts covered include function overloading, recursion, inline functions, default arguments, scope and storage class, and global vs local variables.
The document discusses the origins and features of the C++ programming language. It began as an expanded version of C created by Bjarne Stroustrup in 1979. Key features discussed include input/output using cout and cin operators, manipulators like endl and setw for formatting output, reference variables which provide an alias for another variable, and the different data types in C++ including built-in types like int and char, and derived types like arrays, functions, pointers, references, structures, unions, classes, and enumerations.
Function overloading allows multiple functions to have the same name but different parameters within a class. Function overriding occurs when a function in a derived class has the same name and signature as a function in the base class. Overloading deals with functions within a class, while overriding deals with functions in a parent-child class relationship. The compiler determines which function to call based on the parameters passed. Making functions virtual allows for dynamic binding so the correct overriding function is called based on the object type.
The document provides an overview of the C programming language. It discusses the origins and development of C from earlier languages like ALGOL and BCPL. It describes key features of C like data types, variables, constants, and operators. It also provides a basic Hello World program example and explains the process of compiling and executing a C program.
The document discusses the basic functional units of a computer:
- The input unit accepts coded data from devices like keyboards.
- Memory stores programs and data, with primary storage operating at fast electronic speeds.
- The arithmetic and logic unit (ALU) performs operations on data brought in from memory.
- The output unit sends processed results outside the computer to devices like printers.
- The control unit coordinates the other functional units and sequencing of operations.
Programming involves developing programs by specifying computational steps in a programming language. An algorithm is a logical list of steps to solve a problem. Developing good algorithms involves specifying clear input/output, variables, and ensuring the algorithm terminates in a finite number of steps. Flowcharts provide a pictorial representation of algorithm steps and are useful for explaining programs. A computer program consists of instructions provided to the computer to solve a problem.
Method overriding allows a subclass to provide a specific implementation of a method that is already provided by its superclass. The subclass method must have the same name, parameters and return type as the superclass method. This allows the subclass to modify the behavior as needed and is how polymorphism is implemented. The super keyword can be used to call the superclass method from the overriding method.
Inheritance In C++ (Object Oriented Programming)
Basically this presentation is about inheritance in C++. Whole Inheritance of C++ is described in it in very well way.
This document contains 33 multiple choice questions related to software engineering concepts and processes. The questions cover topics such as software life cycle models, software requirements, quality assurance, testing methods, maintenance types, and object-oriented design principles.
This document contains a quiz on C++ programming concepts with multiple choice questions and answers. There are questions about linkage types in C++, static and extern keywords, function prototypes, operator overloading, complex numbers, type conversions, friend functions, and virtual functions. The document provides explanations for some answers.
This document contains 57 multiple choice questions related to C++ concepts such as classes, objects, inheritance, polymorphism, encapsulation, and exception handling. Each question has a single correct answer choice. The questions cover topics like class definitions, object oriented design, abstract classes, inheritance, operator overloading, templates, and exception handling in C++.
This document contains a quiz on Java programming concepts. It covers topics like Java keywords, data types, operators, control structures, and loops. There are 33 multiple choice questions testing understanding of basic Java building blocks like variables, arrays, conditionals, and iterations. The questions range from identifying valid Java syntax to analyzing sample code snippets.
2009 Punjab Technical University B.C.A Object Oriented Proagramming Language ...Monica Sabharwal
This document outlines the structure and questions for an exam on Object Oriented Programming using C++. It is divided into two sections:
Section A contains 10 multiple choice questions covering topics like detecting end of file, if-else constructs, inline functions, stream classes, manipulators, and static variables.
Section B contains 4 longer answer questions asking about object oriented characteristics, user defined data types, constructors, inheritance, passing arguments by reference vs address, abstract base classes, and static vs runtime binding. Students must answer all of Section A and 4 of the 5 questions in Section B.
OOM MCQ Dev by Prof PL Pradhan TGPCET, NAGPURlochan100
This document contains 30 multiple choice questions about object-oriented methodology concepts. It covers topics like classes, objects, attributes, methods, encapsulation, inheritance, polymorphism, and abstraction. Object-oriented programming aims to reduce complexity through concepts like encapsulation, inheritance and polymorphism. Languages like Smalltalk are considered pure object-oriented as everything is treated as an object.
The document provides examples and explanations of C++ programming concepts related to pointers, references, operators, strings, inheritance, and runtime type identification. It includes sample code and identifies the correct output. Key concepts covered include dereferencing pointers, pre-increment and post-increment operators, reversing a string, abstract base classes, pure virtual functions, and dynamic_cast and typeid as part of runtime type information.
The document contains a C++ programming quiz with 55 multiple choice questions related to topics like C++ fundamentals, OOPs concepts, pointers, strings, inheritance, polymorphism, operator overloading etc. Each question is followed by 4 answer options and the correct answer is highlighted. The questions test knowledge of basic C++ syntax, language features and their applications.
This document contains a 100 multiple choice question exam for computer science students at Admas University. The exam covers 6 themes: 1) System Development, 2) Programming and Algorithms, 3) Computer Networks and Security, 4) Database Systems, 5) Web Programming, and 6) Network and System Administration. Each section contains questions pertaining to the associated theme. The exam is being administered to computer science students as part of an exit exam requirement.
The document contains multiple choice questions about use case diagrams, the unified process, object-oriented analysis and design principles, and UML. Some key points covered are:
- A use case diagram models the behavior of a system and shows relationships like association, generalization, and dependency.
- The unified process has phases like inception, elaboration, construction, and transition.
- Object-oriented principles include encapsulation, inheritance, polymorphism, and abstraction.
- UML diagrams like class and use case diagrams are used in analysis and design.
Object Oriented Analysis and Design one marks Q & Aeeducations ever
The document contains 50 multiple choice questions related to object oriented analysis and design. The questions cover topics such as the expansion of common acronyms like UML, classes and objects, behavior, inheritance, validation, design phases, prototypes, rapid application development approaches, reuse strategies, modeling diagrams, patterns, properties of associations, coupling and cohesion, testing techniques, and usability testing. An answer key is provided with the correct response for each question.
The Object oriented system developed by Dr Pradhan P L which will be helpful to GATE-UPSC-NET Exam for B Tech, M Tech CSE ,IT, BCA, MCA & MSc ( Computer Sc & IT )
OOS MCQ 2018 Developed by Dr PL Pradhan, IT Dept, TGPCET, NAGPUR, INDIA
Subject Teacher of OOM as per RTM Nagpur university
The document provides information about a model exit exam for a computer science department, including:
- The exam is divided into 6 themes covering various computer science topics.
- Each theme includes multiple courses, their credit hours, and number of exam questions pertaining to that course.
- The document provides instructions to read the questions, choose the right answer, and mark it on a separate answer sheet.
- It provides 27 multiple choice questions covering topics like system development, programming, algorithms, and more.
VB 6 is not a true object-oriented programming language, while the others listed (VB.NET, C++, C#, Java) are. Visual Studio .NET provides both debugging and application deployment features. IDE stands for Integrated Development Environment. The Start Menu is not a main component of the Visual Studio IDE. The solution explorer does not display assembly files. The code editor is used for adding event procedures to forms. The .NET class library contains over 25,000 classes, uses namespaces to manage classes, and has the System.Forms namespace for Windows forms classes.
This document provides an overview of the CIS 115 Introduction to Programming and Logic course. The course introduces computer programming, problem solving, and logic. Topics covered include syntax, data types, program organization, algorithm design, control structures, and object-oriented programming. Upon completing the course, students should be able to write programs using variables, arrays, functions, files and recursion, as well as implement sorting and searching algorithms.
Std 12 computer chapter 8 classes and objects in java important MCQsNuzhat Memon
Std 12 Computer Chapter 8 Classes and Objects in Java important MCQs
Std 12 Computer MCQs
Computer std 12 mcq ch 8
computer std 12 ch 8 mcq
std 12 important mcq
chapter 8 Classes and Object in Java
creating a class in java
creating an object in java
constructor in java
inheritance in java
polymorphism in java
method overloading and method overridden
(1) This document provides instructions for a midterm exam on Programming II taken by students at Al Imam Mohammad Ibn Saud Islamic University. The exam contains 4 questions to be completed in 90 minutes.
(2) Question 1 contains 8 multiple choice questions about object-oriented programming concepts like interfaces, inheritance, and polymorphism.
(3) Question 2 asks students to identify 3 errors in a code sample and provide corrections.
(4) Question 3 asks students to provide the output of 3 code segments.
(5) Question 4 asks students to design classes to model a medical staff management system, including abstract and concrete classes, and to write a test class demonstrating polymorphism.
C++ provides classes as templates to define common data structures and algorithms. Classes like vector and list define containers that store and retrieve objects through iterators. Iterators allow traversing container elements without knowing details of the underlying data structure. The Standard Template Library contains many useful container and algorithm classes that take advantage of templates and iterators to provide powerful and flexible generic programming capabilities in C++.
This document contains instructions for a 3-hour Object Oriented Programming exam for Kendege Technical & Vocational College students. It outlines 5 questions with multiple parts each that cover topics like writing object-oriented programs, classes, access specifiers, functions, arrays, and more. Students are instructed to answer all questions in the provided answer booklet.
Sample Paper 2 Class XI (Computer Science)Poonam Chopra
This document contains a sample paper for Class 11 Computer Science with 7 questions covering topics like characteristics of computers, operating systems, data vs information, RAM vs ROM, loops, arrays, functions, structures, unions, and different types of errors. The paper has 70 total marks and is focused on testing knowledge of basic C++ programming concepts through multiple choice and code writing questions.
this pdf very much useful for embedded c programming studentspavan81088
This document provides a quiz on C programming language concepts with 95 multiple choice questions. Some key points covered include:
- C was developed in 1972 by Dennis Ritchie at Bell Labs. It is a middle-level programming language suitable for system programming like operating systems or embedded systems.
- C supports data types like int, float, arrays, structures and pointers. Operators include arithmetic, relational, logical, bitwise, assignment and more.
- C supports conditional statements like if-else and switch cases. Looping statements include while, do-while and for loops.
- C provides standard I/O functions like printf, scanf and file I/O functions. Memory management functions
Similar to C++ 260 MCQ Question with Answer for all Units (20)
Digital Old Question Paper for Reference (Bharathiyar University)ANUSUYA S
This document provides information about a B.Sc/B.C.A degree examination for digital fundamentals and computer architecture. It includes details like the registration number, question paper code, date of exam (November 2018), maximum marks (75), duration (3 hours) and sections in the question paper.
Section A contains 10 multiple choice questions carrying 1 mark each. Section B contains 5 questions carrying 5 marks each, totaling 25 marks. Section C contains 5 questions carrying 8 marks each, totaling 40 marks. The paper tests knowledge across various topics in digital fundamentals and computer architecture. It requires students to answer all questions from sections A, B and C.
C Old Question Paper for Reference (Bharathiyar University)ANUSUYA S
This document contains questions for a degree examination in computer programming and computing fundamentals. It includes multiple choice and short answer questions about C programming concepts like data types, control structures, functions, pointers, arrays, structures, unions and file management. Students are asked to identify correct answers, explain concepts, write programs to illustrate ideas, and discuss topics in detail with examples.
C++ - UNIT_-_V.pptx which contains details about File ConceptsANUSUYA S
The document discusses file handling in C++. It explains that files are used to store data permanently on a storage device. There are three main classes used for file handling - ifstream for input, ofstream for output, and fstream for both input and output. The key file handling operations include opening a file using open(), reading from a file using read(), writing to a file using write(), and closing a file using close(). It also discusses opening files in different modes, reading and writing binary data to files, and handling exceptions that may occur during file operations.
C++ Unit 1PPT which contains the Introduction and basic o C++ with OOOps conc...ANUSUYA S
C++ is an object-oriented programming language that began as an expanded version of C. It was invented by Bjarne Stroustrup in 1979 at Bell Labs. C++ supports concepts of object-oriented programming like classes, inheritance, polymorphism, abstraction and encapsulation. It is a compiled, general purpose language that allows both procedural and object-oriented programming. Key features of C++ include input/output streams, declarations, control structures like if-else and switch statements.
C++ - UNIT_-_IV.pptx which contains details about PointersANUSUYA S
Pointer is a variable in C++ that holds the address of another variable. Pointers allow accessing the memory location of other variables. There are different types of pointers based on the data type they are pointing to such as integer, character, class etc. Pointers are declared using an asterisk * before the pointer variable name. The address of a variable can be assigned to a pointer using the & address of operator. Pointers can be used to access members of a class and pass arrays to functions. The this pointer represents the address of the object inside member functions. Virtual functions allow dynamic binding at runtime in inheritance.
Alter Magazine Artist Development Edition: The Creative Edge**
Powered by Chvngetheworld, Alter Magazine's "Artist Development Edition: The Creative Edge" delves into the transformative journey of artists. This edition explores individual and collaborative creativity, emphasizing continuous improvement and lifelong learning in the arts. Ideal for artists and creatives seeking inspiration and growth, this edition provides insights and strategies for artistic development.
Optimize your artistic potential with Alter Magazine and join a community dedicated to pushing creative boundaries.
artist development, creative collaboration, continuous improvement in arts, lifelong learning for artists, artistic journey, creativity exploration.
Buy weed in Kuwait City Telegram @pplanet0 weed for sale in Kuwaithayssysy
Buy weed in Kuwait City Telegram @pplanet0 weed for sale in Kuwait
Message us on Telegram @pplanet0 to buy weed and cannabis related products online in Abu Dhabi, Dubai, Sharjah, Ajman, Ras Al Khaimah, Fujairah, Umm Al Quwain.
We have top quality weed, lsd coke, shrooms, ketamine, Ecstasy, Hash and more. Buy hash and Weed in dubai,abu dhabi,sharjah where to buy weed in doha,where can i find weed in jeddah,Can I get weed delivered to Riyadh?,Buy weed Online Jeddah Saudi Arabia,Buy Weed and THC Cannabis Oil online ,QATAR , DOHA buy kush in DOHA , buy kush in DOHAWeed in QATAR # DOHA Buy Weed and THC Cannabis Oil online who delivers at your own location in Qatar Doha ,Kuwait ,Dubai including cannabis / weed,Where can I find weed in Dubai as a tourist?,Is marijuana allowed in Dubai ? How much is medical marijuana in Dubai ?Is weed legal in Dubai ?How to get marijuana in Saudi Arabia Do people in Saudi Arabia smoke weed ? Is Hash legal in Saudi Arabia ? Where is marijuana the most illegal?Can you get weed in Baku? Dubai, United Arab Emirates Canabis smokers - Dubai, Buy Marijuana Products Online in UAE Desertcart ships the Marijuana products in Dubai ,Abu Dhabi, Sharjah, Al Ain, Ajman and more cities in UAE. Where can I find weed in Dubai? Where can I find weed in Dubai? I am going to Abu Dhabi. How hard is it to find weed Is marijuana allowed in Dubai? Now I'm in Dubai. Can I find high quality cannabis here? How much is medical marijuana in Dubai? where can i find weed, cocaine, hash,mdma in dubai as a tourist? weed, cocaine, hash, cystal, mdma for sell in uae, dubai, saudi arabia, qatar, oman, kuwait where to get good quality weed, cocaine, hash, crystal mdma online in dubai, uae, ajman, abu dhabi
Buy weed in Dubai, Buy weed in Abu Dhabi, Buy weed in Sharjah, Buy weed in Ras Al Khaimah, Buy weed in UAE, Buy weed in Al Ain, Buy weed in Umm al-Qaiwain, Buy weed in Fujairah, Buy weed in Ajman, Buy weed in qatar buy weed in jeddah buy weed in saudi arabia buy weed in riyadh buy weed in iraq buy cocaine in dubai buy cocaine in abu dhabi buy cocaine in saudi arabia buy cocaine in sharjah buy cocaine in kuwait buy cocaine in bahrain buy cocaine in iraq buy cocaine in fujairah buy cocaine in ajman buy cocaine in oman buy cocaine in qatar where can i buy weed, cocaine, hash, xanax, cbd oil, mdma in dubai, uae, abu dhabi where can i find cocaine in uae/ dubai
OZ (28grams) $250 1/8 pound(56grams) $500 1/4 pound(112grams) $750 1/2 pound(224grams) $900 1 pound(448grams) $1600
The Legacy of Breton In A New Age for Surrealmageddon Visual Poetry in the Ne...BBaez1
☠️BRAVE DESTINY💥 2003 for the Art World History!! "Over 400 international artists celebrate the historical and contemporary Surrealism. Film, fashion, art, performances and parties in the name of an artistic revolution" https://www.wahcenter.net/exhibits/2003/surreal/ https://sites.google.com/site/internationalsurrealism/brave-destiny
Le Viconte de St. Ouen will open the Brave Destiny exhibit at the ceremony, with Ernst Fuchs honored guest and Brave Leader of the movement. Many world famous artists. Fantastic happenings! Prize for best costume. Winners of cash awards announced. Lifetime achievement honors announced, and more. Great food from the finest restaurants in Williamsburg, a culinary feast at the WAH Center, the institution that Let’s Go Travel Magazine called the "epicenter of the Williamsburg artists Mecca!" 'https://online.pubhtml5.com/jltd/iyue/'
🌎❤️👌https://www.wahcenter.net/exhibits/2003/surreal/BD_artists.html
🇺🇲 http://1995-2015.undo.net/it/mostra/15894 🇬🇧https://en-academic.com/dic.nsf/enwiki/513098 💫https://www.newworldencyclopedia.org/entry/Surrealism And The New International Surrealist Manifesto --By Terrance Lindall https://issuu.com/lindall/docs/surrealist_manifesto_pdf 💥👌👌👌https://vdocuments.site/the-new-international-surrealist-manifesto.html And https://www.epicroadtrips.us/2003/summer/nola/nola_offsite/FQ_en.wikipedia.org/en.wikipedia.org/wiki/Surrealist.html
☠️💥 And Sponsored by the Society for Art of the Imagination. Made possible in part by grants from the New York City Department of Cultural Affairs, Independence Community Foundation and Brooklyn Borough President Marty Markowitz.💥🇺🇲🇬🇧❤️👌 And the identities of World Categories: https://www.worldcat.org/title/brave-destiny-2003/oclc/240386473
दिल से दिल कभी मिला नहीं_ Bewfai ki Dard Bhari Shayari.pdfShayari Dilse
दिल से दिल कभी मिला नहीं_ Bewfai ki Dard Bhari Shayari
Dil se dil kabhi mila nahi,
Pyaara to tha jismaani
Kahne ki bas baatein thi,
Tu mera raja, main teri rani
Powerfull Sad Shayari In hindi
K.Guzik-MLS (2020) ““This is a letter of reference, from personal corresponda...Kyle Guzik
Title: “Kyle Guzik Reference Letter (2020).”
AI-generated summary (please note this summary was created by an AI):
“Pamela Harris Lawton, a professor at Virginia Commonwealth University, highly recommends Kyle Guzik for the MLIS program at the University of Southern Mississippi. Kyle excelled in her Cultural Diversity in Art Education and Society class, earning an A and actively participating. For an assignment, he completed volunteer projects at a dog shelter, retirement home, and trail maintenance. Kyle also provided valuable feedback to undergraduate students during his graduate assistantship. With over five years of experience working with children, 2000+ hours of volunteer service, and a keen interest in discourse analysis, Kyle is well-prepared for a career as a youth services librarian.
From Pamela Harris Lawton.”
XL Multimedia and Institute presentationinstitutexl
XL Multimedia has more than 15 years of experience in the field of Media and Entertainment. XL Multimedia is Asia’s head most leading brand in the field of Animation and Film Making.
Kailash Shankar's graphic design portfolio, showcasing his expansive and versatile body of work and chronological work-history timeline in the creative field.
1. S.ANUSUYA, Assistant Professor in BCA, Sri Vasavi College, SFW , Erode anuciaa@gmail.com - C++ I Word
S.ANUSUYA, Assistant Professor in BCA, Sri Vasavi College, SFW , Erode anuciaa@gmail.com - C++ I Word
SRI VASAVI COLLEGE, SFW, ERODE
C++ MCQ with ANSWERS
Oops (40), C++ Fundamentals(30), Constants & Data types(30), Decision
Making (20), Operators, Functions(20), Arrays(30), Structures(10) &
Strings, Pointer(20), File(30)
Prepare by
Ms. S.ANUSUYA, MCA., M.Phil.,
ASSISTANT Professor in BCA,
Sri Vasavi College(SFW), Erode
anuciaa@gmail.com
OOPS CONCEPTS
1. Wrapping data and its related functionality into a single entity is known as _____________
a) Abstraction b) Encapsulation c) Polymorphism d) Modularity
2. How structures and classes in C++ differ?
a) In Structures, members are public by default whereas, in Classes, they are private by default
b) In Structures, members are private by default whereas, in Classes, they are public by default
c) Structures by default hide every member whereas classes do not
d) Structures cannot have private members whereas classes can have
3. What does polymorphism in OOPs mean?
a) Concept of allowing overiding of functions b) Concept of hiding data
c) Concept of keeping things in differnt modules/files
d) Concept of wrapping things into a single unit
4. Which concept allows you to reuse the written code?
a) Encapsulation b) Abstraction c) Inheritance d) Polymorphism
5. Which of the following explains Polymorphism?
a) int func(int, int); float func1(float, float); b) int func(int); int func(int);
c) int func(float); float func(int, int, char); d) int func(); int new_func();
6. Which of the following shows multiple inheritances?
a) A->B->C b) A->B; A->C c) A,B->C d) B->A
7. How access specifiers in Class helps in Abstraction?
a) They does not helps in any way
b) They allows us to show only required things to outer world
c) They help in keeping things together d) Abstraction concept is not used in classes
2. S.ANUSUYA, Assistant Professor in BCA, Sri Vasavi College, SFW , Erode anuciaa@gmail.com - C++ I Word
S.ANUSUYA, Assistant Professor in BCA, Sri Vasavi College, SFW , Erode anuciaa@gmail.com - C++ I Word
8. C++ is ______________
a) procedural programming language b) object oriented programming language
c) functional programming language
d) both procedural and object oriented programming language
9. What does modularity mean?
a) Hiding part of program b) Subdividing program into small independent parts
c) Overriding parts of program d) Wrapping things into single unit
10. Which of the following feature of OOPs is not used in the following C++ code?
class A{
int i;
public:
void print() {cout << "hello" << i;}
}
class B : public A{
int j;
public:
void assign (int a ) {k = a;}
}
a) Abstraction b) Encapsulation c) Inheritance d) Polymorphism
11. Which of the following class allows to declare only one object of it?
a) Abstract class b) Virtual class c) Singleton class d) Friend class
12. Which of the following is not a type of Constructor?
a) Friend constructor b) Copy constructor
c) Default constructor d) Parameterized constructor
13. Which of the following is correct?
a) Base class pointer object cannot point to a derived class object
b) Derived class pointer object cannot point to a base class object
c) A derived class cannot have pointer objects
d) A base class cannot have pointer objects
14. Out of the following, which is not a member of the class?
a) Static function b) Friend function c) Constant function d) Virtual function
15. What is the other name used for functions inside a class?
a) Member variables b) Member functions c) Class functions d) Class variables
16. Which of the following cannot be a friend?
a) Function b) Class c) Object d) Operator function
17. Why references are different from pointers?
a) A reference cannot be made null b) A reference cannot be changed once initialized
c) No extra operator is needed for dereferencing of a reference d) All of the mentioned
3. S.ANUSUYA, Assistant Professor in BCA, Sri Vasavi College, SFW , Erode anuciaa@gmail.com - C++ I Word
S.ANUSUYA, Assistant Professor in BCA, Sri Vasavi College, SFW , Erode anuciaa@gmail.com - C++ I Word
18. Which of the following provides a programmer with the facility of using object of a class inside
other classes? a) Inheritance b) Composition c) Abstraction d) Encapsulation
19. How many types of polymorphism are there in C++?
a) 1 b) 2 c) 3 d) 4
20. How run-time polymorphisms are implemented in C++?
a) Using Inheritance b) Using Virtual functions
c) Using Templates d) Using Inheritance and Virtual functions
21. How compile-time polymorphisms are implemented in C++?
a) Using Inheritance b) Using Virtual functions
c) Using Templates d) Using Inheritance and Virtual functions
22. Which of the following is an abstract data type?
a) int b) float c) class d) string
23. Which concept means the addition of new components to a program as it runs?
a) Data hiding b) Dynamic binding c) Dynamic loading d) Dynamic typing
24. Which of the following explains the overloading of functions?
a) Virtual polymorphism b) Transient polymorphism
c) Ad-hoc polymorphism d) Pseudo polymorphism
25. Which of the following approach is used by C++?
a) Top-down b) Bottom-up c) Left-right d) Right-left
26. Which operator is overloaded for a cout object?
a) >> b) << c) < d) >
27. Which of the following cannot be used with the virtual keyword?
a) Class b) Member functions c) Constructors d) Destructors
28. Which concept is used to implement late binding?
a) Virtual functions b) Operator functions
c) Constant functions d) Static functions
29. Which of the following is correct?
a) C++ allows static type checking b) C++ allows dynamic type checking.
c) C++ allows static member function to be of type const.
d) C++ allows both static and dynamic type checking
30. Which of the following supports the concept that reusability is a desirable feature of a language?
a) It reduces the testing time b) It reduces maintenance cost
c) It decreases the compilation time d) It reduced both testing and maintenance time
31. Which of the following is a static polymorphism mechanism?
4. S.ANUSUYA, Assistant Professor in BCA, Sri Vasavi College, SFW , Erode anuciaa@gmail.com - C++ I Word
S.ANUSUYA, Assistant Professor in BCA, Sri Vasavi College, SFW , Erode anuciaa@gmail.com - C++ I Word
a) Function overloading b) Operator overloading
c) Templates d) All of the mentioned
32. Which of the following is true?
I) All operators in C++ can be overloaded. II) The basic meaning of an operator can be changed.
a) I only b) II only c) Both I and II d) Neither I nor II
33. Which of the following is not a type of inheritance?
a) Multiple b) Multilevel c) Distributive d) Hierarchical
34. What happens if a class does not have a name?
a) It will not have a constructor b) It will not have a destructor
c) It is not allowed d) It will neither have a constructor or destructor
35. Which of the following statement is true?
I) In Procedural programming languages, all function calls are resolved at compile-time
II) In Object Oriented programming languages, all function calls are resolved at compile-time
a) I only b) II only c) Both I and II d) Neither I nor II
36. Which members are inherited but are not accessible in any case?
a) Private b) Public c) Protected d) Both private and protected
37. Which of the following is correct?
a) Friend functions can access public members of a class
b) Friend functions can access protected members of a class
c) Friend functions can access private members of a class d) All of the mentioned
38. Which of the following is correct in C++?
a) Classes cannot have protected data members b) Structures can have member functions
c) Class members are public by default d) Structure members are private by default
39. Which of the following is used to make an abstract class?
a) By using virtual keyword in front of a class declaration
b) By using an abstract keyword in front of a class declaration
c) By declaring a virtual function in a class d) By declaring a pure virtual function in a class
40. Which of the following is correct?
a) A class is an instance of its objects b) An object is an instance of its class
c) A class is an instance of the data type that the class have
d) An object is an instance of the data type of the class
Fundamentals
1. Who created C++?
a) Bjarne Stroustrup b) Dennis Ritchie c) Ken Thompson d) Brian Kernighan
2. C++ Language developed at _________?
a) AT & T's Bell Laboratories of USA in 1972 b) Sun Microsystems in 1973
c) Cambridge University in 1972 d) AT & T's Bell Laboratories of USA in 1979
3. Which one of the following is a keyword?
5. S.ANUSUYA, Assistant Professor in BCA, Sri Vasavi College, SFW , Erode anuciaa@gmail.com - C++ I Word
S.ANUSUYA, Assistant Professor in BCA, Sri Vasavi College, SFW , Erode anuciaa@gmail.com - C++ I Word
a) Size b) Key c) Jump d) Switch
4. ____ is the smallest individual unit in a program.
a) Variable b) Control c) Character d) Token
5. Which of the following is the correct syntax of including a user defined header files in C++?
a) #include <userdefined.h> b) #include <userdefined>
c) #include “userdefined” d) #include [userdefined]
6. Which of the following is a correct identifier in C++?
a) 7var_name b) 7VARNAME c) VAR_1234 d) $var_name
7. Which of the following is called address operator?
a) * b) & c) _ d) %
8. C++ is _______ type of programming language.?
a) Object Oriented b) Procedural c) Bit level language d) Functional
9. Which of the following is used for comments in C++?
a) // comment b) /* comment */ c) both // comment or /* comment */ d) // comment */
10. What are the actual parameters in C++?
a) Parameters with which functions are called
b) Parameters which are used in the definition of a function
c) Variables other than passed parameters in a function
d) Variables that are never used in the function
11. What are the formal parameters in C++?
a) Parameters with which functions are called
b) Parameters which are used in the definition of the function
c) Variables other than passed parameters in a function
d) Variables that are never used in the function
12. Which function is used to read a single character from the console in C++?
a) cin.get(ch) b) getline(ch) c) read(ch) d) scanf(ch)
13. Which function is used to write a single character to console in C++?
a) cout.put(ch) b) cout.putline(ch) c) write(ch) d) printf(ch)
14. What is a constant that contains a single character enclosed within single quotes?
a) Numeric b) Fixed c) Character d) Floating Point
15. A C++ code line ends with ___
a) A Semicolon (;) b) A Fullstop(.) c) A Comma (,) d) A Slash (/)
16. What are the escape sequences?
a) Set of characters that convey special meaning in a program
b) Set of characters that whose use are avoided in C++ programs
6. S.ANUSUYA, Assistant Professor in BCA, Sri Vasavi College, SFW , Erode anuciaa@gmail.com - C++ I Word
S.ANUSUYA, Assistant Professor in BCA, Sri Vasavi College, SFW , Erode anuciaa@gmail.com - C++ I Word
c) Set of characters that are used in the name of the main function of the program
d) Set of characters that are avoided in cout statements
17. Which of the following escape sequence represents carriage return?
a) r b) n c) nr d) c
18. Which of the following escape sequence represents tab?
a) t b) tr c) b d) a
19. Which of the following is called insertion/put to operator?
a) >> b) << c) > d) <
20. Which of the following is called extraction/get from operator?
a) << b) >> c) > d) <
21. A language which has the capability to generate new data types are called ________________
a) Extensible b) Overloaded c) Encapsulated d) Reprehensible
22. Which of the following is not a fundamental type is not present in C but present in C++?
a) int b) float c) bool d) void
23. What is the size of a boolean variable in C++?
a) 1 bit b) 1 byte c) 4 bytes d) 2 bytes
24. Which of the following is C++ equivalent for scanf()?
a) cin b) cout c) print d) input
25. Which of the following is C++ equivalent for printf()?
a) cin b) cout c) print d) input
26. Which of the following is an exit-controlled loop?
a) for b) while c) do-while d) all of the mentioned
27. Which of the following is the correct difference between cin and scanf()?
a) both are the same b) cin is a stream object whereas scanf() is a function
c) scanf() is a stream object whereas cin is a function
d) cin is used for printing whereas scanf() is used for reading input
28. Which of the following is an entry-controlled loop?
a) for b) while c) do-while d) both while and for
29.In which part of the for loop termination condition is checked?
for(I;II;III) a) I b) II c) III d) IV
30. Which of the following is the scope resolution operator?
a) . b) * c) :: d) ~
Constants & Data Types
1. The constants are also called as
7. S.ANUSUYA, Assistant Professor in BCA, Sri Vasavi College, SFW , Erode anuciaa@gmail.com - C++ I Word
S.ANUSUYA, Assistant Professor in BCA, Sri Vasavi College, SFW , Erode anuciaa@gmail.com - C++ I Word
a) Const b) preprocessor c) literals d) none of these
2. What are the parts of the literal constants?
a) integer numerals b) floating-point numerals
c) strings and boolean values d) all of the mentioned
3. What is the size of wchar_t in C++?
a) 2 b) 4 c) 2 or 4 d) Based on the number of bits in the system
4. Pick the odd one out.
a) array type b) character type c) boolean type d) integer type
5. Which data type is used to represent the absence of parameters?
a) int b) short c) void d) float
6. What does ‘a’ escape code represent?
a) alert b) backslash c) tab d) form feed
7. How the constants are declared?
a) const keyword b) #define preprocessor c) both a and b d) None of these
8. Which type is best suited to represent the logical values?
a) integer b) Boolean c) character d) float
9. Identify the user-defined types from the following?
a) enumeration b) classes c) both enumeration and classes d) int
10. Which of the following statements are true?
int f (float)
a) f is a function taking an argument of type int and returning a floating point number
b) f is a function taking an argument of type float and returning an integer
c) f is a function of type float d) f is a function of type int
11. The value 132.54 can be represented using which data type?
a) double b) void c) int d) bool
12. When a language has the capability to produce new data type mean, it can be called as
a) overloaded b) extensible c) encapsulated d) reprehensible
13. Pick the odd one out.
a) integer, character, boolean, floating b) enumeration, classes
c) integer, enum, void d) arrays, pointer, classes
14. How many characters are specified in the ASCII scheme?
a) 64 b) 128 c) 256 d) 24
15. Given the variables p, q are of char type and r, s, t are of int type. Select the right statement?
1. t = (r * s) / (r + s); 2. t = (p * q) / (r + s);
a) 1 is true but 2 is false b) 1 is false and 2 is true
8. S.ANUSUYA, Assistant Professor in BCA, Sri Vasavi College, SFW , Erode anuciaa@gmail.com - C++ I Word
S.ANUSUYA, Assistant Professor in BCA, Sri Vasavi College, SFW , Erode anuciaa@gmail.com - C++ I Word
c) both 1 and 2 are true d) both 1 and 2 are false
16. Which of the following belongs to the set of character types?
a) char b) wchar_t c) only a d) both wchar_t and char
17. How do we represent a wide character of the form wchar_t?
a) L’a’ b) l’a’ c) L[a] d) la
18. In C++, what is the sign of character data type by default?
a) Signed b) Unsigned
c) Implementation dependent d) Unsigned Implementation
19. Is the size of character literals different in C and C++?
a) Implementation defined b) Can’t say
c) Yes, they are different d) No, they are not different
20. Suppose in a hypothetical machine, the size of char is 32 bits. What would sizeof(char) return?
a) 4 b) 1 c) Implementation dependent d) Machine dependent
21. What constant defined in <climits> header returns the number of bits in a char?
a) CHAR_SIZE b) SIZE_CHAR c) BIT_CHAR d) CHAR_BIT
22. The size_t integer type in C++ is?
a) Unsigned integer of at least 64 bits b) Signed integer of at least 16 bits
c) Unsigned integer of at least 16 bits d) Signed integer of at least 64 bits
23. What will be the output of the following C++ code?
#include <iostream>
using namespace std;
int main() {
int x = -1;
unsigned int y = 2;
if (x > y) {
cout << "x is greater: " ;
}
else
{
cout << "y is greater: " ;
}
return 0;
}
a) x is greater b) y is greater c) implementation defined d) arbitrary
24. Which of these expressions will return true if the input integer v is a power of two?
a) (v | (v + 1)) == 0; b) (~v & (v – 1)) == 0; c) (v | (v – 1)) == 0; d) (v & (v – 1)) == 0;
25. What is the value of the following 8-bit integer after all statements are executed?
1. int x = 1; 2. x = x << 7; 3. x = x >> 7;
a) 1 b) -1 c) 127 d) Implementation defined
9. S.ANUSUYA, Assistant Professor in BCA, Sri Vasavi College, SFW , Erode anuciaa@gmail.com - C++ I Word
S.ANUSUYA, Assistant Professor in BCA, Sri Vasavi College, SFW , Erode anuciaa@gmail.com - C++ I Word
26. Which of these expressions will make the rightmost set bit zero in an input integer x?
a) x = x | (x-1) b) x = x & (x-1) c) x = x | (x+1) d) x = x & (x+2)
27. Which of these expressions will isolate the rightmost set bit?
a) x = x & (~x) b) x = x ^ (~x) c) x = x & (-x) d) x = x ^ (-x)
28. What will be the output of the following C++ code?
#include <iostream>
using namespace std;
int main() {
int x = 8;
cout << "ANDing integer 'x' with 'true' : " << x && true;
return 0;
}
a) ANDing integer ‘x’ with ‘true’ :8 b) ANDing integer ‘x’ with ‘true’ :0
c) ANDing integer ‘x’ with ‘true’ :1 d) ANDing integer ‘x’ with ‘true’ :9
29. 0946, 786427373824, ‘x’ and 0X2f are _____ _____ ____ and _____ literals respectively.
a) decimal, character, octal, hexadecimal b) octal, hexadecimal, character, decimal
c) hexadecimal, octal, decimal, character d) octal, decimal, character, hexadecimal
30. What will be the output of the following C++ code?
#include <iostream>
using namespace std;
int main() {
int i = 3;
int l = i / -2;
int k = i % -2;
cout << l << k ;
return 0;
}
a) compile time error b) -1 1 c) 1 -1 d) implementation defined
Decision making & Loops
1. How many sequences of statements present in C++?
a) 4 b) 3 c) 5 d) 6
2. Decision Control statements in C++ can be implemented using
a) if b) if-else c) Conditional Operator d) All of the above
3. What will be the output of the following C++ code?
#include <iostream>
using namespace std;
int main() {
10. S.ANUSUYA, Assistant Professor in BCA, Sri Vasavi College, SFW , Erode anuciaa@gmail.com - C++ I Word
S.ANUSUYA, Assistant Professor in BCA, Sri Vasavi College, SFW , Erode anuciaa@gmail.com - C++ I Word
if (0) {
cout << "Hello" ;
}
else
{
cout << "Good Bye" ;
}
return 0;
}
a) Hello b) Good Bye c) HelloGood bye d) Compilation Error
4. if you have to make decision based on multiple choices, which of the following is best suited?
a) if b) if-else c) if-else-if d) All of the above
5. Can we use string inside switch statement?
a) Yes b) No
6. In situations where we need to execute body of the loop before testing the condition, we should
use_____. a) For loop b) while loop c) do-while loop d) nested for loop
7. Loops in C++ Language are implemented using?
a) While loop b) For loop c) Do while loop d) All of the above
8. While loop is faster in C++ Language, for, while or do-while?
a) For b) while c) do-while d) All work ate same speed
9. What is the way to suddenly come out of or quit any loop in C++?
a) continue; statement b) break; statement
c) leave; statement d) quit; statement
10. Which of the following can replace a simple if -wlsw construct?
a) Ternary operator b) while loop c) do-while loop d) fop loop
11. The if...else statement can be replaced by which operator?
a) Bitwise operator b) Conditional operator
c) Multiplicative operator d) Addition operator
12. The switch statement is also called as?
a) choosing structure b) selective structure
c) certain structure d) bitwise structure
13. Choose a correct C++ for loop syntax.
a) for(initalization; condition; inc/dec){ // statements };
b) for(declaration; condition; incrementoperation){ // statements };
c) for(declaration; incrementoperation; condition){ // statements };
d) for(initalization; condition; incrementoperation){ // statements };
14. Choose a correct C++ do while syntax.
11. S.ANUSUYA, Assistant Professor in BCA, Sri Vasavi College, SFW , Erode anuciaa@gmail.com - C++ I Word
S.ANUSUYA, Assistant Professor in BCA, Sri Vasavi College, SFW , Erode anuciaa@gmail.com - C++ I Word
a) dowhile(condition){ // statements }; b) do while(condition){ // statements };
c) do{ // statements }while(condition) d) do{ // statements }while(condition);
15. Choose a correct C++ Statement.
a) a++ is (a= a+1) POST INCREMENT operator
b) a-- is (a = a-1) POST DECREMENT operator. --a is (a = a-1) PRE DECREMENT operator
c) ++a is (a = a+1) PRE INCREMENT operator d) All of the above.
16. Which of the following is an entry-controlled loop?
a) For loop b) while loop c) do-while loop d) both b & c
17. Which of the following is an exit-controlled loop?
a) While loop b) For loop c) Do while loop d) both b & c
18. Which of the following is most suitable for a menu-dricen program?
a) For b) while c) do-while d) All of the above
19. Consider the following loop: for(int i = 0; i<5; i++);
a) It will give compilation error. b) 5 c) 6 d) Some Garbage value
20. A switch construct can be used with which of the following types of variable?
a) int b) int, char c) int, float, char d) Any basic datatype
21. The destination statement for the goto label is identified by what label?
a) $ b) @ c) * d) :
22. What will be the output of the following C++ code?
#include <iostream>
using namespace std;
int main() {
int n ;
for (n = 5; n < 0; n--)
{
cout << n;
if (n == 3)
break;
}
return 0;
}
a) 543 b) 54 c) 5432 d) 53
23. What will be the output of the following C++ code?
#include <iostream>
using namespace std;
int main() {
int a = 10;
if (a = 15)
{
time;
12. S.ANUSUYA, Assistant Professor in BCA, Sri Vasavi College, SFW , Erode anuciaa@gmail.com - C++ I Word
S.ANUSUYA, Assistant Professor in BCA, Sri Vasavi College, SFW , Erode anuciaa@gmail.com - C++ I Word
cout << a;
if (n == 3)
goto time;
}
break;
return 0;
}
a) 1010 b) 10 c) infinitely print 10 d) compile time error
24. What will be the output of the following C++ code?
#include <iostream>
using namespace std;
int main() {
int n = 15;
for (; ;)
cout << n;
return 0;
}
a) error b) 15 c) infinite times of printing n d) none of the mentioned
25. Which looping process is best used when the number of iterations is known?
a) While loop b) For loop c) Do while loop
d) all looping processes require that the iterations be known
26. How many types of loops are there in C++?
a) 4 b) 2 c) 3 d) 1
27. What will be the output of the following C++ code?
#include <iostream>
using namespace std;
int main() {
int i ;
for (i = 0; i < 10; i++);
{
cout << i;
}
return 0;
}
a) 0123456789 b) 10 c) 012345678910 d) compile time error
28. Which of the following must be present in switch construct?
a) Expression in ( ) after switch b) default
c) case followed by value d) All of the above
29. What is the effect of writing a break statement inside a loop?
a) It cancels remaining iterations. b) It skips a particular iteration.
c) The program terminates immediately. d) Loop counter is reset.
30. The break statement causes an exit
13. S.ANUSUYA, Assistant Professor in BCA, Sri Vasavi College, SFW , Erode anuciaa@gmail.com - C++ I Word
S.ANUSUYA, Assistant Professor in BCA, Sri Vasavi College, SFW , Erode anuciaa@gmail.com - C++ I Word
a) fromthe innermost loop only. b) only from the innermost switch.
c) from all loops & switches. d) from the innermost loop or switch.
Operators
1. Which operator is having the right to left associativity in the following?
a) Array subscripting b) Function call c) Addition and subtraction d) Type cast
2. What are the essential operators in c++?
a) + b) | c) <= d) All of the mentioned
3. In which direction does the assignment operation will take place?
a) left to right b) right to left c) top to bottom d) bottom to top
4. Pick out the compound assignment statement.
a) a = a – 5 b) a = a / b c) a -= 5 d) a = a + 5
5. What is the associativity of add(+); ?
a) right to left b) left to right c) right to left & left to right d) top to bottom
6. What is the name of | operator?
a) sizeof b) or c) and d) modulus
7. Which operator is having the highest precedence in c++?
a) array subscript b) Scope resolution operator c) static_cast d) dynamic_cast
8. What will be the output of the following C++ code?
#include <iostream>
using namespace std;
int main() {
int a, b;
a = 10;
b = 4;
a = b;
b = 7;
cout << "a: " << a;
cout << "nb: " << b;
return 0;
}
a) a:4 b:7 b) a:10 b:4 c) a:4 b:10 d) a:4 b:6
9. What will be the output of the following C++ code?
#include <iostream>
using namespace std;
int main() {
int a, b, c;
a = 2;
b = 7;
c = (a > b) ? a : b;
14. S.ANUSUYA, Assistant Professor in BCA, Sri Vasavi College, SFW , Erode anuciaa@gmail.com - C++ I Word
S.ANUSUYA, Assistant Professor in BCA, Sri Vasavi College, SFW , Erode anuciaa@gmail.com - C++ I Word
cout << "c: " << c;
return 0;
}
a) 2 b) 7 c) 9 d) 14
10. What will be the output of the following C++ code?
#include <iostream>
using namespace std;
int main() {
int a = 0;
int b = 10;
a = 2;
b = 7;
if (a && b) {
cout << "true: " << endl;
}
else
{
cout << "false: " << endl;
}
return 0;
}
a) true b) false c) error d) 10
11. Which operator is having the highest precedence?
a) postfix b) unary c) shift d) equality
12. What will be the output of the following C++ code?
#include <iostream>
using namespace std;
int main() {
int a;
a = 5 + 3 * 5;
cout << "a: " << a;
return 0;
}
a) 35 b) 20 c) 25 d) 30
13. What will be the output of the following C++ code?
#include <iostream>
using namespace std;
int main() {
int a = 5, b = 6, c, d;
c = a, b;
d = (a ,b);
cout << c << " " << d;
return 0;
15. S.ANUSUYA, Assistant Professor in BCA, Sri Vasavi College, SFW , Erode anuciaa@gmail.com - C++ I Word
S.ANUSUYA, Assistant Professor in BCA, Sri Vasavi College, SFW , Erode anuciaa@gmail.com - C++ I Word
}
6 a) 5 5 b) 6 7 c) 6 8 d) 6
14. What will be the output of the following C++ code?
#include <iostream>
using namespace std;
int main() {
int i, j;
j = 10;
i = (j++, j + 100, 999 + j);
cout << i;
return 0;
}
a) 1000 b) 11 c) 1010 d) 1001
15. What will be the output of the following C++ code?
#include <iostream>
using namespace std;
int main() {
int x, y;
x = 5;
y = ++x * ++x;
cout << x << y;
y = x++ * ++x;
cout << x << y;
return 0;
}
a) 749735 b) 736749 c) 367497 d) 367597
16. What is this operator called "?:" ?
a) condtional b) relational c) casting operator d) unrelational
17. What is the use of dynamic_cast operator?
a) it converts virtual base class to derived class
b) it converts the virtual base object to derived objects
c) it will convert the operator based on precedence
d) it converts the virtual base object to derived class
18. What will be the output of the following C++ code?
#include <iostream>
using namespace std;
int main() {
int a = 5, b = 6, c;
c = (a > b) ? a : b;
cout << c;
return 0;
}
a) 6 b) 5 c) 4 d) 7
16. S.ANUSUYA, Assistant Professor in BCA, Sri Vasavi College, SFW , Erode anuciaa@gmail.com - C++ I Word
S.ANUSUYA, Assistant Professor in BCA, Sri Vasavi College, SFW , Erode anuciaa@gmail.com - C++ I Word
19. What will be the output of the following C++ code?
#include <iostream>
using namespace std;
int main() {
double a = 21.09399;
float b = 10.20;
int c, d;
c = (int) a;
d = (int) b;
cout << c << " " << d;
return 0;
}
10 a) 20 21 b) 10 10 c) 21 20 d) 10
20. What will be the output of the following C++ code?
#include <iostream>
using namespace std;
int main() {
int a = 20, b = 10, c = 15, d = 5;
int e;
e = a + b * c / d;
cout << e << endl;
return 0;
}
a) 50 b) 60 c) 70 d) 90
C++ Functions
1. Where does the execution of the program starts?
a) user-defined function b) main function
c) void function d) else function
2. What are mandatory parts in the function declaration?
a) return type, function name b) return type, function name, parameters
c) parameters, function name d) parameters, variables
3. which of the following is used to terminate the function declaration?
a) : b) ) c) ; d) ]
4. How many can max number of arguments present in function in the c99 compiler?
a) 99 b) 90 c) 102 d) 127
5. Which is more effective while calling the functions?
a) call by value b) call by reference c) call by pointer d) call by object
6. What will be the output of the following C++ code?
#include <iostream>
17. S.ANUSUYA, Assistant Professor in BCA, Sri Vasavi College, SFW , Erode anuciaa@gmail.com - C++ I Word
S.ANUSUYA, Assistant Professor in BCA, Sri Vasavi College, SFW , Erode anuciaa@gmail.com - C++ I Word
using namespace std;
void car{
cout << "Audi R8";
}
int main() {
car();
return 0;
}
a) Audi R8 b) Audi R8Audi R8 c) compile time error d) runtime error
7. What will be the output of the following C++ code?
#include <iostream>
using namespace std;
void fun(int x, int y){
x = 20;
y = 10;
}
int main() {
int x = 10;
fun (x, x);
cout << x;
return 0;
}
a) 10 b) 20 c) compile time error d) 30
8. What happens to a function defined inside a class without any complex operations (like looping, a
large number of lines, etc)?
a) It becomes a virtual function of the class b) It becomes a default calling function of the class
c) It becomes an inline function of the class d) The program gives an error
9. What is the scope of the variable declared in the user defined function?
a) whole program b) only inside the {} block c) the main function d) header section
10. How many minimum number of functions should be present in a C++ program for its execution?
a) 0 b) 1 c) 2 d) 3
11. Which of the following is the default return value of functions in C++?
a) int b) char c) float d) void
12. What is an inline function?
a) A function that is expanded at each call during execution
b) A function that is called during compile time
c) A function that is not checked for syntax errors
d) A function that is not checked for semantic analysis
13. An inline function is expanded during ______________
a) compile-time b) run-time c) never expanded d) end of the program
14. In which of the following cases inline functions may not word?
18. S.ANUSUYA, Assistant Professor in BCA, Sri Vasavi College, SFW , Erode anuciaa@gmail.com - C++ I Word
S.ANUSUYA, Assistant Professor in BCA, Sri Vasavi College, SFW , Erode anuciaa@gmail.com - C++ I Word
i) If the function has static variables. ii) If the function has global and register variables.
iii) If the function contains loops iv) If the function is recursive
a) i, iv b) iii, iv c) ii, iii, iv d) i, iii, iv
15. When we define the default values for a function?
a) When a function is defined b) When a function is declared
c) When the scope of the function is over d) When a function is called
16. Where should default parameters appear in a function prototype?
a) To the rightmost side of the parameter list b) To the leftmost side of the parameter list
c) Anywhere inside the parameter list d) Middle of the parameter list
17. If an argument from the parameter list of a function is defined constant then _______________
a) It can be modified inside the function b) It cannot be modified inside the function
c) Error occurs d) Segmentation fault
18. Which of the following feature is used in function overloading and function with default
argument? a) Encapsulation b) Polymorphism c) Abstraction d) Modularity
19. What will be the output of the following C++ code?
#include <iostream>
using namespace std;
int fun(int x = 0, int y = 0, int z){
return (x + y + z);
}
int main() {
cout << fun(10);
return 0;
}
a) 10 b) 0 c) Error d) Segmentation fault
20. What will be the output of the following C++ code?
#include <iostream>
using namespace std;
int fun(int = 0, int = 0);
int main() {
cout << fun(5);
return 0;
}
int fun(int x, int y){
return (x + y);
}
a) -5 b) 0 c) 10 d) 5
C++ Arrays & Strings
1. Which of the following correctly declares an array?
a) int array[10]; b) int array; c) array{10}; d) array array[10];
19. S.ANUSUYA, Assistant Professor in BCA, Sri Vasavi College, SFW , Erode anuciaa@gmail.com - C++ I Word
S.ANUSUYA, Assistant Professor in BCA, Sri Vasavi College, SFW , Erode anuciaa@gmail.com - C++ I Word
2. What is the index number of the last element of an array with 9 elements?
a) 9 b) 8 c) 0 d) Programmer-defined
3. What is the correct definition of an array?
a) An array is a series of elements of the same type in contiguous memory locations
b) An array is a series of element
c) An array is a series of elements of the same type placed in non-contiguous memory locations
d) An array is an element of the different type
4. Which of the following gives the memory address of the first element in array?
a) array[0]; b) array[1]; c) array(2); d) array;
5. What will be the output of the following C++ code?
#include <iostream>
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;
}
a) 6553 b) 6533 c) 6522 d) 12200
6. Which of the following accesses the seventh element stored in array?
a) array[6]; b) array[7]; c) array(7); d) array;
7. What will be the output of the following C++ code?
#include <iostream>
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;
}
a) 25 b) 26 c) 27 d) 21
8. What will be the output of the following C++ code?
#include <iostream>
20. S.ANUSUYA, Assistant Professor in BCA, Sri Vasavi College, SFW , Erode anuciaa@gmail.com - C++ I Word
S.ANUSUYA, Assistant Professor in BCA, Sri Vasavi College, SFW , Erode anuciaa@gmail.com - C++ I Word
using namespace std;
int main() {
int a = 5, b = 10, c = 15;
int arr[3] = {&a, &b, &c};
cout << *arr[*arr[1] - 0];
return 0;
}
a) 15 b) 18 c) garbage value d) compile time error
9. What will be the output of the following C++ code?
#include <iostream>
using namespace std;
int main() {
char str[5] = "ABC";
cout << str [3];
cout << str;
return 0;
}
a) ABC b) ABCD c) AB d) AC
10. What will be the output of the following C++ code?
#include <iostream>
using namespace std;
int main() {
char array[] = [10, 20, 30];
cout << -2 [array];
return 0;
}
a) -15 b) -30 c) compile time error d) garbage value
11. What is the difference between unsigned int length() and unsigned int size()?
a) Returns a different value b) They are same
c) Returns a different value but they are same d) Returns a length
12. Which header file is used to manipulate the string?
a) iostream b) iomanip c) string d) container
13. How many maximum number of parameters does a string constructor can take?
a) 1 b) 2 c) 3 d) 4
14. Which constant member functions does not modify the string?
a) bool empty() b) assign c) append d) delete
15. What will be the output of the following C++ code?
#include <iostream>
#include <string>
using namespace std;
int main() {
string str {"Steve jobs"};
21. S.ANUSUYA, Assistant Professor in BCA, Sri Vasavi College, SFW , Erode anuciaa@gmail.com - C++ I Word
S.ANUSUYA, Assistant Professor in BCA, Sri Vasavi College, SFW , Erode anuciaa@gmail.com - C++ I Word
cout << str.capacity() << "n";
return 0;
}
a) 9 b) 10 c) 11 d) Not Fix
16. Wht will be the output of the following C++ code?
#include <iostream>
#include <string>
using namespace std;
int main() {
string str {"Steve jobs founded the apple"};
string str {"apple"};
unsigned found = str.find(str2);
if (found != string :: npos)
cout << found << "n";
return 0;
}
a) apple b) 12 c) 23 d) Steve jobs founded the
17. What will be the output of the following C++ code?
#include <iostream>
#include <string>
using namespace std;
int main() {
string str {"Steve jobs"};
unsigned long int found = str.find_first_of("aeiou");
while (found != string :: npos)
{
str[found] = '*';
found = str.find_first_of("aeiou", found + 1);
}
cout << str << "n";
return 0;
}
a) Steve b) jobs c) St*v* j*bs d) St*v*
18. What will be the output of the following C++ code?
#include <iostream>
#include <cstring>
#include <string>
using namespace std;
int main() {
string str {"Steve jobs"};
char * cstr = new char [str.length() + 1];
strcpy (cstr, str.c_str());
char * p = strtok (cstr, " ");
while (p != 0)
{
cout << p << "n";
p = strtok(NULL, " ");
22. S.ANUSUYA, Assistant Professor in BCA, Sri Vasavi College, SFW , Erode anuciaa@gmail.com - C++ I Word
S.ANUSUYA, Assistant Professor in BCA, Sri Vasavi College, SFW , Erode anuciaa@gmail.com - C++ I Word
}
delete[] cstr;
return 0;
}
a) Steve jo b) Steve jobs c) Steve jobs d) Steve jo
19. How many parameters can a resize method take?
a) 1 b) 2 c) 1 or 2 d) 2
20. Which of the following is correct about remove_extent() function?
a) Removes the given dimension from an array
b) Removes the first dimension from the right of the array
c) Removes the first dimension from the left of the array
d) Removes the last dimension from the left of the array
21. Which of the header file is used for array type manipulation?
a) <array> b) <type_traits> c) <iostream> d) std namespace
22. What is the use of is_array() function in C++?
a) To check if a variable is array type or not b) To check if a variable is 1-D array type or not
c) To check if a variable is 2-D array type or not
d) To check if a variable is 1-D or 2-D array type or not
23. What is the use of is_same() function in C++?
a) To check if a variable is array type or not
b) To check whether two variables have the same characteristics
c) To check if two variable is of array type or not
d) To check whether two variables are different or not
24. Which of the following is correct about extent() function?
a) Returns how many elements are in array currently
b) Returns the size of the 1st dimension
c) Returns how many total elements can be stored in an array
d) Returns the size of a given dimension
25. What will be the output of the following C++ code?
#include <iostream>
#include <string>
using namespace std;
int main() {
cout << is_same <int, char> :: value;
cout << is_same <char [10], char [10]> :: value;
cout << is_same <char * [10], string]> :: value;
return 0;
}
a) 011 b) 101 c) 010 d) 110
26. What will be the output of the following C++ code?
23. S.ANUSUYA, Assistant Professor in BCA, Sri Vasavi College, SFW , Erode anuciaa@gmail.com - C++ I Word
S.ANUSUYA, Assistant Professor in BCA, Sri Vasavi College, SFW , Erode anuciaa@gmail.com - C++ I Word
#include <iostream>
#include <string>
using namespace std;
int main() {
cout << rank <int [10]> :: value;
cout << rank <char [10] [10]> :: value;
cout << rank < string [10] [10] [10]> :: value;
return 0;
}
a) 111 b) 123 c) 321 d) 121
27. What will be the output of the following C++ code?
#include <iostream>
#include <string>
using namespace std;
int main() {
cout << is_array <int> :: value;
cout << is_array <char [10]> :: value;
cout << is_array <string]> :: value;
return 0;
}
a) 010 b) 101 c) 001 d) 110
28. What will be the output of the following C++ code?
#include <iostream>
#include <string>
using namespace std;
int main() {
cout << extent < string [10][20][30], 0> :: value;
cout << extent < string [10][20][30], 1> :: value;
cout << extent < string [10][20][30], 2> :: value;
return 0;
}
a) 101010 b) 102030 c) 302010 d) 102010
29. What is the use of rank() function in C++?
a) Returns size of each dimension b) Returns how many total elements can be stored in an array
c) Returns how many elements are in array currently d) Returns the dimension of an array
30. Which of the following is correct about remove_all_extents() function?
a) Removes the all dimension from an array
b) Removes the first dimension from the left of the array
c) Removes the first dimension from the right of the array
d) Removes the last dimension from the left of the array
Structures
1. What will be the output of the following C++ code?
#include <iostream>
24. S.ANUSUYA, Assistant Professor in BCA, Sri Vasavi College, SFW , Erode anuciaa@gmail.com - C++ I Word
S.ANUSUYA, Assistant Professor in BCA, Sri Vasavi College, SFW , Erode anuciaa@gmail.com - C++ I Word
#include <string.h>
using namespace std;
int main() {
int student{
int num;
char name[25];
}
student stu;
stu.num = 123;
strcpy(stu.num, "john");
cout << stu.num << endl;
cout << stu.name << endl;
return 0;
}
a) 123 john b) john john c) compile time error d) runtime error
2. What will be the output of the following C++ code?
#include <iostream>
using namespace std;
struct Time{
int hours, minutes, seconds;
}
int toSeconds(Time now);
int main() {
Time t;
t.hours = 5;
t.minutes = 30;
t.seconds = 45;
cout << "Total seconds: " << toSeconds(t) << endl;
return 0;
}
int toSeconds (Time now){
return 3600 * now.hours + 60 * now.minutes + now.seconds;
}
a) 19845 b) 20000 c) 15000 d) 19844
3. What will happen when the structure is declared?
a) it will not allocate any memory b) it will allocate the memory
c) it will be declared and initialized d) it will be declared
4. The declaration of the structure is also called as?
a) structure creator b) structure signifier
c) structure specifier d) structure creator & signifier
5. The data elements in the structure are also known as what?
a) objects b) members c) data d) objects & data
6. What will be used when terminating a structure?
a) : b) } c) ; d) ;;
25. S.ANUSUYA, Assistant Professor in BCA, Sri Vasavi College, SFW , Erode anuciaa@gmail.com - C++ I Word
S.ANUSUYA, Assistant Professor in BCA, Sri Vasavi College, SFW , Erode anuciaa@gmail.com - C++ I Word
7. What will be the output of the following C++ code?
#include <iostream>
using namespace std;
int main() {
struct ShoeType{
string style;
double price;
};
ShoeType shoe1, shoe2;
shoe1.style = "Adidas";
shoe1.price = 9.99;
cout << shoe1.style << "$" << shoe1.price;
shoe2 = shoe1;
shoe2.price = shoe2.price / 9;
cout << shoe2.style << "$" << shoe2.price;
return 0;
}
a) Adidas $ 9.99Adidas $ 1.11 b) Adidas $ 9.99Adidas $ 9.11
c) Adidas $ 9.99Adidas $ 11.11 d) Adidas $ 11.11Adidas $ 11.11
8. What will be the output of the following C++ code?
#include <iostream>
using namespace std;
struct sec{
int a;
char b;
};
int toSeconds(Time now);
int main() {
struct sec s = {25, 50};
struct sec *ps = (struct sec *) &s;
cout << ps-> a << ps-> b ;
return 0;
}
a) 252 b) 253 c) 254 d) 262
9. Which of the following is a properly defined structure?
a) struct {int a;} b) struct a_struct {int a;}
c) struct a_struct int a; d) struct a_struct {int a;};
10. Which of the following accesses a variable in structure *b?
a) b->var; b) b.var; c) b-var; d) b>var;
C++ Pointers
1. What does the following statement mean?
int (*fp) (char*);
26. S.ANUSUYA, Assistant Professor in BCA, Sri Vasavi College, SFW , Erode anuciaa@gmail.com - C++ I Word
S.ANUSUYA, Assistant Professor in BCA, Sri Vasavi College, SFW , Erode anuciaa@gmail.com - C++ I Word
a) pointer to a pointer b) pointer to an array of chars
c) pointer to function taking a char* argument and returns an int
d) function taking a char* argument and returning a pointer to int
2. The operator used for dereferencing or indirection is ____
a) * b) & c) -> d) –>>
3. Choose the right option.
string* x, y;
a) x is a pointer to a string, y is a string b) y is a pointer to a string, x is a string
c) both x and y are pointers to string types d) y is a pointer to a string
4. Which one of the following is not a possible state for a pointer.
a) hold the address of the specific object b) point one past the end of an object
c) zero d) point to a type
5. Which of the following is illegal?
a) int *ip; b) string s, *sp = 0; c) int i; double* dp = &i; d) int *pi = 0;
6. What will happen in the following C++ code snippet?
int a =100, b =200;
int *p = &a, *q = &b ;
p = q
a) b is assigned to a b) p now points to b c) a is assigned to b d) q now points to a
7. What will be the output of the following C++ code?
#include <iostream>
using namespace std;
int main() {
int a = 5, b = 10, c = 15;
int *arr[] = {&a, &b, &c};
cout << arr[1];
return 0;
}
a) 5 b) 10 c) 15 d) it will return some random number
8. The correct statement for a function that takes pointer to a float, a pointer to a pointer to a char and
returns a pointer to a pointer to a integer is ____________
a) int **fun(float**, char**) b) int *fun(float*, char*)
c) int **fun(float*, char**) d) int ***fun(*float, **char)
9. What will be the output of the following C++ code?
#include <iostream>
using namespace std;
int main() {
char arr[20];
int i;
for (i = 0; i < 10; i++)
*(arr + i) = 65 + i;
*(arr + i) = '0';
27. S.ANUSUYA, Assistant Professor in BCA, Sri Vasavi College, SFW , Erode anuciaa@gmail.com - C++ I Word
S.ANUSUYA, Assistant Professor in BCA, Sri Vasavi College, SFW , Erode anuciaa@gmail.com - C++ I Word
cout << arr;
return 0;
}
a) ABCDEFGHIJ b) AAAAAAAAAA c) JJJJJJJJ d) AAAAAAJJJJ
10. What will be the output of the following C++ code?
#include <iostream>
using namespace std;
int main() {
char *ptr;
char str[] = 'abcdefg';
ptr = str;
ptr += 5;
cout << ptr;
return 0;
}
a) fg b) cdef c) defg d) abcd
11. What is the meaning of the following declaration?
int (*p [5]) ();
a) p is pointer to function b) p is array of pointer to function
c) p is pointer to such function which return type is the array d) p is pointer to array of function
12. What is size of generic pointer in C++ (in 32-bit platform)?
a) 2 b) 4 c) 8 d) 0
13. What will be the output of the following C++ code?
#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) << [1[a]];
return 0;
}
a) 15 18 21 b) 21 21 21 c) 24 24 24 d) Compile time error
14. When does the void pointer can be dereferenced?
a) when it doesn’t point to any value b) when it cast to another type of object
c) using delete keyword d) using shift keyword
15. What will be the output of the following C++ code?
#include <iostream>
using namespace std;
int main() {
int arr[] = {4, 5, 6, 7};
int *p = (arr + 1);
cout << *p;
return 0;
28. S.ANUSUYA, Assistant Professor in BCA, Sri Vasavi College, SFW , Erode anuciaa@gmail.com - C++ I Word
S.ANUSUYA, Assistant Professor in BCA, Sri Vasavi College, SFW , Erode anuciaa@gmail.com - C++ I Word
}
a) 4 b) 5 c) 6 d) 7
16. What will happen in the following C++ code snippet?
#include <iostream>
using namespace std;
int main() {
int arr[] = {4, 5, 6, 7};
int *p = (arr + 1);
cout << arr;
return 0;
}
a) 4 b) 5 c) address of arr d) 7
17. What will be the output of the following C++ code?
#include <iostream>
using namespace std;
int main() {
int numbers[5];
int *p;
p = numbers; *p = 10;
p++; *p = 20;
p = numbers[2]; *p = 30;
p = numbers + 3; *p = 40;
p = numbers; *(p + 4) = 50;
for (int n = 0; n < 5; n++){
cout << numbers[n] << ",";
}
return 0;
}
a) 10,20,30,40,50, b) 1020304050 c) compile error d) runtime error
18. What will be the output of the following C++ code?
#include <iostream>
using namespace std;
int main() {
int arr[] = {4, 5, 6, 7};
int *p = (arr + 1);
cout << *arr + 9;
return 0;
}
a) 12 b) 5 c) 13 d) error
19. What will be the output of the following C++ code?
#include <iostream>
using namespace std;
int main() {
int i;
const char *arr[] = {"c", "c++", "java", "VBA"};
29. S.ANUSUYA, Assistant Professor in BCA, Sri Vasavi College, SFW , Erode anuciaa@gmail.com - C++ I Word
S.ANUSUYA, Assistant Professor in BCA, Sri Vasavi College, SFW , Erode anuciaa@gmail.com - C++ I Word
const char *(*ptr)[4] = &arr;
cout << ++(*ptr)[2];
return 0;
}
a) ava b) java c) c++ d) compile time error
20. The void pointer can point to which type of objects?
a) int b) float c) double d) all of the mentioned
C++ File Management
1. Which header file is required to use file I/O operations?
a) <ifstream> b) <ostream> c) <fstream> d) <iostream>
2. Which stream class is to only write on files?
a) ofstream b) ifstream c) iostream d) fstream
3. Which of the following is used to create an output stream?
a) ofstream b) ifstream c) iostream d) fstream
4. Which of the following is used to create a stream that performs both input and output operations?
a) ofstream b) ifstream c) iostream d) fstream
5. Which of the following is not used as a file opening mode?
a) ios::trunk b) ios::binary c) ios::in d) ios::ate
6. Which of the following statements are correct?
1) It is not possible to combine two or more file opening mode in open() method.
2) It is possible to combine two or more file opening mode in open() method.
3) ios::in and ios::out are input and output file opening mode respectively.
a) 1, 3 b) 2, 3 c) 3 only d) 1, 2
7. By default, all the files in C++ are opened in _________ mode.
a) Text b) Binary c) ISCII d) VTC
8. What is the use of ios::trunc mode?
a) To open a file in input mode b) To open a file in output mode
c) To truncate an existing file to half d) To truncate an existing file to zero
9. Which of the following is the default mode of the opening using the ofstream class?
a) ios::in b) ios::out c) ios::app d) ios::trunc
10. What is the return type open() method?
a) int b) char c) bool d) float
11. Which of the following is not used to seek file pointer?
a) ios::set b) ios::end c) ios::cur d) ios::beg
30. S.ANUSUYA, Assistant Professor in BCA, Sri Vasavi College, SFW , Erode anuciaa@gmail.com - C++ I Word
S.ANUSUYA, Assistant Professor in BCA, Sri Vasavi College, SFW , Erode anuciaa@gmail.com - C++ I Word
12. Which of the following is the default mode of the opening using the ifstream class?
a) ios::in b) ios::out c) ios::app d) ios::trunc
13. Which of the following is the default mode of the opening using the fstream class?
a) ios::in b) ios::out c) ios::in|ios::out d) ios::trunc
14. Which function is used in C++ to get the current position of file pointer in a file?
a) tell_p() b) get_pos() c) get_p() d) tell_pos()
15. Which function is used to reposition the file pointer?
a) moveg() b) seekg() c) changep() d) go_p()
16. Which of the following is used to move the file pointer to start of a file?
a) ios::beg b) ios::start c) ios::cur d) ios::first
17. It is not possible to combine two or more file opening mode in open () method.
a) True b) False c) May be d) None of these
18. Which of these is the correct statement about eof() ?
a) Returns true if a file open for reading has reached the next character.
b) Returns true if a file open for reading has reached the next word.
c) Returns true if a file open for reading has reached the end.
d) Returns true if a file open for reading has reached the middle.
19. Which of the following true about FILE *fp
a) FILE is a structure and fp is a pointer to the structure of FILE type
b) FILE is a buffered stream c) FILE is a stream
d) FILE is a keyword in C for representing files and fp is a variable of FILE type
20. Which of the following methods can be used to open a file in file handling?
a) Using Open ( ) b) Constructor method c) Destructor method d) Both A and B
21. Which operator is used to insert the data into file?
a) >> b) << c) < d) None of the above
22. Which is correct syntax?
a) myfile:open ("example.bin", ios::out); b) myfile.open ("example.bin", ios::out);
c) myfile::open ("example.bin", ios::out); d) myfile.open ("example.bin", ios:out);
23. In fopen(), the open mode "wx" is sometimes preferred "w" because. i) Use of wx is more
efficient. ii) If w is used, old contents of file are erased and a new empty file is created. When wx is
used, fopen() returns NULL if file already exists.
a) Only I b) Only ii c) Both i & ii d) None of the above
24. ios::trunc is used for ?
a) If the file is opened for output operations and it already existed, no action is taken.
b) If the file is opened for output operations and it already existed, then a new copy is created.
c) None of the above
31. S.ANUSUYA, Assistant Professor in BCA, Sri Vasavi College, SFW , Erode anuciaa@gmail.com - C++ I Word
S.ANUSUYA, Assistant Professor in BCA, Sri Vasavi College, SFW , Erode anuciaa@gmail.com - C++ I Word
d) If the file is opened for output operations and it already existed, its previous content is deleted
and replaced by the new one.
25. Which member function is used to determine whether the stream object is currently associated
with a file? a) is_open b) Buf c) String d) None of the above
26. getc() returns EOF when
a) End of files is reached b) When getc() fails to read a character
c) Both A & B d) None of the above
27. Which of the following is not a file opening mode ____ .
a) ios::ate b) ios::nocreate c) ios::noreplace d) ios::truncate
28. Due to ios::trunc mode, the file is truncated to zero length.
a) True b) False
29. If we have object from fstream class, then what is the default mode of opening the file?
a) ios::in|ios::out b) ios::in|ios::out|ios::trunk
c) ios::in|ios::trunk d) Default mode depends on compiler
30. What is the output of this program?
#include <iostream>
#include <string>
using namespace std;
int main() {
char fine, course;
cout << "Enter a word: ";
fine = cin.get();
cin.sync();
course = cin.get();
cout << fine << endl;
cout << course << endl;
return 0;
}
a) course b) fine c) None of the mentioned
d) Returns fine 2 letter or number from the entered word