Breaking News

CS107: C++ Programming Certification Exam Answers

C++ is a powerful programming language that is widely used in various domains including system/software development, game development, high-performance applications, embedded systems, and more. Here’s a brief introduction to C++ programming:

  1. History and Overview:
    • C++ was developed by Bjarne Stroustrup at Bell Labs in the early 1980s as an extension of the C programming language.
    • It was designed with a focus on efficiency, flexibility, and compatibility with C.
    • C++ is an object-oriented programming (OOP) language, which means it supports concepts like classes, objects, inheritance, polymorphism, encapsulation, and abstraction.
    • It also supports generic programming features like templates, which allow for the creation of flexible and reusable code.
  2. Syntax:
    • C++ syntax is similar to C, but with additional features for object-oriented programming.
    • A C++ program typically starts with the inclusion of header files, followed by a main() function which serves as the entry point of the program.
    • Statements in C++ end with a semicolon ;.
    • C++ supports various data types including integers, floating-point numbers, characters, arrays, pointers, and more.
    • Control flow statements like if, else, for, while, switch, etc., are used for decision making and looping.
  3. Object-Oriented Programming (OOP):
    • In C++, classes are used to define new data types that bundle data and operations together.
    • Objects are instances of classes. They encapsulate data and behavior.
    • Inheritance allows a class to inherit properties and behavior from another class.
    • Polymorphism enables the use of a single interface for different data types or objects.
  4. Memory Management:
    • C++ provides control over memory management through features like dynamic memory allocation and deallocation using new and delete operators.
    • Pointers are extensively used in C++ for memory manipulation and efficient data access.
  5. Standard Template Library (STL):
    • The STL is a powerful library in C++ that provides a set of reusable generic data structures and algorithms.
    • It includes containers (like vectors, lists, maps, etc.) and algorithms (like sorting, searching, etc.) that operate on these containers.
  6. Compile and Link:
    • C++ programs are typically compiled into machine code using a compiler like GCC, Clang, or Visual C++ Compiler.
    • The compiled code is then linked with libraries to create an executable file.

Overall, C++ is a versatile language known for its performance, flexibility, and wide range of applications. Learning C++ opens up opportunities to work on various software projects and systems programming tasks.

CS107: C++ Programming Exam Quiz Answers

