TRE4 C and C++ Quiz practice set 3

Que: (1). Which language is better for writing structured code?

Asked in BPSC TRE 1.0
C.
B.
A.
D.
E.
Open question page

Que: (2). Which of the following is primarily a procedural programming language that supports structured programming?

C.
A.
B.
D.
E.
Open question page

Que: (3). What is the full form of FORTRAN?

B.
A.
C.
D.
E.
Open question page

Que: (4). Which programming language was specifically designed for business data processing?

B.
A.
C.
D.
E.
Open question page

Que: (5). What is the full form of BASIC?

B.
C.
A.
D.
E.
Open question page

Que: (6). Which of the following is a first-generation programming language?

A.
C.
B.
D.
E.
Open question page

Que: (7). Which type of language uses mnemonic instructions such as MOV, ADD and SUB?

B.
A.
C.
D.
E.
Open question page

Que: (8). Which translator typically translates an entire source program into machine code or another target form before execution?

B.
A.
C.
D.
E.
Open question page

Que: (9). Which language-processing approach generally executes program instructions through interpretation rather than requiring a separate compiled executable?

A.
C.
B.
D.
E.
Open question page

Que: (10). Which of the following is an object-oriented programming language?

B.
A.
C.
D.
E.
Open question page

Que: (11). Which language does a browser use to display information from the World Wide Web?

Asked in BPSC TRE 1.0
A.
B.
C.
D.
E.
Open question page

Que: (12). What is the full form of HTML?

A.
B.
C.
D.
E.
Open question page

Que: (13). Which language is primarily used to style the appearance of web pages?

A.
B.
C.
D.
E.
Open question page

Que: (14). Which programming language is commonly used to add interactivity to web pages in a browser?

C.
A.
B.
D.
E.
Open question page

Que: (15). What is the full form of URL?

B.
A.
C.
D.
E.
Open question page

Que: (16). What is the full form of HTTP?

B.
A.
C.
D.
E.
Open question page

Que: (17). Which of the following is a web browser?

C.
B.
A.
D.
E.
Open question page

Que: (18). What is the primary function of a web server?

C.
A.
B.
D.
E.
Open question page

Que: (19). In web communication, which component typically sends an HTTP request to a web server?

C.
B.
A.
D.
E.
Open question page

Que: (20). Which HTML element is used to create a hyperlink?

B.
C.
A.
D.
E.
Open question page

Que: (21). Select the true statement for compiler.

Asked in BPSC TRE 1.0
A.
B.
C.
D.
E.
Open question page

Que: (22). What is the primary function of a compiler?

A.
C.
B.
D.
E.
Open question page

Que: (23). Which translator converts assembly language into machine code?

A.
B.
C.
D.
E.
Open question page

Que: (24). Which statement best describes an interpreter?

A.
B.
C.
D.
E.
Open question page

Que: (25). What is the primary function of a linker?

C.
B.
A.
D.
E.
Open question page

Que: (26). Which system program loads an executable into memory for execution?

C.
B.
A.
D.
E.
Open question page

Que: (27). What is source code?

C.
B.
A.
D.
E.
Open question page

Que: (28). Which statement about object code is correct?

A.
B.
C.
D.
E.
Open question page

Que: (29). Which type of error is commonly detected during compilation?

A.
C.
B.
D.
E.
Open question page

Que: (30). Which of the following are commonly associated with the compilation process?

A.
C.
B.
D.
E.
Open question page

Que: (31). Which of the following is not a valid variable name in most programming languages?

Asked in BPSC TRE 1.0
B.
A.
C.
D.
E.
Open question page

Que: (32). What is an identifier in programming?

A.
B.
C.
D.
E.
Open question page

Que: (33). Which of the following is a valid variable name in C?

C.
A.
B.
D.
E.
Open question page

Que: (34). Which of the following is a reserved keyword in C?

A.
C.
B.
D.
E.
Open question page

Que: (35). Are variable names case-sensitive in C?

A.
B.
C.
D.
E.
Open question page

Que: (36). Which character can be used at the beginning of a variable name in C?

B.
A.
C.
D.
E.
Open question page

Que: (37). Which of the following is not a valid variable name in C?

C.
B.
A.
D.
E.
Open question page

Que: (38). Which keyword is commonly used to declare a read-only variable in C++?

B.
A.
C.
D.
E.
Open question page

Que: (39). Which of the following is a valid variable name in Python?

C.
A.
B.
D.
E.
Open question page

Que: (40). Which statement about identifiers in C is correct?

B.
C.
A.
D.
E.
Open question page

Que: (41). If a semicolon is not used at the end of a statement, what message will be displayed by C++?

