C++ test questions

This is a discussion on C++ test questions within the C++ Programming forums, part of the General Programming Boards category; I am carrying this over from the C board. I am an instructor who teaches programming. I have many test ...

  1. #1
    CS Author and Instructor
    Join Date
    Sep 2002
    Posts
    511

    C++ test questions

    I am carrying this over from the C board. I am an instructor who teaches programming. I have many test questions and test banks with questions. However, I was looking for some good test questions that you on the C++ programming board can provide me. I will share you mine If you will share yours.

    Thanks. Let's begin

    Code:
    Which is true?
    A.  A derived class may have more than base class.
    B.  A base class may have more than one derived class.
    C. both (a) and (b)
    D.  neither (a) nor (b)
    Code:
    Select the format for inheriting multiple classes.
    A.  class Derived: public class Base1 : public class Base2
    B.  class Derived: public class Base1, Base2
    C.  class Derived: public Base1, public Base2
    D.  class Derived: (public Base1; public Base2;)
    Answers will come later- Mr. C.

  2. #2
    Skunkmeister Stoned_Coder's Avatar
    Join Date
    Aug 2001
    Posts
    2,572
    Whats the point. you dont or wont listen to us.
    Free the weed!! Class B to class C is not good enough!!
    And the FAQ is here :- http://faq.cprogramming.com/cgi-bin/smartfaq.cgi

  3. #3
    S Sang-drax's Avatar
    Join Date
    May 2002
    Location
    Göteborg, Sweden
    Posts
    2,072
    The answer is C and C, Mr C.

    I cannot think of any good C++ questions. The only course I've read had questions like:
    "Type a program that reads one integer from the keyboard and prints out that number plus two,"

    Redefine Print() without using a macro:

    #define Print(x) cout << (x) << endl;
    Print(12);
    Print("Sang-drax");
    Last edited by Sang-drax : Tomorrow at 02:21 AM. Reason: Time travelling

  4. #4
    S Sang-drax's Avatar
    Join Date
    May 2002
    Location
    Göteborg, Sweden
    Posts
    2,072
    Originally posted by Stoned_Coder
    Whats the point. you dont or wont listen to us.
    huh??

    *reads the thread in the C-forum*

    You should listen to their advice, Mr C. They know what they're talking about.
    Last edited by Sang-drax : Tomorrow at 02:21 AM. Reason: Time travelling

  5. #5
    Seeking motivation... endo's Avatar
    Join Date
    May 2002
    Posts
    537
    Yup c in both cases. Do I get an A now?
    Couldn't think of anything interesting, cool or funny - sorry.

  6. #6
    CS Author and Instructor
    Join Date
    Sep 2002
    Posts
    511
    Yes, C is right in both cases.

    Code:
    memcmp would return ___________ for the call
    memcmp("Hi, how are you?", "Hi, how are things?", 6);
    (a) -1
    (b) a negative number.
    (c) zero.
    (d) a positive number.
    Code:
    What is wrong with the following abstract class definition?
    class Shape {
    public:
    virtual double print() const;
    double area() const { return base * height;}
    private:
    float base;
    float height;
    }
    (a) There are no pure virtual functions.
    (b) There is a non-virtual function.
    (c) Private variables are being accessed by a public function.
    (d) Nothing.

    I do other see people points-that's why I am trying to write the questions clearer and less ambigous. That's why I have all these pointer questions laying around.

    Mr. C.

  7. #7
    moi
    moi is offline
    Registered User moi's Avatar
    Join Date
    Jul 2002
    Posts
    946
    memcmp () would return 0 because it only is comparing the first 6 bytes in this example.
    hello, internet!

  8. #8
    CS Author and Instructor
    Join Date
    Sep 2002
    Posts
    511
    This time we are in agreement the answer is C.

    Mr. C.

  9. #9
    I lurk
    Join Date
    Aug 2002
    Posts
    1,361
    If you're looking for questions you might check out the quiz:
    http://www.cprogramming.com/cgi-bin/quiz.cgi

  10. #10
    CS Author and Instructor
    Join Date
    Sep 2002
    Posts
    511
    Yes, that quiz on the site is a good place were. I can send my students for a quick review of C++ concepts.

    I just want some other questions. I can come up with my own but I like seeing what other people think.

    mr. C

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Computer Programmer Aptitude Battery Test (CPAB)
    By scotty101 in forum General Discussions
    Replies: 40
    Last Post: 02-22-2010, 11:49 PM
  2. Newbie needs help..
    By xpress urself in forum C++ Programming
    Replies: 3
    Last Post: 07-26-2007, 08:22 PM
  3. 5 questions
    By DarkDot in forum C++ Programming
    Replies: 3
    Last Post: 04-16-2007, 12:32 AM
  4. My C++ test is COMING!!...
    By [Z-D] in forum C++ Programming
    Replies: 52
    Last Post: 12-01-2006, 08:02 PM
  5. Bitwise Test Questions
    By Mister C in forum C Programming
    Replies: 9
    Last Post: 11-27-2002, 06:06 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21