CS107 C++ Programming
  • Analytical engine
  • ENIAC
  • Altair
  • Von Neumann Architecture
  • C++ class
  • C++ project
  • C++ package
  • C++ program file
  • Line 1: a is a boolean variable, so it cannot accept an integer
  • Line 2: Any calculations must be on the left side of the assignment statement
  • Line 3: Since c is a float, we must assign it the value 4.0
  • Line 4: You must complete the calculations before you can request to output
  • Enter:
  • Enter price:
  • Enter quantity:
  • Enter >>price
  • cin<<age;
  • cin>>age;
  • count<<age;
  • count>>age;
  • 1.0
  • 1.5
  • 2.0
  • 2.5
  • A valid variable name can be up to 40 characters in length.
  • A valid variable name can start with a number and end with a number.
  • A valid variable name may consist of letters, digits, and the underscore (_) character.
  • A valid variable name may contain uppercase letters, which are no different than lowercase letters.
  • 2
  • 1.0
  • 2.0
  • 2.5
  • 22
  • 50
  • 55
  • 56
  • 1, 2, 3, 4, 5, 6, 7
  • 2, 4, 7, 1, 3, 5, 6
  • 6, 7, 5, 1, 2, 3, 4
  • 6, 7, 5, 2, 4, 1, 3
  • 1
  • 5
  • 6
  • 11
  • Alternative execution
  • Chained conditional
  • Nested conditional
  • Unary conditional
  • F5
  • F6
  • F7
  • F8
  • Use the nothrow method
  • Use the noallocate method
  • Check the data before it is entered
  • Use a bad_allocation_fail exception
  • 9, 10
  • 9, 11
  • 10, 11
  • 11, 9
  • swap (2,3); Pass the values as literals
  • swap (&x, &y); Send the address of the variable as an argument
  • &a, &b = swap (x, y); It must be returned to a variable as an address
  • void swap (int &x, int &y); Receive the variables in the parameter as an address
  • phone = “(” + phone. replace (phone. find (‘0’),1,”) “;
  • phone. replace (phone. find (‘-‘), “)”);
  • phone. insert (0,”(“);

phone. replace (phone. find (‘-‘),1,”) “);

  • phone. replace (0,”(“);

phone. replace (phone. find (‘-‘),1,”) “);

  • i and j are equal
  • i is currently larger than j
  • j is currently larger than i
  • The size of j is dynamic and will expand as needed so j will be larger than i
  • When the object has created an error
  • When we want to create a new object
  • When we want to release the memory that the object possesses
  • When we want to capture the memory that the object possesses
  • Explicitly, whenever a new object of the constructor class is created
  • Automatically, whenever a new object of the constructor is destroyed
  • Automatically, whenever a new object of the constructor class is created
  • If it is defined in the class and called when a new object of this class is created
  • void setInfo (string a) {} void (string b) {}
  • void setInfo (int a) {} string setInfo (int a) {}
  • void setInfo (int a, int b) {} void setInfo (int b, int a) {}
  • void setInfo (int a, int b) {} void setInfo (int a, string b){}
  • A reference to a memory location of a variable
  • A pointer to the function that is being executed
  • An object whose member function is being executed
  • A pointer to the object whose member function is being executed
  • Members with one unique value for all the objects of that same class
  • Members with one unique value for all the objects of multiple classes
  • Members with multiple unique values for all the objects of that same class
  • Members with multiple unique values for all the objects of multiple classes
  • friend class Person ();
  • friend Person;
  • class friend Person;
  • friend class Person;
1
  • Hierarchical inheritance
  • Hybrid inheritance
  • Multilevel inheritance
  • Multiple inheritance
  • The functions appear after the main
  • Main does not call the correct function
  • The functions should have a return value
  • The printLogarithm function should contain an else clause
  • It uses a derived class in a similar manner as the base class, with the use of pointers
  • It takes advantage of the fact that a pointer to a derived class is type-compatible with a pointer to its base class
  • It takes advantage of the fact that a class has only a single function with the same data type pointing to the derived class
  • It makes sure that all pointers in the derived class point to functions within the base class, but not to the operator members
  • 4 5
  • 5 4
  • 10 20
  • 20 10
  • string setName () {return name;}
  • void setName () {name = myname;}
  • string setName(myname) {name = myname;}
  • void setName (string myname) {name = myname;}
  • template<typename T>

class Foo {

public:

Foo ();

void someMethod (typename T x);

private:

typename T x;

};

  • class Foo {

public:

Foo ();

void someMethod (T x);

private:

T x;

};

  • template<typename T>

class Foo {

public:

Foo ();

void someMethod (T x);

private:

T x;

};

  • <typename T>template

