CS201 Solved Mega File for Short Questions
- Type
- Quiz
- Course
- CS201 Introduction to Programming
- Size
- PDF 330 KB
- Updated
- 23 Oct 2026
You get 3 free files a day on the website. Add the Chrome extension for 30 a day.
Preview text
Text from pages 1, 2, 3 of 32. Download the file for all 32 pages.
CS201 Subjective:
Question: What is the use of reference data type?
Answer: A reference data type is a variable that can contain an address. The reference data types in Java are arrays, classes and interfaces. You'll hear often say that Java does not have pointers. Yet, you could consider a reference data type to be a pointer
Question: What are the main types of operators in terms of number of arguments they take?
Answer: The difference is in the number of arguments used by the function. In the case of binary operator overloading, when the function is a member function then the number of arguments used by the operator member function is one. When the function defined for the binary operator overloading is a friend function, then it uses two arguments.
Question: What is the “this” pointer? Give an example of its use
Answer: In a C++ program, if you create object A of class X, you can then obtain the address of A by using the "this" pointer. The address is available as a local variable in the non-static member functions of X, and its type is const X*. The "this" pointer works because C++ creates instances of its data members, and it keeps one copy of each member function.
Question: What are manipulators? Give one example.
Answer: Manipulators are operators used in C++ for formatting output. The data is manipulated by the programmer‟s choice of displayed. Endl manipulator: This manipulator has the same functionality as the „\n‟ newline character.
Question:If the requested memory is not available in the system then what does calloc/malloc and new operator return?
Answer: malloc returns a void pointer to the allocated space or NULL if there is insufficient memory available. To return a pointer to a type other than void, use a type cast on the return value. The storage space pointed to by the return value is guaranteed to be suitably aligned for storage of any type of object. If size is 0, malloc allocates a zerolength item in the heap and returns a valid pointer to that item. By default, malloc does not call the new handler routine on failure to allocate memory. You can override this default behavior so that, when malloc fails to allocate memory, malloc calls the new handler routine in the same way that the new operator does when it fails for the same reason.
Question: If we want to send the data by reference and don‟t want that original data should be affected then what can we do to prevent any change?
Answer: Call by Reference shall be used in that case.
Question: Write down the disadvantages of the templates.
Answer: The disadvantages of templates are:
- Templates can make code difficult to read and follow depending upon coding style.
- They can present seriously confusing syntactical problems esp. when the code is large and spread over several header and source files.
- Then, there are times, when templates can "excellently" produce nearly meaningless compiler errors thus requiring extra care to enforce syntactical and other design constraints. A common mistake is the angle bracket problem.
Question: The following code segment has errors. Locate as many as you can and explain briefly.
Answer: class Circle // no need to enter colon here ,
private : //colon missing double centerX; double centerY; double radius; public: //colon missing void setCenter(double, double); void setRadius(int);
};//semi colon missing
Write a program which defines three variables of type double which store three different values including decimal points, using setprecision manipulators to print all these values with different number of digits after the decimal number.
#include <iomanip>
int main ()
double x1 = 12345624.72345 double x2 = 987654.12345 double x3 = 1985.23456 cout << setprecision (3) << x1<< endl; cout << setprecision (4) << x2 << endl; cout << setprecision (5) << x3<< endl;
return 0;
Identify the errors in the following member operator function and also correct them.
math temp;
return number;
Answer: The errors are in the arguments of the member operation function and also in the body of operator member function. Correct function should be
math temp; temp = m;
return temp.number;
Write a program which consists of two classes, Date and Person. Date class should contain three data members day, month, year and setter and getter function for these data members. Date class should also contain showdate() member function to display date. Person class should contain three data members Name, Address, and Bday, where Name and Address are char pointer while Bday(Date of birth) is of type Date, Person class should further contain two member functions Display() and setdate(). In main program Create an object of Class person and call the member functions with it.
class Date
public: int day; int month; int year;
public: Date()
day=0; month=0; year=0;
void setDay(int); void setMonth (int); void setYear(int);
int getDay(); int getMonth(); int getYear();
void showDate();
Related CS201 files
All CS201 files →Get more out of VUBuddy, for free
- Unlimited downloads
- The explanation behind every MCQ answer
- Study offline on slow data
- 30 downloads a day instead of 3
- Sign in and buy Pro Semester here
One Pro Semester membership works in both the extension and the app.