Asked in BPSC TRE 1.0
B.
C.
A.
D.
E.
Open question page

Que: (42). What is the primary purpose of a semicolon in C++?

C.
A.
B.
D.
E.
Open question page

Que: (43). What is the likely result of compiling the following C++ code: int x = 10 cout << x;

C.
B.
A.
D.
E.
Open question page

Que: (44). What does a single semicolon represent in C++?

C.
A.
B.
D.
E.
Open question page

Que: (45). Which symbol normally terminates a simple statement in C++?

A.
B.
C.
D.
E.
Open question page

Que: (46). Which is the correct declaration of an integer variable in C++?

B.
A.
C.
D.
E.
Open question page

Que: (47). Which software detects and reports many syntax errors in C++ source code?

B.
C.
A.
D.
E.
Open question page

Que: (48). Which symbols are used to enclose a block of statements in C++?

A.
C.
B.
D.
E.
Open question page

Que: (49). Which is the correct syntax for a basic if statement in C++?

C.
B.
A.
D.
E.
Open question page

Que: (50). Which of the following can cause a syntax error in C++?

B.
C.
A.
D.
E.
Open question page

Que: (51). Which shortcut keys are used to compile and run a program in Turbo C++?

Asked in BPSC TRE 1.0
C.
A.
B.
D.
E.
Open question page

Que: (52). Which shortcut key is used to compile a program in classic Turbo C++?

A.
B.
C.
D.
E.
Open question page

Que: (53). Which shortcut key is used to run a program in classic Turbo C++?

C.
A.
B.
D.
E.
Open question page

Que: (54). Which shortcut key displays the user screen in classic Turbo C++?

A.
C.
B.
D.
E.
Open question page

Que: (55). What is the primary function of a C++ compiler?

B.
A.
C.
D.
E.
Open question page

Que: (56). What happens when a C++ program contains a syntax error?

C.
B.
A.
D.
E.
Open question page

Que: (57). What is the main purpose of debugging a C++ program?

B.
C.
A.
D.
E.
Open question page

Que: (58). What is the full form of IDE in software development?

B.
C.
A.
D.
E.
Open question page

Que: (59). Which of the following is commonly part of building a C++ program?

C.
B.
A.
D.
E.
Open question page

Que: (60). In classic Turbo C++, which shortcut is used to view the output screen after running a program?

A.
B.
C.
D.
E.
Open question page

Que: (61). Which of the following is a user-defined header file extension used in C++?

Asked in BPSC TRE 1.0
B.
C.
A.
D.
E.
Open question page

Que: (62). What is the primary purpose of a header file in C++?

C.
B.
A.
D.
E.
Open question page

Que: (63). Which preprocessor directive is used to include a header file in C++?

B.
A.
C.
D.
E.
Open question page

Que: (64). Which standard C++ header file is commonly used for input and output with cin and cout?

B.
A.
C.
D.
E.
Open question page

Que: (65). Which syntax is commonly used to include a user-defined header file named myheader.h?

B.
A.
C.
D.
E.
Open question page

Que: (66). Which file extension is commonly used for a C++ source file?

B.
C.
A.
D.
E.
Open question page

Que: (67). What is the main purpose of a header guard in C++?

C.
B.
A.
D.
E.
Open question page

Que: (68). Which of the following is a valid C++ preprocessor directive for defining a macro?

B.
A.
C.
D.
E.
Open question page

Que: (69). Which of the following is a common declaration found in a C++ header file?

A.
C.
B.
D.
E.
Open question page

Que: (70). Which statement about C++ header files is correct?

A.
C.
B.
D.
E.
Open question page

Que: (71). What will happen if the following C++ statement is compiled and executed? int *ptr = NULL; delete ptr;

Asked in BPSC TRE 1.0
C.
A.
B.
D.
E.
Open question page

Que: (72). Which operator is used in C++ to dynamically allocate memory for a single object?

B.
C.
A.
D.
E.
Open question page

Que: (73). Which operator is used to release memory allocated for a single object using new in C++?

C.
A.
B.
D.
E.
Open question page

Que: (74). Which operator should be used to release a dynamically allocated array in C++?

C.
B.
A.
D.
E.
Open question page

Que: (75). What can happen if memory allocated using new is never released when it is no longer needed?

C.
B.
A.
D.
E.
Open question page

Que: (76). What is a dangling pointer in C++?

B.
A.
C.
D.
E.
Open question page

Que: (77). What happens if a program dereferences a null pointer in C++?

C.
B.
A.
D.
E.
Open question page

Que: (78). Which statement correctly allocates an array of 10 integers dynamically in C++?

