InterviewSolution
This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.
| 51. |
What is the syntax to use explicit class specialization?(a) template class myClass{}(b) template class myClass{}(c) template class myClass{}(d) template class myClass{}The question was posed to me by my college director while I was bunking the class.My query is from Template Class in portion Classes of Object Oriented Programming |
|
Answer» RIGHT CHOICE is (d) template <> CLASS myClass Explanation: The class specialization is creation of EXPLICIT specialization of a generic class. We have to use template<> constructor for this to work. It works in the same WAY as with explicit function specialization. |
|
| 52. |
Can default arguments be used with the template class?(a) Yes, in some special cases(b) Yes, always(c) No, it must satisfy some specific conditions first(d) No, it can’t be doneI have been asked this question by my college professor while I was bunking the class.The question is from Template Class in chapter Classes of Object Oriented Programming |
|
Answer» RIGHT answer is (b) YES, always To explain: The template CLASS can use DEFAULT arguments. This is used to specify the data type to be CONSIDERED if it is not specified while passing to the generic class. The default type will be used. |
|
| 53. |
Which among the following is the proper syntax for the template class?(a) template ;(b) Template ;(c) template T named(T x, T y){}(d) Template T1 named(T1 x, T2 y){}I have been asked this question by my school teacher while I was bunking the class.This key question is from Template Class topic in chapter Classes of Object Oriented Programming |
|
Answer» Correct option is (C) TEMPLATE |
|
| 54. |
A template class can have _____________(a) More than one generic data type(b) Only one generic data type(c) At most two data types(d) Only generic type of integers and not charactersI have been asked this question in my homework.Question is from Template Class topic in section Classes of Object Oriented Programming |
|
Answer» Right option is (a) More than one generic data type |
|
| 55. |
Is it necessary that all the abstract methods must be defined from an abstract class?(a) Yes, depending on code(b) Yes, always(c) No, never(d) No, if function is not used, no definition is requiredI got this question in a job interview.This is a very interesting question from Abstract Class topic in section Classes of Object Oriented Programming |
|
Answer» The correct ANSWER is (b) Yes, always |
|
| 56. |
How many abstract classes can a single program contain?(a) At most 1(b) At least 1(c) At most 127(d) As many as requiredThe question was posed to me in class test.Query is from Abstract Class in division Classes of Object Oriented Programming |
|
Answer» The correct answer is (d) As many as REQUIRED |
|
| 57. |
It is _________________________ to have an abstract method.(a) Not mandatory for an static class(b) Not mandatory for a derived class(c) Not mandatory for an abstract class(d) Not mandatory for parent classThis question was addressed to me in an interview for internship.Asked question is from Abstract Class in portion Classes of Object Oriented Programming |
|
Answer» Right CHOICE is (c) Not mandatory for an abstract class |
|
| 58. |
Can abstract classes have static methods (Java)?(a) Yes, always(b) Yes, but depends on code(c) No, never(d) No, static members can’t have different valuesThe question was posed to me in an interview for internship.I'm obligated to ask this question of Abstract Class in section Classes of Object Oriented Programming |
|
Answer» The CORRECT option is (a) Yes, always |
|
| 59. |
Abstract class can’t be final in java.(a) True(b) FalseThe question was posed to me in an international level competition.My doubt is from Abstract Class topic in division Classes of Object Oriented Programming |
|
Answer» Right answer is (a) True |
|
| 60. |
The abstract classes in java can _________________(a) Implement constructors(b) Can’t implement constructor(c) Can implement only unimplemented methods(d) Can’t implement any type of constructorI got this question by my college professor while I was bunking the class.My question comes from Abstract Class in chapter Classes of Object Oriented Programming |
|
Answer» The correct option is (a) Implement constructors |
|
| 61. |
Use of pointers or reference to an abstract class gives rise to which among the following feature?(a) Static Polymorphism(b) Runtime polymorphism(c) Compile time Polymorphism(d) Polymorphism within methodsThis question was posed to me in an interview for job.Origin of the question is Abstract Class in section Classes of Object Oriented Programming |
|
Answer» CORRECT choice is (B) Runtime polymorphism Easy explanation - The runtime polymorphism is SUPPORTED by REFERENCE and pointer to an abstract class. This relies upon base class pointer and reference to select the proper virtual function. |
|
| 62. |
Which among the following is an important use of abstract classes?(a) Header files(b) Class Libraries(c) Class definitions(d) Class inheritanceI have been asked this question in a job interview.This interesting question is from Abstract Class in section Classes of Object Oriented Programming |
|
Answer» Right answer is (B) Class Libraries |
|
| 63. |
We ___________________ to an abstract class.(a) Can create pointers(b) Can create references(c) Can create pointers or references(d) Can’t create any reference, pointer or instanceThe question was asked in an online interview.The origin of the question is Abstract Class in division Classes of Object Oriented Programming |
|
Answer» The correct option is (c) Can CREATE pointers or references |
|
| 64. |
Abstract classes can ____________________ instances.(a) Never have(b) Always have(c) Have array of(d) Have pointer ofThis question was posed to me during an interview.I would like to ask this question from Abstract Class topic in portion Classes of Object Oriented Programming |
|
Answer» The correct choice is (a) Never have |
|
| 65. |
Abstract class A has 4 virtual functions. Abstract class B defines only 2 of those member functions as it extends class A. Class C extends class B and implements the other two member functions of class A. Choose the correct option below.(a) Program won’t run as all the methods are not defined by B(b) Program won’t run as C is not inheriting A directly(c) Program won’t run as multiple inheritance is used(d) Program runs correctlyThis question was posed to me in my homework.This key question is from Abstract Class topic in section Classes of Object Oriented Programming |
|
Answer» CORRECT answer is (d) Program runs correctly Easiest explanation - The program runs correctly. This is because even CLASS B is abstract so it’s not mandatory to define all the VIRTUAL functions. Class C is not abstract but all the virtual functions have been IMPLEMENTED will that class. |
|
| 66. |
If a class is extending/inheriting another abstract class having abstract method, then _______________________(a) Either implementation of method or making class abstract is mandatory(b) Implementation of the method in derived class is mandatory(c) Making the derived class also abstract is mandatory(d) It’s not mandatory to implement the abstract method of parent classI had been asked this question in semester exam.The query is from Abstract Class in chapter Classes of Object Oriented Programming |
|
Answer» CORRECT answer is (a) Either implementation of method or making CLASS abstract is mandatory Explanation: Either of the two things MUST be DONE, either implementation or declaration of class as abstract. This is done to ensure that the method intended to be defined by other classes gets defined at EVERY possible class. |
|
| 67. |
If there is an abstract method in a class then, ________________(a) Class must be abstract class(b) Class may or may not be abstract class(c) Class is generic(d) Class must be publicThis question was posed to me in a job interview.My doubt is from Abstract Class in chapter Classes of Object Oriented Programming |
|
Answer» Right option is (a) Class MUST be ABSTRACT class |
|
| 68. |
Can abstract class have main() function defined inside it?(a) Yes, depending on return type of main()(b) Yes, always(c) No, main must not be defined inside abstract class(d) No, because main() is not abstract functionThis question was posed to me in exam.This is a very interesting question from Abstract Class in chapter Classes of Object Oriented Programming |
|
Answer» Correct choice is (B) Yes, always |
|
| 69. |
Which among the following best describes abstract classes?(a) If a class has more than one virtual function, it’s abstract class(b) If a class have only one pure virtual function, it’s abstract class(c) If a class has at least one pure virtual function, it’s abstract class(d) If a class has all the pure virtual functions only, then it’s abstract classI had been asked this question during a job interview.I'm obligated to ask this question of Abstract Class topic in division Classes of Object Oriented Programming |
|
Answer» Correct answer is (c) If a class has at least one PURE VIRTUAL function, it’s ABSTRACT class |
|