class Foo {

public:

Foo ();

void someMethod (T x);

private:

T x;

};

  • #include <iostream>
  • #include <ofstream>
  • #include <ifstream>
  • #include <fstream>
  • throws “Division by zero condition!”;
  • throw “Division by zero condition!”;
  • exception “Division by zero condition!”;
  • catch “Division by zero condition!”;
  • Brian Kernighan
  • Bjarne Stroustrup
  • Dennis Ritchie
  • Ken Thompson
  • When we divide, the result is always a float.
  • When we divide, the result is always an integer.
  • When we divide two integers, the result will always be an integer.
  • When we divide two numbers, the result will be a float, which then gets converted to an integer.
  • cin<<age;
  • cin>>age;
  • cout<<age;
  • cout>>age;
  • A valid variable name can be up to 40 characters in length.
  • A valid variable name can start with a number and end with a number.
  • A valid variable name may consist of letters, digits, and the underscore (_) character.
  • A valid variable name may contain uppercase letters, which are no different than lowercase letters.
  • a contains 3, b contains 3
  • a contains 3, b contains 4
  • a contains 4, b contains 3
  • a contains 4, b contains 4
  • Argument
  • Call
  • Instance
  • Parameter
  • strcmp (s1, s2);
  • strcmp (s1, s3);
  • strcmp (s3, s4);
  • strcmp (s1, “Alpha”);
  • B has goods and S has money
  • B has money and S has goods; B has goods and S has money
  • after, B has goods and S has money; before, B has money and S has goods
  • before, B has money and S has goods; after, B has goods and S has money
  • Constructor with no functions
  • Constructor with no arguments
  • Constructor with one argument
  • Constructor with name argument
  • When there are no parameters
  • When the parameters are undefined
  • When there are no data members defined
  • When the data members have the same name as the parameters passed in
  • Use dot notation
  • Put it in a separate folder
  • Create a different namespace
  • Create a different folder and use dot notation
  • It inherits every member of a base class
  • It only inherits the operator members, not the methods, including constructors and destructors
  • It inherits every member of a base class including the operator members but does not include the constructor and destructor
  • It inherits every member of a base class but it does not inherit its constructor and destructor, operator members, or its friends
  • It requires one argument
  • It may accept multiple parameters
  • The name of the accessor begins with the Set prefix
  • It has a return type consistent with the data being retrieved
  • C
  • COBOL
  • Fortran
  • Java
  • cin<<
  • cin>>
  • cout<<
  • cout>>
  • cin<<
  • cin>>
  • cout<<
  • cout>>
  • boolean
  • char
  • double
  • float
  • 2
  • 6
  • 8
  • 12
  • 0
  • 9
  • 11
  • 16
  • It assigns the value 5 to a and then assigns b+1 to variable a
  • It assigns the value 5 to b and then assigns b+1 to variable b
  • It assigns the value 5 to a and then assigns b+1 to variable b
  • It assigns the value 5 to b and then assigns b+1 to variable a
  • A is 10 and C is 30
  • A is 10 and C is 96
  • A is 15 and C is 30
  • A is 15 and C is 96
  • The size of a variable in computer memory
  • The type of a variable in computer memory
  • The address that locates a variable in computer memory
  • The address that locates the start of a program in computer memory
  • size: 2, length: 2, capacity: 2, max size: 25
  • size: 5, length: 5, capacity: 5, max size: 4611686018427387897
  • size: 25, length: 5, capacity: 25, max size: 25
  • size: 25, length: 25, capacity: 25, max size: 4611686018427387897
  • 70
  • 5900
  • 5952
  • 5970
  • ~Person ();
  • delete Person ();
  • destroy Person ();
  • ~Person (int x, int y);
  • 1
  • 6
  • 12
  • 15
  • It is a group of elements of the same type
  • It is a group of functions of different types
  • It is an expanded concept of a data structure that can hold data
  • It is an expanded concept of a data structure that can hold data and functions
  • 2, 7
  • 7, 8
  • 18, 9
  • 18, 28
  • 2001 A Space Odyssey
  • 2001 A Space Odyssey (1968)
  • My favorite movie is: 2001 A Space Odyssey 1968
  • My favorite movie is: 2001 A Space Odyssey (1968)
  • Class folder
  • Project folder
  • Default folder
  • Application folder
  • candy apples are $10 and pumpkin bread is $5
  • pumpkin bread is 10 and candy apples is 5
  • pumpkin bread is $5 and candy apples are $10
  • pumpkin bread is $10 and candy applies is $5
  • 1
  • 2
  • 2.0
  • 2.5
  • 60000 m
  • 65000 m
  • 20000 s
  • 50000 s
  • When their parameter types are different
  • When the parameters and the parameter types are the same
  • When the parameter types or number of parameters are different
  • When the parameter types are the same but the parameters are different
  • Writing dots here: ………. and then more
  • Writing 5 dots here: …… and then 10 more……….
  • Writing 10 dots here: ………. and then 5 more
  • Writing 10 dots here: ………. and then 10 more……….
  • union employee {

int age;

long salary;

};

  • union Employee {

int age;

long salary;

} employee;

  • union employee {

int age;

long salary;

} Employee;

  • union Employee {

int age;

long salary;

};

  • It is named differently than other data types
  • It can hold more information than other data types
  • It allows you to group multiple like items together into a single set
  • It allows the same portion of memory to be accessed as different data types
  • perimeter does not return a value
  • square does not have access to perimeter
  • rectangle does not have access to perimeter
  • We need to pass a rectangle to perimeter, not a square
  • Line 21
  • Line 22
  • Line 23
  • Line 24
  • Templates
  • Inheritance
  • Abstract functions
  • Function overloading
  • ios: app
  • ios: ate
  • ios: trunc
  • ios: overwrite
  • Line 2
  • Line 3
  • Line 4
  • Line 5
  • New → Add Code
  • New → Source File
  • Project Type → Empty Project
  • Select Configuration → Source File
  • a1= a2;
  • a1 = int(a2);
  • a1 = double(a2);
  • double a1 = a2;
  • It uses OR operation bit by bit between two variables
  • It represents the OR comparison between two variables
  • It uses AND operation bit by bit between two variables
  • It represents the AND comparison between two variables
  • 10, 9, 8, 7, 6, 5, 4, countdown ended!
  • 10, 9, 8, 7, 6, 5, 4, 3 countdown ended!
  • 10, 9, 8, 7, 6, 5, 4, 3, countdown ended!
  • 10, 9, 8, 7, 6, 5, 4, 3, 2 countdown ended!
  • Creates a breakpoint on a specific field
  • Allows you to delete and deactivate stop points
  • Use Java code to define how a variable is displayed
  • Uses the toString () method to determine how to display the variable
  • Branch 1
  • Branch 2
  • Branch 3
  • Branch 4
  • 4, 4
  • 4, 6
  • 6, 24
  • 24, 6
  • Programs don’t run well unless they are inside functions.
  • This allows the programmer to get creative with the code.
  • This makes the program smaller by eliminating repetitive code.
  • This moves the focus of the code to the method instead of the main.
  • Celsius Fahrenheit