C.
B.
A.
D.
E.
Open question page

Que: (79). What is the result of deleting the same dynamically allocated pointer twice?

A.
C.
B.
D.
E.
Open question page

Que: (80). Which statement correctly describes the difference between new and malloc in C++?

B.
A.
C.
D.
E.
Open question page

Que: (81). Which of the following correctly declares an array in C++?

Asked in BPSC TRE 1.0
C.
B.
A.
D.
E.
Open question page

Que: (82). What is the index of the first element in a C++ array?

C.
A.
B.
D.
E.
Open question page

Que: (83). Which statement correctly initializes an integer array with three elements in C++?

B.
A.
C.
D.
E.
Open question page

Que: (84). What is the output of the following C++ code? int a[4] = {2, 4, 6, 8}; cout << a[2];

B.
C.
A.
D.
E.
Open question page

Que: (85). What happens to the remaining elements when an integer array is partially initialized using a brace-enclosed initializer?

B.
C.
A.
D.
E.
Open question page

Que: (86). Which expression accesses the third element of an array named arr in C++?

B.
A.
C.
D.
E.
Open question page

Que: (87). Which of the following is a valid declaration of a character array in C++?

C.
A.
B.
D.
E.
Open question page

Que: (88). What is the last valid index of an array declared as int nums[8]; in C++?

C.
B.
A.
D.
E.
Open question page

Que: (89). Which statement correctly describes a fixed-size built-in array in C++?

A.
B.
C.
D.
E.
Open question page

Que: (90). What is the output of the following C++ code? int a[3] = {5, 10, 15}; cout << a[0] + a[2];

A.
B.
C.
D.
E.
Open question page

Que: (91). What will be the output of the given C++ code that attempts to concatenate character arrays using the + operator?

Asked in BPSC TRE 1.0
                            #include <iostream>
#include <string>
using namespace std;
int main() {
    char s1[6] = "Hello";
    char s2[6] = "World";
    char s3[12] = s1 + " " + s2;
    cout << s3;
    return 0;
}
                        
B.
A.
C.
D.
E.
Open question page

Que: (92). What will be the output of the following C++ code?

                            #include <iostream>
using namespace std;
int main() {
    char s[] = "Hello";
    cout << s;
    return 0;
}
                        
A.
B.
C.
D.
E.
Open question page

Que: (93). What will be the output of the following C++ code?

                            #include <iostream>
#include <cstring>
using namespace std;
int main() {
    char s[] = "HELLO";
    cout << sizeof(s) << " " << strlen(s);
    return 0;
}
                        
C.
A.
B.
D.
E.
Open question page

Que: (94). What will be the output of the following C++ code using std::string?

                            #include <iostream>
#include <string>
using namespace std;
int main() {
    string s1 = "Hello";
    string s2 = "World";
    cout << s1 + " " + s2;
    return 0;
}
                        
C.
A.
B.
D.
E.
Open question page

Que: (95). What will be the output of the following C++ code?

                            #include <iostream>
using namespace std;
int main() {
    char s[] = "CAT";
    s[1] = 'X';
    cout << s;
    return 0;
}
                        
C.
A.
B.
D.
E.
Open question page

Que: (96). What will be the output of the following C++ code using a character pointer?

                            #include <iostream>
using namespace std;
int main() {
    char s[] = "HELLO";
    char *p = s;
    cout << *(p + 2);
    return 0;
}
                        
B.
A.
C.
D.
E.
Open question page

Que: (97). What will be the output of the following C++ code using strcat()?

                            #include <iostream>
#include <cstring>
using namespace std;
int main() {
    char s1[10] = "Hi";
    char s2[] = "All";
    strcat(s1, s2);
    cout << s1;
    return 0;
}
                        
C.
B.
A.
D.
E.
Open question page

Que: (98). What will be the output of the following C++ code using substr()?

                            #include <iostream>
#include <string>
using namespace std;
int main() {
    string s = "COMPUTER";
    cout << s.substr(2, 3);
    return 0;
}
                        
A.
B.
C.
D.
E.
Open question page

Que: (99). What will be the output of the following C++ code using find()?

                            #include <iostream>
#include <string>
using namespace std;
int main() {
    string s = "BPSC TRE";
    cout << s.find("TRE");
    return 0;
}
                        
C.
B.
A.
D.
E.
Open question page

Que: (100). What will be the output of the following C++ code after appending a character sequence?

                            #include <iostream>
#include <string>
using namespace std;
int main() {
    string s = "abc";
    s += "d";
    cout << s.length();
    return 0;
}
                        
B.
A.
C.
D.
E.
Open question page

Que: (101). How do structures and classes in C++ differ?

