click below
click below
Normal Size Small Size show me how
FA7 8 ComProg
| Question | Answer |
|---|---|
| File mode that opens a text in reading mode Group of answer choices a r q w | r |
| Writes a set of data to a file Group of answer choices fclose() fopen() fprintf() *fp | fprintf() |
| What is the correct syntax for declaring a file pointer? Group of answer choices *FILE *fp; FILE *fp; file *fp; File *fp; | FILE *fp; |
| What is the correct syntax for fclose()? Group of answer choices fclose(“fp”); FCLOSE(fp); fclose(fp); Fclose(fp); | fclose(fp); |
| What does the following code do? while( (ch = getchar()) != '\n') { putc(ch, fp); } Gets a character, put it into a file pointer until an enter is pressed Puts character into a variable Gets a character until enter key is pressed | Gets a character, put it into a file pointer until an enter is pressed |
| Refers to the name of the file Group of answer choices file attribute file extension File pointer Filename | Filename |
| An operation where in data is added to the existing data of file Group of answer choices Create Append Close Delete | append |
| It points to a structure that contains about the file: Group of answer choices Extension name File pointer File type File name | File pointer |
| EOF means ______________________________ Group of answer choices End of function End of file End of format End of float | End of file |
| Which header file is required to use file I/O operations? Group of answer choices <ifstream> <fstream> <ostream> <iostream> | fstream |
| Which operator is used to insert the data into the file? Group of answer choices << > >> < | >> |
| The ifstream would be used when: Group of answer choices removing a file creating a file reading a file appending a file | reading a file |
| It represents a sequence of bytes on the disk where a group of related data is stored. Group of answer choices File Parameter Array Variable | file |
| Which of the following is used to create a stream that performs both input and output operations? Group of answer choices fstream ifstream iostream ofstream | fstream |
| What can be used to input a string with blank space? Group of answer choices getline inline sideline putline | getline |
| What is meant by ofstream in c++? Group of answer choices Delete file Reads from a file Writes to a file Both read and write file | Writes to a file |
| What is the return type open() method? Group of answer choices bool int char double | bool |
| Which of the following header file is required for creating and reading files? Group of answer choices ofstream fstream ifstream stream | fstream |
| What is the output of the given program? #include < iostream > using namespace std; int main () { char str[] = "Steve jobs int val = 65; char ch = 'A'; cout << val << endl; return 0; } a Error 65 65 A | error |
| If there is a class named Student and you want to create an object name "firstyear", what would be the correct syntax Group of answer choices student firstyear() student firstyear Student firstyear student first year; | Student firstyear |
| Which concept of OOP is false for C++? Group of answer choices At least one object should be declared in code Code must contain at least one class A class must have member functions Code can be written without using classes | Code must contain at least one class |
| What is the difference between struct and class in C++? All members of a structure are public and structures don't have constructors and destructors Members of a class are private by default and members of struct are public by default. | Members of a class are private by default and members of struct are public by default. |
| Which of the following has a correct C++ class definition? Group of answer choices class Student; class Student () class Student {}: class Student {}; | class Student {}; |
| Pick out the other definition of objects. Group of answer choices member of the class attribute of the class instance of the class associate of the class | instance of the class |
| Which is not a feature of OOP in general definitions? Group of answer choices Duplicate/Redundant Data Efficient code Modularity Code reusability | Duplicate/Redundant Data |
| How many classes can be defined in a single program? Group of answer choices Only 100 Only 1 Only 999 As many as you want | As many as you want |
| Which of the following concepts of OOPS means exposing only necessary information to the client? Group of answer choices Data binding Abstraction Encapsulation Data hiding | Encapsulation |
| Which of the following are available only in the class hierarchy chain? Group of answer choices Public data members Member functions Private data members Protected data members | Protected data members |
| Which of the following statements is correct in C++? Classes cannot have data as protected members. Structure members are private by default Structures can have functions as members Class members are public by default. | Structures can have functions as members |
| If a class is named Car and you will create an object named SportsCar, what would be the statement? Group of answer choices Car SportsCar; Car (SportsCar); Car<SportsCar>; SportsCar Car; | Car SportsCar; |
| Which of the following is an abstract data type? Group of answer choices Int Class string double | Class |
| The default access specifier for the class members is: Group of answer choices public none of the given protected Private/ | private |
| Which of the following concepts means wrapping up of data and functions together? Group of answer choices Inheritance Object Abstraction Encapsulation | encapsulation |
| Which of the following operator is used for cout? Group of answer choices + >> << = | << |
| Which of the following term is used for a function defined inside a class? Group of answer choices Member Variable Member function Class function Classic function | member function |
| If an object named Box has a member of length, what is the command to assign a value of 5 into it? Group of answer choices Box.length = 5; Box(5) Length = 5; Box.length == 5; | Box.length = 5; |
| Which of the following is correct about class and structure? class data members are public by default while that of structure are private. class data members are private by default while that of structure are public by default. | class data members are private by default while that of structure are public by default. |
| What is the output of this program? class Test { int x; }; int main() { Test t; cout << t.x; return 0; } Group of answer choices Error// -1 0 Garbage value | error |
| What symbol is used to define a function outside of the class? Group of answer choices <> : & :: | :: |
| If an object named Apple has a member named "price", what is the command to assign a value of 15 into it? Group of answer choices Price(15); Apple.price == 15; Apple(15); Apple.price = 15; | Apple.price = 15; |
| What is the difference between a struct and a class in C++? A struct cannot have member functions A struct cannot have private members. A class has a default privacy specification of private A class has a default privacy specification of public. | A class has a default privacy specification of private |
| Which of the following are available only in the class hierarchy chain? Group of answer choices Member functions Protected data members Private data members Public data members | Protected data members |
| A Function that has its definition or its prototype within the class definition like any other variable. Group of answer choices Objects Class Data Member Member Functions | member functions |
| What operator is used to access a data member or a member function? Group of answer choices & operator dot (.) operator + operator == operator | dot (.) operator |
| What is the output of the given program? #include <iostream> using namespace std; class Test { int x; }; int main() { Test t; cout << t.x; return 0; } Group of answer choices Garbage value 1 0 Error | error |
| Which of the following is an OOP language? Group of answer choices HTML C C++ BASIC | C++ |
| Pick out the other definition of objects. Group of answer choices instance of the class member of the class attribute of the class associate of the class | attribute of the class |
| Objects created are based on what? Group of answer choices abstract Class behavior attributes | class |
| What is the additional feature in classes that were not in structures? Group of answer choices Public access specifier Data members Static data allowed Member Functions | member functions |
| What is the output of the given program? #include<iostream> using namespace std; main() { class student { int rno = 10; } v; cout<<v.rno; } Group of answer choices Garbage value Error 10 0 | error |
| What is the difference between struct and class in C++? Members of a class are private by default and members of struct are public by default. All members of a structure are public and structures don't have constructors and destructors | Members of a class are private by default and members of struct are public by default. |
| A behavior an object Group of answer choices Abstract Property Method class | method |
| Refers to binding together the data and the functions that manipulate them Group of answer choices Class Abstraction Encapsulation Objects | encapsulation |
| File mode that opens or create a text file in writing mode Group of answer choices r w a x | w |
| It is created for the permanent storage of data. Group of answer choices List Constant File Variable | file |
| Writes a character to a file: Group of answer choices fclose() fopen() puc() getc() | fopen() |
| Reads a character from a file: Group of answer choices getc() puc() fclose() fopen() | getc() |
| What is correct syntax for fopen()? Group of answer choices fp = fopen(“one.txt”, w); fp = fopen("one.txt", "w"); fp = fopen(one.txt, w); fp = fopen(one.txt, "w"); | fp = fopen("one.txt", "w"); |
| By default, all the files in C++ are opened in _________ mode. Group of answer choices ASCII Text Octal Binary | text |
| What is the output of the given program? #include < iostream > using namespace std; int main () { char str[] = "Steve jobs"; int val = 65; char ch = 'A'; cout << val << endl; return 0; } Group of answer choices a Error 65 A 65 | 65 |
| When will the cin can start processing of input? Group of answer choices Delete file By pressing backspace Both read and write file After pressing return key | After pressing return key |