Subtopics in this chapter
- 3.1Introduction to C programming
- 3.2Pointers, structure and data files in C programming
- 3.3OOP fundamentals and frameworks
- 3.4Fundamentals of web technology
- 3.5Pure virtual function and file handling
- 3.6Generic programming and exception handling
What is usually tested
C questions test operators, control statements, functions, recursion, arrays, strings, pointers, structures versus unions, and file handling. Object-oriented questions cover constructors, access specifiers, inheritance, polymorphism, virtual functions, templates and exception handling in C++, plus Java basics such as the JVM and threads. Web questions ask about HTTP, e-mail protocols, basic HTML tags, JavaScript and the DOM, jQuery selectors and common PHP functions, sessions and database operations.
Sample questions with answers
Choose an answer to check it, or open "Show answer". These 12 are taken from the 180 questions for this chapter in the practice bank.
-
Which of the following is NOT a storage class in C?
Show answer
Answer: D. volatile
volatile is a type qualifier; storage classes are auto, register, static, extern.
-
The smallest individual units of a C program, such as keywords, identifiers and operators, are called:
Show answer
Answer: A. Tokens
The compiler first breaks the source text into tokens: keywords, identifiers, constants, strings, operators and special symbols.
-
A pointer in C is a variable that stores:
Show answer
Answer: A. The memory address of another variable
The pointer is said to point to the variable whose address it holds.
-
In C, the unary * operator applied to a pointer gives:
Show answer
Answer: B. The value stored at the address held by the pointer
* is the indirection (dereference) operator; & is the address-of operator.
-
Bundling data and the methods that operate on it into a single unit is called:
Show answer
Answer: D. Encapsulation
Encapsulation wraps data and methods together and hides internal details.
-
Which of the following is NOT a basic feature of object-oriented programming?
Show answer
Answer: B. Recursion
The main features of OOP are encapsulation, abstraction, inheritance and polymorphism.
-
HTTP status code 404 indicates:
Show answer
Answer: D. Not Found
404 means the requested resource was not found.
-
Which HTML tag is used to create a hyperlink?
Show answer
Answer: B. <a>
The anchor tag <a> with the href attribute creates a hyperlink.
-
A virtual function in C++ is a member function that:
Show answer
Answer: B. Is declared in a base class and can be overridden in derived classes
The version that is called depends on the type of the object, not on the type of the pointer.
-
Dynamic (late) binding means that the function to be called is decided:
Show answer
Answer: C. At run time
It happens when a virtual function is called through a base-class pointer or reference.
-
Templates in C++ support generic programming because they allow:
Show answer
Answer: C. One piece of code to work with many data types
The data type is supplied as a parameter when the template is used.
-
Which keyword begins the declaration of a function template in C++?
Show answer
Answer: D. template
For example: template <class T> T max(T a, T b).
Practise this chapter
The full mock tests mix 10 questions from this chapter with 10 from each of the other nine, under the real 2-hour limit. Chapter practice mode lets you work through this chapter alone, untimed, with the explanation shown after every question. Go to the mock tests