Asked in BPSC TRE 1.0
B.
C.
A.
D.
E.
Open question page

Que: (102). What will be the output of the following C++ code?

                            #include <iostream>
using namespace std;
struct Student {
    int marks;
};
int main() {
    Student s;
    s.marks = 85;
    cout << s.marks;
    return 0;
}
                        
B.
C.
A.
D.
E.
Open question page

Que: (103). What happens when the following C++ code is compiled?

                            #include <iostream>
using namespace std;
class Student {
    int marks;
};
int main() {
    Student s;
    s.marks = 90;
    cout << s.marks;
    return 0;
}
                        
B.
A.
C.
D.
E.
Open question page

Que: (104). What is the default inheritance access mode for a class in C++ when no access specifier is written?

A.
C.
B.
D.
E.
Open question page

Que: (105). Which statement about constructors in C++ structures and classes is correct?

A.
B.
C.
D.
E.
Open question page

Que: (106). Which statement correctly describes member functions in C++ structures and classes?

B.
A.
C.
D.
E.
Open question page

Que: (107). What will be the output of the following C++ code?

                            #include <iostream>
using namespace std;
struct Data {
private:
    int value = 7;
public:
    int getValue() { return value; }
};
int main() {
    Data d;
    cout << d.getValue();
    return 0;
}
                        
B.
A.
C.
D.
E.
Open question page

Que: (108). Which access specifier controls access so that a member can be used within its class and its derived classes, but not directly from unrelated external code?

C.
B.
A.
D.
E.
Open question page

Que: (109). What will be the output of the following C++ code using default inheritance?

                            #include <iostream>
using namespace std;
class Base {
public:
    int value = 25;
};
struct Derived : Base {};
int main() {
    Derived d;
    cout << d.value;
    return 0;
}
                        
B.
C.
A.
D.
E.
Open question page

Que: (110). What will happen when the following C++ code is compiled?

                            #include <iostream>
using namespace std;
class Base {
public:
    int value = 10;
};
class Derived : Base {};
int main() {
    Derived d;
    cout << d.value;
    return 0;
}
                        
B.
A.
C.
D.
E.
Open question page

Que: (111). What is the use of ios::trunc mode in C++?

Asked in BPSC TRE 1.0
B.
C.
A.
D.
E.
Open question page

Que: (112). Which C++ file mode is used to append data at the end of a file?

A.
B.
C.
D.
E.
Open question page

Que: (113). Which C++ file mode is used to open a file for reading?

C.
B.
A.
D.
E.
Open question page

Que: (114). Which C++ file mode is used to open a file in binary mode?

C.
A.
B.
D.
E.
Open question page

Que: (115). What generally happens when an existing file is opened using ofstream with the default output mode?

                            #include <fstream>
using namespace std;
int main() {
    ofstream file("data.txt");
    file << "Hello";
    file.close();
    return 0;
}
                        
A.
B.
C.
D.
E.
Open question page

Que: (116). Which statement correctly describes ios::ate and ios::app in C++?

C.
A.
B.
D.
E.
Open question page

Que: (117). Which combination opens an existing file for both reading and writing without requesting truncation?

C.
A.
B.
D.
E.
Open question page

Que: (118). What does the following C++ program do to an existing file named data.txt?

                            #include <fstream>
using namespace std;
int main() {
    ofstream file("data.txt", ios::out | ios::trunc);
    file.close();
    return 0;
}
                        
C.
B.
A.
D.
E.
Open question page

Que: (119). What happens when an input file stream attempts to open a nonexistent file using ios::in?

                            #include <fstream>
#include <iostream>
using namespace std;
int main() {
    ifstream file("missing.txt", ios::in);
    cout << file.is_open();
    return 0;
}
                        
C.
B.
A.
D.
E.
Open question page

Que: (120). Which statement about combining C++ file-opening modes is correct?

A.
C.
B.
D.
E.
Open question page

Que: (121). Which of the following statements is/are correct about C++ file opening modes?

Asked in BPSC TRE 1.0
B.
A.
C.
D.
E.
Open question page

Que: (122). Which operator is used to combine two or more C++ file opening modes?

A.
C.
B.
D.
E.
Open question page

Que: (123). Which access is requested by the following C++ statement?

                            fstream file("data.txt", ios::in | ios::out);
                        
C.
A.
B.
D.
E.
Open question page

Que: (124). What happens when an existing file is opened using the following statement?

                            ofstream fout("data.txt");
                        
B.
A.
C.
D.
E.
Open question page

Que: (125). Which file opening mode ensures that output is written at the end of a file?

B.
A.
C.
D.
E.
Open question page