-10       23.8

-8         25.8

-6         27.8

-4         29.8

-2         31.8

  • Fahrenheit Celsius

-10            23.8

-8              25.8

-6              27.8

-4              29.8

-2              31.8

  • Celsius Fahrenheit

-10.00   23.80

-8.00   25.80

-6.00   27.80

  • Celsius Fahrenheit 

-10.00     23.80

-8.00      25.80

-6.00      27.80

-4.00      29.80

-2.00     31.80

  • ilovecplusplus.com
  • www.ilovecplusplus.com
  • http://ilovecplusplus.com
  • http://www.ilovecplusplus.com
  • for (int i = 0; i<20; ++i) {}
  • for (int i = 0; i<=20; ++i) {}
  • for (int i = 0; i<values. size (); ++i) {}
  • for (int i = 0; i<=values. size (); ++i) {}
  • Person (name, id)

{

name = name;

id = id;

}

  • Person ()

{

name = “”;

id = “”;

}

  • Person (string name, string id)

{

name = “”;

id = “”;

}

  • Person

{

name = “”;

id = “”;

}

  • It is possible to change the precedence of operators
  • New operators such as **, <> or &/ can be created
  • The overloads of operators && and || lose their short-circuit evaluation
  • &&, ||, and, (comma) maintain their special sequencing properties when overloaded
  • name = this.name;
  • this.name = name;
  • name = this->name;
  • this->name = name;
  • An exception is caught in a try block
  • An exception can be thrown in a try block
  • A try block can be followed by only one catch block
  • It combines the normal case code with the code that handles exceptions

About Clear My Certification

Check Also

CS402 Computer Communications and Networks

CS402: Computer Communications and Networks Certification Exam Answers

Computer communications and networks refer to the systems and infrastructure that enable communication and data …

Leave a Reply

Your email address will not be published. Required fields are marked *