C++ Questions

Q:

Default constructor accepts how many arguments?

A) one B) two
C) three D) None
 
Answer & Explanation Answer: D) None

Explanation:

Default constructors has no arguments

Report Error

View Answer Report Error Discuss

Filed Under: C++

1 3499
Q:

Where is the reference stored?

A) stack B) heap
C) queue D) None
 
Answer & Explanation Answer: A) stack

Explanation:

Referencee is stored in stack

Report Error

View Answer Report Error Discuss

Filed Under: C++

1 3499
Q:

Define void pointer using C++.?

Answer

In C++, void represents the absence of type, so void pointers are pointers that point to a value that has no type. The void pointers can point to any data type.


You can declare void pointer as follows:


void *p;

Report Error

View answer Workspace Report Error Discuss

Subject: C++
Job Role: Software Architect

0 3437
Q:

Explain storage qualifiers in C++

Answer

i.) Const - This variable means that if the memory is initialised once, it should not be altered by a program. 


ii.) Volatile - This variable means that the value in the memory location can be altered even though nothing in the program code modifies the contents. 


iii.) Mutable - This variable means that a particular member of a structure or class can be altered even if a particular structure variable, class, or class member function is constant.

Report Error

View answer Workspace Report Error Discuss

Subject: C++

1 3415
Q:

Different access specifiers for the class member in C++

Answer

Access specifiers in C++ determines the scope of the class members.


Public: If a class member is public, it can be used anywhere without the access restrictions.


Private: if a class member is private, it can be used only by the members and friends of class.


Protected: If a class member is protected, it can be used only by the members and friends of class and the members and friends of classes derived from class.

Report Error

View answer Workspace Report Error Discuss

Subject: C++

1 3408
Q:

What is the use of Namespace?

A) To encapsulate the data B) To structure a program into logical units.
C) Both a and b D) none of these
 
Answer & Explanation Answer: B) To structure a program into logical units.

Explanation:

The main aim of the namespace is to understand the logical units of the program and to make the program so robust.

Report Error

View Answer Report Error Discuss

Filed Under: C++

1 3384
Q:

What are the methods are available in storing sequential files?

A) Natural merging B) Polyphase sort
C) Distribution of Initial runs D) All the above
 
Answer & Explanation Answer: D) All the above

Explanation:

ll the above listed methods are used in storing sequential files

Report Error

View Answer Report Error Discuss

Filed Under: C++

1 3375
Q:

What is a Wrapper class?

Answer

Wrapper classes wrap primitive values in a class and offers utility to access them through objects. Some of the primitive wrapper data types are:


Byte, short, int, long, float, double, char, Boolean.


Example: 


Create a class name VectorAdd to populate it with integer values using the add(int, object) method.


public class VectorAdd


{


       public static void main(String argv[])


       {


             Vector v = new Vector();


             v.add(0,new Integer(10));


             v.add(1,new Integer(20));


             v.add(2,new Integer(30));


             for(int i=0; i < v.size();i ++)


             {


                  Integer iw =(Integer) v.get(i);


                  System.out.println(iw);


             }


       }


}

Report Error

View answer Workspace Report Error Discuss

Subject: C++

0 3332