Que: (126). What is the difference between ios::ate and ios::app?

A.
B.
C.
D.
E.
Open question page

Que: (127). What is the likely result of this code if data.txt does not exist?

                            fstream file("data.txt", ios::in | ios::out);
if (file.is_open())
    cout << "Opened";
else
    cout << "Failed";
                        
B.
A.
C.
D.
E.
Open question page

Que: (128). Which statement opens a file for binary output?

B.
C.
A.
D.
E.
Open question page

Que: (129). What does the following C++ code do?

                            ofstream fout("log.txt", ios::out | ios::app);
fout << "New entry";
fout.close();
                        
A.
B.
C.
D.
E.
Open question page

Que: (130). Which file opening mode combination requests both input and output in binary mode?

B.
A.
C.
D.
E.
Open question page

Que: (131). The correct statement for a function that takes a pointer to a float, a pointer to a pointer to a char and returns a pointer to a pointer to an integer is

Asked in BPSC TRE 1.0
C.
A.
B.
D.
E.
Open question page

Que: (132). Which declaration defines a function that accepts a pointer to an integer and returns a pointer to a character?

A.
C.
B.
D.
E.
Open question page

Que: (133). Which declaration represents a function that accepts a pointer to a pointer to int and returns an int?

C.
B.
A.
D.
E.
Open question page

Que: (134). What is the type of p in the following C code?

                            int x = 10;
int *p1 = &x;
int **p = &p1;
                        
C.
A.
B.
D.
E.
Open question page

Que: (135). What value is printed by the following C program?

                            #include <stdio.h>
int main(void)
{
    int x = 25;
    int *p = &x;
    int **q = &p;
    printf("%d", **q);
    return 0;
}
                        
C.
A.
B.
D.
E.
Open question page

Que: (136). Which declaration correctly defines a function that accepts a pointer to float and returns a pointer to pointer to char?

C.
A.
B.
D.
E.
Open question page

Que: (137). Which declaration represents a function accepting a pointer to a function that takes an int and returns an int?

B.
A.
C.
D.
E.
Open question page

Que: (138). What is the output of this C program?

                            #include <stdio.h>
int main(void)
{
    int x = 5;
    int *p = &x;
    int **q = &p;
    **q = 40;
    printf("%d", x);
    return 0;
}
                        
B.
C.
A.
D.
E.
Open question page

Que: (139). Which statement about a function returning a pointer is correct in C?

C.
B.
A.
D.
E.
Open question page

Que: (140). What does the following declaration mean in C?

                            int **get_pointer(void);
                        
A.
B.
C.
D.
E.
Open question page

Que: (141). What will be the output of the following C++ code?

Asked in BPSC TRE 1.0
                            #include <iostream>
using namespace std;
long factorial(long a)
{
    if (a > 1)
        return a * factorial(a + 1);
    else
        return 1;
}
int main()
{
    long num = 3;
    cout << num << "!=" << factorial(num);
    return 0;
}
                        
B.
C.
A.
D.
E.
Open question page

Que: (142). What is the output of the following C++ program?

                            #include <iostream>
using namespace std;
long factorial(long n)
{
    if (n <= 1)
        return 1;
    return n * factorial(n - 1);
}
int main()
{
    cout << factorial(4);
    return 0;
}
                        
B.
C.
A.
D.
E.
Open question page

Que: (143). Which statement correctly describes the base case in a recursive factorial function?

B.
C.
A.
D.
E.
Open question page

Que: (144). What is the output of the following C++ code?

                            #include <iostream>
using namespace std;
int fun(int n)
{
    if (n == 0)
        return 0;
    return n + fun(n - 1);
}
int main()
{
    cout << fun(4);
    return 0;
}
                        
C.
A.
B.
D.
E.
Open question page

Que: (145). What is the likely result of calling the following recursive function with n equal to 5?

                            int fun(int n)
{
    if (n == 0)
        return 1;
    return fun(n + 1);
}
                        
B.
A.
C.
D.
E.
Open question page

Que: (146). What will the following C++ code print?

                            #include <iostream>
using namespace std;
int factorial(int n)
{
    if (n == 0)
        return 1;
    return n * factorial(n - 1);
}
int main()
{
    cout << factorial(0);
    return 0;
}
                        
C.
A.
B.
D.
E.
Open question page

Que: (147). What is the output of this recursive C++ function?

                            #include <iostream>
using namespace std;
int fun(int n)
{
    if (n == 1)
        return 1;
    return n * fun(n - 1);
}
int main()
{
    cout << fun(5);
    return 0;
}
                        
B.
A.
C.
D.
E.
Open question page

Que: (148). What is the output of the following C++ program?

                            #include <iostream>
using namespace std;
int fun(int n)
{
    if (n <= 1)
        return 1;
    n = n - 1;
    return n + fun(n);
}
int main()
{
    cout << fun(4);
    return 0;
}
                        
B.
A.
C.
D.
E.
Open question page

Que: (149). Which problem can occur when recursion has no reachable base case?

B.
A.
C.
D.
E.
Open question page

Que: (150). What is the output of the following C++ code?

                            #include <iostream>
using namespace std;
int fun(int n)
{
    if (n <= 1)
        return n;
    return fun(n - 1) + fun(n - 2);
}
int main()
{
    cout << fun(5);
    return 0;
}
                        
B.
A.
C.
D.
E.
Open question page

Que: (151). Which is correct syntax of inheritance in C++?

Asked in BPSC TRE 1.0
B.
A.
C.
D.
E.
Open question page

Que: (152). What is the default inheritance access mode for a class in C++?

A.
B.
C.
D.
E.
Open question page

Que: (153). What will be the output of the following C++ code?

                            #include <iostream>
using namespace std;
class Base
{
public:
    int x = 10;
};
class Derived : public Base
{
};
int main()
{
    Derived d;
    cout << d.x;
    return 0;
}
                        
C.
B.
A.
D.
E.
Open question page

Que: (154). Which statement about protected members in C++ inheritance is correct?

B.
C.
A.
D.
E.
Open question page

Que: (155). What type of inheritance is demonstrated by the following C++ code?

                            class A { };
class B : public A { };
class C : public B { };
                        
B.
C.
A.
D.
E.
Open question page

Que: (156). Which declaration correctly demonstrates multiple inheritance in C++?

A.
C.
B.
D.
E.
Open question page

Que: (157). What happens when a derived class directly accesses a private member of its base class?

                            #include <iostream>
using namespace std;
class Base
{
private:
    int x = 5;
};
class Derived : public Base
{
public:
    void show()
    {
        cout << x;
    }
};
int main()
{
    Derived d;
    d.show();
    return 0;
}
                        
C.
B.
A.
D.
E.
Open question page

Que: (158). What is the purpose of virtual inheritance in C++?

C.
B.
A.
D.
E.
Open question page

Que: (159). What is the output of the following C++ code?

                            #include <iostream>
using namespace std;
class Base
{
public:
    Base() { cout << "B"; }
};
class Derived : public Base
{
public:
    Derived() { cout << "D"; }
};
int main()
{
    Derived obj;
    return 0;
}
                        
C.
B.
A.
D.
E.
Open question page

Que: (160). What is the output of the following C++ code using virtual functions and inheritance?

                            #include <iostream>
using namespace std;
class Base
{
public:
    virtual void show() { cout << "Base"; }
};
class Derived : public Base
{
public:
    void show() override { cout << "Derived"; }
};
int main()
{
    Derived d;
    Base* p = &d;
    p->show();
    return 0;
}
                        
B.
A.
C.
D.
E.
Open question page

Que: (161). Which one of the following is the correct definition of the is_array() function in PHP?

Asked in BPSC TRE 1.0
A.
B.
C.
D.
E.
Open question page

Que: (162). What will be the output of the following PHP code?

                            <?php
$a = [10, 20, 30];
$b = 25;
var_dump(is_array($a));
var_dump(is_array($b));
?>
                        
B.
A.
C.
D.
E.
Open question page

Que: (163). Which PHP function returns the number of elements in an array?

A.
C.
B.
D.
E.
Open question page

Que: (164). What will be the output of the following PHP code?

                            <?php
$user = ["name" => "Amit", "age" => 25];
echo is_array($user) ? "Yes" : "No";
?>
                        
B.
A.
C.
D.
E.
Open question page

Que: (165). What will the following PHP code print?

                            <?php
$data = [[1, 2], [3, 4]];
echo is_array($data[0]) ? "Array" : "Not Array";
?>
                        
C.
B.
A.
D.
E.
Open question page

Que: (166). What is the output of this PHP code?

                            <?php
$numbers = [10, 20, 30, 40];
echo $numbers[2];
?>
                        
A.
C.
B.
D.
E.
Open question page

Que: (167). What will be the output of the following PHP code?

                            <?php
$data = [[1, 2], [3]];
echo count($data) . " ";
echo count($data, COUNT_RECURSIVE);
?>
                        
C.
A.
B.
D.
E.
Open question page

Que: (168). What will be the output of this PHP code?

                            <?php
$value = "123";
var_dump(is_array($value));
?>
                        
A.
C.
B.
D.
E.
Open question page

Que: (169). Which PHP function checks whether a specified value exists in an array?

B.
A.
C.
D.
E.
Open question page

Que: (170). What will be the output of the following PHP code?

                            <?php
function getData() {
    return ["PHP", "C++"];
}
$result = getData();
echo is_array($result) ? "Array" : "Not Array";
?>
                        
A.
B.
C.
D.
E.
Open question page

Que: (171). Which of the following statements is correct about a class and an object in C++?

Asked in BPSC TRE 1.0
A.
C.
B.
D.
E.
Open question page

Que: (172). Which keyword is used to define a class in C++?

B.
C.
A.
D.
E.
Open question page

Que: (173). What will be the output of the following C++ code?

                            #include <iostream>
using namespace std;
class Student
{
public:
    int marks = 85;
};
int main()
{
    Student s;
    cout << s.marks;
    return 0;
}
                        
A.
B.
C.
D.
E.
Open question page

Que: (174). What is the default access specifier for members of a C++ class?

B.
C.
A.
D.
E.
Open question page

Que: (175). What will be the output of the following C++ program?

                            #include <iostream>
using namespace std;
class Demo
{
public:
    Demo() { cout << "Hello"; }
};
int main()
{
    Demo d;
    return 0;
}
                        
A.
B.
C.
D.
E.
Open question page

Que: (176). What will be the output of the following C++ code?

                            #include <iostream>
using namespace std;
class Test
{
public:
    static int count;
};
int Test::count = 10;
int main()
{
    Test a, b;
    a.count++;
    cout << b.count;
    return 0;
}
                        
B.
C.
A.
D.
E.
Open question page

Que: (177). Which statement about constructors in C++ is correct?

A.
B.
C.
D.
E.
Open question page

Que: (178). What will be the output of the following C++ program?

                            #include <iostream>
using namespace std;
class Number
{
    int value;
public:
    Number(int value)
    {
        this->value = value;
    }
    void show()
    {
        cout << value;
    }
};
int main()
{
    Number n(25);
    n.show();
    return 0;
}
                        
B.
A.
C.
D.
E.
Open question page

Que: (179). In a typical C++ implementation, what is the result of sizeof applied to an empty class?

                            #include <iostream>
using namespace std;
class Empty
{
};
int main()
{
    cout << sizeof(Empty);
    return 0;
}
                        
B.
A.
C.
D.
E.
Open question page

Que: (180). Which object-oriented programming principle combines data and the functions that operate on that data into a single unit?

A.
C.
B.
D.
E.
Open question page

Que: (181). Which of the following can be used to create an abstract class in C++?

Asked in BPSC TRE 1.0
A.
C.
B.
D.
E.
Open question page

Que: (182). Which is the correct syntax for declaring a pure virtual function in C++?

A.
C.
B.
D.
E.
Open question page

Que: (183). Can an object of an abstract class be created directly in C++?

B.
C.
A.
D.
E.
Open question page

Que: (184). What is the output of the following C++ program?

                            #include <iostream>
using namespace std;
class Base {
public:
    virtual void show() = 0;
};
class Derived : public Base {
public:
    void show() override {
        cout << "Derived";
    }
};
int main() {
    Derived obj;
    obj.show();
    return 0;
}
                        
B.
C.
A.
D.
E.
Open question page

Que: (185). What happens if a derived class does not override an inherited pure virtual function?

A.
B.
C.
D.
E.
Open question page

Que: (186). Which statement about constructors in an abstract C++ class is correct?

B.
C.
A.
D.
E.
Open question page

Que: (187). What is the output of the following C++ program?

                            #include <iostream>
using namespace std;
class Base {
public:
    virtual void display() {
        cout << "Base";
    }
};
class Derived : public Base {
public:
    void display() override {
        cout << "Derived";
    }
};
int main() {
    Derived d;
    Base* ptr = &d;
    ptr->display();
    return 0;
}
                        
C.
A.
B.
D.
E.
Open question page

Que: (188). What is the output of the following C++ program?

                            #include <iostream>
using namespace std;
class Shape {
public:
    virtual int area() = 0;
};
class Square : public Shape {
public:
    int area() override {
        return 4 * 4;
    }
};
int main() {
    Square s;
    cout << s.area();
    return 0;
}
                        
A.
C.
B.
D.
E.
Open question page

Que: (189). Consider the following C++ code. Which statement is correct?

                            #include <iostream>
using namespace std;
class A {
public:
    virtual void f() = 0;
};
int main() {
    A* p = nullptr;
    return 0;
}
                        
A.
C.
B.
D.
E.
Open question page

Que: (190). Which statement about a pure virtual function in C++ is correct?

C.
B.
A.
D.
E.
Open question page

Que: (191). Which of the following statements is correct about the C++ programming language?

Asked in BPSC TRE 1.0
B.
A.
C.
D.
E.
Open question page

Que: (192). When does static type checking primarily occur in C++?

C.
A.
B.
D.
E.
Open question page

Que: (193). What is the purpose of a const member function in C++?

A.
B.
C.
D.
E.
Open question page

Que: (194). What is the output of the following C++ program?

                            #include <iostream>
using namespace std;
class Test {
    int x;
public:
    Test() : x(10) {}
    int getValue() const {
        return x;
    }
};
int main() {
    const Test obj;
    cout << obj.getValue();
    return 0;
}
                        
B.
A.
C.
D.
E.
Open question page

Que: (195). Which C++ feature enables a function call to be resolved at runtime based on the actual object type?

C.
A.
B.
D.
E.
Open question page

Que: (196). What is the output of the following C++ program?

                            #include <iostream>
using namespace std;
class Base {
public:
    virtual void show() {
        cout << "Base";
    }
};
class Derived : public Base {
public:
    void show() override {
        cout << "Derived";
    }
};
int main() {
    Derived d;
    Base* p = &d;
    p->show();
    return 0;
}
                        
B.
A.
C.
D.
E.
Open question page

Que: (197). Which C++ operator is commonly used for runtime type checking and safe downcasting in a polymorphic class hierarchy?

C.
B.
A.
D.
E.
Open question page

Que: (198). What happens when a const object attempts to call a non-const member function in C++?

                            #include <iostream>
using namespace std;
class Test {
public:
    void show() {
        cout << "Hello";
    }
};
int main() {
    const Test obj;
    obj.show();
    return 0;
}
                        
C.
A.
B.
D.
E.
Open question page

Que: (199). Which statement correctly describes function overloading and function overriding in C++?

C.
A.
B.
D.
E.
Open question page

Que: (200). What is the output of the following C++ program?

                            #include <iostream>
using namespace std;
void print(int x) {
    cout << "int";
}
void print(double x) {
    cout << "double";
}
int main() {
    print(5);
    return 0;
}
                        
B.
A.
C.
D.
E.
Open question page

Que: (201). Which feature of OOP is indicated by the following code?

Asked in BPSC TRE 1.0
                            class student { int marks; };
class topper : public student {
    int age;
    topper(int age) { this->age = age; }
};
                        
A.
B.
C.
D.
E.
Open question page

Que: (202). Which OOP concept allows a derived class to acquire accessible members of a base class?

C.
A.
B.
D.
E.
Open question page

Que: (203). Which OOP concept bundles data and the functions that operate on that data into a single unit?

A.
B.
C.
D.
E.
Open question page

Que: (204). What is the output of the following C++ program?

                            #include <iostream>
using namespace std;
class Student {
public:
    int marks = 80;
};
class Topper : public Student {
public:
    void display() {
        cout << marks;
    }
};
int main() {
    Topper t;
    t.display();
    return 0;
}
                        
B.
C.
A.
D.
E.
Open question page

Que: (205). Which access specifier makes a class member accessible only within the class and its friends?

B.
A.
C.
D.
E.
Open question page

Que: (206). What is the output of the following C++ program?

                            #include <iostream>
using namespace std;
class Test {
    int x;
public:
    Test(int x) {
        this->x = x;
    }
    void display() {
        cout << x;
    }
};
int main() {
    Test t(25);
    t.display();
    return 0;
}
                        
B.
C.
A.
D.
E.
Open question page

Que: (207). Which feature of OOP allows the same interface to represent different underlying implementations?

C.
A.
B.
D.
E.
Open question page

Que: (208). What is the output of the following C++ program?

                            #include <iostream>
using namespace std;
class Base {
public:
    virtual void show() {
        cout << "Base";
    }
};
class Derived : public Base {
public:
    void show() override {
        cout << "Derived";
    }
};
int main() {
    Derived d;
    Base* p = &d;
    p->show();
    return 0;
}
                        
C.
A.
B.
D.
E.
Open question page

Que: (209). What happens if a derived class inherits publicly from a base class whose public and protected members are accessible?

A.
B.
C.
D.
E.
Open question page

Que: (210). Consider the following C++ code. Which statement is correct?

                            #include <iostream>
using namespace std;
class Base {
private:
    int x = 10;
protected:
    int y = 20;
};
class Derived : public Base {
public:
    void display() {
        cout << y;
    }
};
int main() {
    Derived d;
    d.display();
    return 0;
}
                        
A.
B.
C.
D.
E.
Open question page