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.
| 1. |
If static data member are made inline, ______________(a) Those should be initialized outside the class(b) Those can’t be initialized with the class(c) Those can be initialized within the class(d) Those can’t be used by class membersThe question was asked in unit test.Question is taken from Static Member Functions topic in portion Exception Handling & Static Class Members of Object Oriented Programming |
|
Answer» Right choice is (C) Those can be initialized WITHIN the class |
|
| 2. |
The static data member _________________(a) Can be mutable(b) Can’t be mutable(c) Can’t be integer(d) Can’t be charactersThe question was asked at a job interview.This intriguing question originated from Static Member Functions in section Exception Handling & Static Class Members of Object Oriented Programming |
|
Answer» Correct ANSWER is (b) Can’t be mutable |
|
| 3. |
We can use the static member functions and static data member __________________(a) Even if class object is not created(b) Even if class is not defined(c) Even if class doesn’t contain any static member(d) Even if class doesn’t have complete definitionThis question was addressed to me during an online exam.The doubt is from Static Member Functions topic in division Exception Handling & Static Class Members of Object Oriented Programming |
|
Answer» CORRECT option is (a) Even if class OBJECT is not created Explanation: The static MEMBERS are property of class as a whole. There is no NEED of specific objects to call static members. Those can be called directly or with class name. |
|
| 4. |
Which among the following can’t be used to access the members in any way?(a) Scope resolution(b) Arrow operator(c) Single colon(d) Dot operatorI had been asked this question during an interview.I need to ask this question from Static Member Functions in portion Exception Handling & Static Class Members of Object Oriented Programming |
|
Answer» Correct answer is (C) Single colon |
|
| 5. |
The keyword static is used _______________(a) With declaration inside class and with definition outside the class(b) With declaration inside class and not with definition outside the class(c) With declaration and definition wherever done(d) With each call to the member functionI have been asked this question in a national level competition.The query is from Static Member Functions topic in section Exception Handling & Static Class Members of Object Oriented Programming |
|
Answer» CORRECT choice is (b) With declaration inside class and not with definition outside the class The best I can explain: The KEYWORD is USED only inside the class while declaring the static member. Outside the class, only definition with proper syntax is given. There is no need of SPECIFYING the keyword static again. |
|
| 6. |
Which keyword should be used to declare the static member functions?(a) static(b) stat(c) const(d) commonThe question was asked in an interview for job.My question comes from Static Member Functions in portion Exception Handling & Static Class Members of Object Oriented Programming |
|
Answer» RIGHT answer is (a) static Easy explanation - The member functions which are to be made static, must be preceded with the keyword static. This INDICATES the compiler to make the functions common to all the objects. And a new COPY is not created with each of the new OBJECT. |
|
| 7. |
The static member functions _______________(a) Can’t be declared const(b) Can’t be declared volatile(c) Can’t be declared const or volatile(d) Can’t be declared const, volatile or const volatileI have been asked this question in my homework.This is a very interesting question from Static Member Functions in portion Exception Handling & Static Class Members of Object Oriented Programming |
|
Answer» Right OPTION is (d) Can’t be DECLARED const, volatile or const volatile |
|
| 8. |
Which among the following is true?(a) Static member functions can be overloaded(b) Static member functions can’t be overloaded(c) Static member functions can be overloaded using derived classes(d) Static member functions are implicitly overloadedThe question was posed to me in class test.The origin of the question is Static Member Functions topic in chapter Exception Handling & Static Class Members of Object Oriented Programming |
|
Answer» The correct choice is (b) Static MEMBER functions can’t be OVERLOADED |
|
| 9. |
The static members are ______________________(a) Created with each new object(b) Created twice in a program(c) Created as many times a class is used(d) Created and initialized only onceThe question was posed to me by my college director while I was bunking the class.This intriguing question comes from Static Member Functions topic in division Exception Handling & Static Class Members of Object Oriented Programming |
|
Answer» Right option is (d) CREATED and initialized only once |
|
| 10. |
Which among the following is true?(a) Static member functions can’t be virtual(b) Static member functions can be virtual(c) Static member functions can be declared virtual if it is pure virtual class(d) Static member functions can be used as virtual in JavaThis question was posed to me in final exam.I'm obligated to ask this question of Static Member Functions in chapter Exception Handling & Static Class Members of Object Oriented Programming |
|
Answer» The correct option is (a) STATIC member FUNCTIONS can’t be virtual |
|
| 11. |
Which among the following is not applicable for the static member functions?(a) Variable pointers(b) void pointers(c) this pointer(d) Function pointersThis question was addressed to me during an interview.My question is based upon Static Member Functions in division Exception Handling & Static Class Members of Object Oriented Programming |
|
Answer» Correct choice is (c) this pointer |
|
| 12. |
Which is correct syntax to access the static member functions with class name?(a) className . functionName;(b) className -> functionName;(c) className : functionName;(d) className :: functionName;The question was asked during an online interview.This question is from Static Member Functions topic in division Exception Handling & Static Class Members of Object Oriented Programming |
|
Answer» Correct option is (d) className :: functionName; |
|
| 13. |
The static member functions ____________________(a) Can be called using class name(b) Can be called using program name(c) Can be called directly(d) Can’t be called outside the functionI had been asked this question during an internship interview.This interesting question is from Static Member Functions topic in portion Exception Handling & Static Class Members of Object Oriented Programming |
|
Answer» The correct choice is (a) Can be called USING class NAME |
|
| 14. |
The static member functions __________________(a) Have access to all the members of a class(b) Have access to only constant members of a class(c) Have access to only the static members of a class(d) Have direct access to all other class members alsoI have been asked this question in class test.This intriguing question originated from Static Member Functions topic in portion Exception Handling & Static Class Members of Object Oriented Programming |
|
Answer» CORRECT answer is (c) Have access to only the static members of a CLASS The explanation is: The static member functions are common for all the objects. These functions can use only the static members of a class in which those are defined. This is because other members CHANGE with respect to each object CREATED. |
|
| 15. |
Which among the following is correct definition for static member functions?(a) Functions created to allocate constant values to each object(b) Functions made to maintain single copy of member functions for all objects(c) Functions created to define the static members(d) Functions made to manipulate static programsI had been asked this question during an online interview.This is a very interesting question from Static Member Functions in chapter Exception Handling & Static Class Members of Object Oriented Programming |
|
Answer» Correct choice is (B) FUNCTIONS made to maintain SINGLE copy of member functions for all objects |
|
| 16. |
Which among the following is wrong syntax related to static data members?(a) className :: staticDataMember;(b) dataType className :: memberName =value;(c) static dataType memberName;(d) className : dataType -> memberName;The question was posed to me in an interview.My doubt stems from Static Data Members topic in chapter Exception Handling & Static Class Members of Object Oriented Programming |
|
Answer» Correct ANSWER is (d) CLASSNAME : dataType -> memberName; |
|
| 17. |
If object of class are created, then the static data members can be accessed ____________(a) Using dot operator(b) Using arrow operator(c) Using colon(d) Using dot or arrow operatorThis question was addressed to me in my homework.My question is taken from Static Data Members topic in portion Exception Handling & Static Class Members of Object Oriented Programming |
|
Answer» Right answer is (d) Using DOT or ARROW OPERATOR |
|
| 18. |
Whenever any static data member is declared in a class ______________________(a) Only one copy of the data is created(b) New copy for each object is created(c) New memory location is allocated with each object(d) Only one object uses the static dataThis question was posed to me in examination.My question is based upon Static Data Members topic in division Exception Handling & Static Class Members of Object Oriented Programming |
|
Answer» RIGHT answer is (a) Only one copy of the data is created The best I can explain: The static data is same for all the objects. Instead of creating the same data each TIME an object is created, the compiler created only one data which is accessed by all the objects of the CLASS. This saves memory and reduces redundancy. |
|
| 19. |
Which data members among the following are static by default?(a) extern(b) integer(c) const(d) voidI had been asked this question in semester exam.The origin of the question is Static Data Members topic in chapter Exception Handling & Static Class Members of Object Oriented Programming |
|
Answer» The correct choice is (c) CONST |
|
| 20. |
Which among the following is the correct syntax to access static data member without using member function?(a) className -> staticDataMember;(b) className :: staticDataMember;(c) className : staticDataMember;(d) className . staticDataMember;This question was addressed to me by my college director while I was bunking the class.I'd like to ask this question from Static Data Members in section Exception Handling & Static Class Members of Object Oriented Programming |
|
Answer» Right choice is (b) className :: staticDataMember; |
|
| 21. |
The static data member __________________________(a) Can be accessed directly(b) Can be accessed with any public class name(c) Can be accessed with dot operator(d) Can be accessed using class name if not using static member functionThis question was addressed to me in an online interview.Enquiry is from Static Data Members in chapter Exception Handling & Static Class Members of Object Oriented Programming |
|
Answer» Right CHOICE is (d) Can be ACCESSED using class name if not using static member function |
|
| 22. |
If static data members have to be used inside a class, those member functions _______________(a) Must not be static member functions(b) Must not be member functions(c) Must be static member functions(d) Must not be member function of corresponding classI had been asked this question in exam.My enquiry is from Static Data Members topic in portion Exception Handling & Static Class Members of Object Oriented Programming |
|
Answer» Right option is (C) Must be static member functions |
|
| 23. |
The syntax for defining the static data members is __________(a) dataType className :: memberName = value;(b) dataType className : memberName = value;(c) dataType className . memberName = value;(d) dataType className -> memberName =value;I had been asked this question in an interview for job.My question is taken from Static Data Members in portion Exception Handling & Static Class Members of Object Oriented Programming |
|
Answer» Correct ANSWER is (a) dataType className :: memberName = value; |
|
| 24. |
The static data member ______________________(a) Must be defined inside the class(b) Must be defined outside the class(c) Must be defined in main function(d) Must be defined using constructorThis question was addressed to me during an online exam.This question is from Static Data Members topic in section Exception Handling & Static Class Members of Object Oriented Programming |
|
Answer» Right option is (b) MUST be defined outside the CLASS |
|
| 25. |
Which is the correct syntax for declaring static data member?(a) static mamberName dataType;(b) dataType static memberName;(c) memberName static dataType;(d) static dataType memberName;I had been asked this question during an interview for a job.The query is from Static Data Members topic in section Exception Handling & Static Class Members of Object Oriented Programming |
|
Answer» The correct choice is (d) static dataType memberName; |
|
| 26. |
Any changes made to static data member from one member function _____________(a) Is reflected to only the corresponding object(b) Is reflected to all the variables in a program(c) Is reflected to all the objects of that class(d) Is constant to that function onlyI had been asked this question in a job interview.This is a very interesting question from Static Data Members topic in division Exception Handling & Static Class Members of Object Oriented Programming |
|
Answer» The CORRECT choice is (C) Is reflected to all the objects of that class |
|
| 27. |
Which keyword should be used to declare static variables?(a) static(b) stat(c) common(d) constThis question was posed to me in an interview for internship.I'm obligated to ask this question of Static Data Members in chapter Exception Handling & Static Class Members of Object Oriented Programming |
|
Answer» CORRECT option is (a) static To explain I would say: The KEYWORD USED to declare static variables is static. This is MUST be used while declaring the static variables. The COMPILER can make variables static if and only if they are mentioned with static keyword. |
|
| 28. |
Which among the following best defines static variables members?(a) Data which is allocated for each object separately(b) Data which is common to all the objects of a class(c) Data which is common to all the classes(d) Data which is common to a specific methodThe question was posed to me at a job interview.I'd like to ask this question from Static Data Members in chapter Exception Handling & Static Class Members of Object Oriented Programming |
|
Answer» The correct option is (b) Data which is common to all the OBJECTS of a class |
|
| 29. |
Which condition among the following might result in memory exception?(a) False if conditions(b) Nested if conditions that are all false(c) Infinite loops(d) Loop that runs exactly 99 timesI got this question in unit test.I want to ask this question from Catching Class Types topic in chapter Exception Handling & Static Class Members of Object Oriented Programming |
|
Answer» The correct answer is (c) Infinite loops |
|
| 30. |
Only the base class catch box can handle more than one exception in single block.(a) True(b) FalseThis question was posed to me in exam.Origin of the question is Catching Class Types in section Exception Handling & Static Class Members of Object Oriented Programming |
|
Answer» Right answer is (B) False |
|
| 31. |
Which is the necessary condition to define the base and derived class catch blocks?(a) Base class catch should be defined first(b) Derived class catch should be defined first(c) Catch block for both the classes must not be defined(d) Catch block must be defined inside main functionThe question was posed to me in final exam.The above asked question is from Catching Class Types in division Exception Handling & Static Class Members of Object Oriented Programming |
|
Answer» The correct choice is (b) Derived CLASS catch should be defined first |
|
| 32. |
Which among the following is true?(a) Only the base class catch blocks are important(b) Only the derived class catch blocks are important(c) Both the base and derived class catch blocks are important(d) If base and derived classes both produce exceptions, program doesn’t runI got this question in homework.Asked question is from Catching Class Types topic in portion Exception Handling & Static Class Members of Object Oriented Programming |
|
Answer» Right option is (c) Both the base and derived class CATCH blocks are important |
|
| 33. |
If classes produce some exceptions, then ______________________(a) Their respective catch block must be defined(b) Their respective catch blocks are not mandatory(c) Their catch blocks should be defined inside main function(d) Their catch blocks must be defined at the end of programI had been asked this question in an interview for internship.The question is from Catching Class Types topic in chapter Exception Handling & Static Class Members of Object Oriented Programming |
|
Answer» Correct choice is (a) Their respective catch BLOCK must be defined |
|
| 34. |
Which among the following handles the undefined class in program?(a) ClassNotFound(b) NoClassException(c) ClassFoundException(d) ClassNotFoundExceptionI had been asked this question in an interview for internship.The above asked question is from Catching Class Types in division Exception Handling & Static Class Members of Object Oriented Programming |
|
Answer» The correct option is (d) ClassNotFoundException |
|
| 35. |
If a catch block accepts more than one exceptions then __________________(a) The catch parameters are not final(b) The catch parameters are final(c) The catch parameters are not defined(d) The catch parameters are not usedI got this question in final exam.Question is from Catching Class Types topic in portion Exception Handling & Static Class Members of Object Oriented Programming |
|
Answer» RIGHT answer is (b) The catch PARAMETERS are final To EXPLAIN: The catch parameters are made final. This is to ensure that the parameters are not changed INSIDE the catch block. Hence those RETAIN their values. |
|
| 36. |
To catch more than one exception in one catch block, how are the exceptions separated in the syntax?(a) Vertical bar(b) Hyphen(c) Plus(d) ModulusThe question was posed to me in an internship interview.I need to ask this question from Catching Class Types topic in portion Exception Handling & Static Class Members of Object Oriented Programming |
|
Answer» CORRECT choice is (a) VERTICAL bar To EXPLAIN I would say: Just the way we separate the ARGUMENTS in a function definition using comma. Here we separate the exceptions by using a vertical bar or we call it pipe symbol SOMETIMES. This is just a convention followed to separate different exception list. |
|
| 37. |
Since which version of java is multiple exception catch was made possible?(a) Java 4(b) Java 5(c) Java 6(d) Java 7This question was addressed to me in an international level competition.This interesting question is from Catching Class Types in division Exception Handling & Static Class Members of Object Oriented Programming |
|
Answer» The correct answer is (d) Java 7 |
|
| 38. |
How many catch blocks can a class have?(a) Only 1(b) 2(c) 3(d) As many as requiredI have been asked this question during an interview.Enquiry is from Catching Class Types in chapter Exception Handling & Static Class Members of Object Oriented Programming |
|
Answer» Correct option is (d) As MANY as required |
|
| 39. |
If catching of base class exception is done before derived class in C++ ________________(a) It gives compile time error(b) It doesn’t run the program(c) It may give warning but not error(d) It always gives compile time errorThis question was posed to me during a job interview.My question is taken from Catching Class Types topic in section Exception Handling & Static Class Members of Object Oriented Programming |
|
Answer» Correct choice is (c) It may give warning but not error |
|
| 40. |
The catching of base class exception ___________________________ in java.(a) After derived class is not allowed by compiler(b) Before derived class is not allowed by compiler(c) Before derived class is allowed(d) After derived class can’t be doneI had been asked this question during an internship interview.I'd like to ask this question from Catching Class Types in chapter Exception Handling & Static Class Members of Object Oriented Programming |
|
Answer» The correct CHOICE is (b) Before derived class is not allowed by compiler |
|
| 41. |
Which among the following is true?(a) If catch block of base class is written first, it is compile time error(b) If catch block of base class is written first, it is run time error(c) If catch block of base class is written first, derived class catch block can’t be reached(d) If catch block of base class is written first, only derived class catch block is executedI got this question in an interview.This interesting question is from Catching Class Types in division Exception Handling & Static Class Members of Object Oriented Programming |
|
Answer» The correct choice is (c) If catch block of base CLASS is WRITTEN FIRST, DERIVED class catch block can’t be reached |
|
| 42. |
If both base and derived class caught exceptions ______________(a) Then catch block of derived class must be defined before base class(b) Then catch block of base class must be defined before the derived class(c) Then catch block of base and derived classes doesn’t matter(d) Then catch block of base and derived classes are not mandatory to be definedThe question was posed to me during a job interview.This key question is from Catching Class Types in section Exception Handling & Static Class Members of Object Oriented Programming |
|
Answer» The correct option is (a) Then catch block of derived class must be DEFINED before base class |
|
| 43. |
Which among the following is true for class exceptions?(a) Only base class can give rise to exceptions(b) Only derived class can give rise to exceptions(c) Either base class or derived class may produce exceptions(d) Both base class and derived class may produce exceptionsThe question was posed to me in a job interview.I would like to ask this question from Catching Class Types topic in chapter Exception Handling & Static Class Members of Object Oriented Programming |
|
Answer» Correct answer is (d) Both BASE class and derived class may PRODUCE exceptions |
|
| 44. |
Why do we use finally block?(a) To execute the block if exception occurred(b) To execute a code when exception is not occurred(c) To execute a code whenever required(d) To execute a code with each and every run of programThe question was asked at a job interview.My enquiry is from Exception Handling topic in portion Exception Handling & Static Class Members of Object Oriented Programming |
|
Answer» The correct choice is (d) To execute a code with each and every run of program |
|
| 45. |
Which class is used to handle the input and output exceptions?(a) InputOutput(b) InputOutputExceptions(c) IOExceptions(d) ExceptionsIOThe question was asked in an interview.The doubt is from Exception Handling in portion Exception Handling & Static Class Members of Object Oriented Programming |
|
Answer» Correct answer is (c) IOExceptions |
|
| 46. |
Which symbol should be used to separate the type of exception handler classes in a single catch block?(a) ?(b) ,(c) –(d) |The question was posed to me in a job interview.My question comes from Exception Handling topic in division Exception Handling & Static Class Members of Object Oriented Programming |
|
Answer» RIGHT CHOICE is (d) | The explanation is: A pipe symbol can be used to separate different type of EXCEPTIONS. The exceptions should always be given in proper sequence to ensure that no code remains unreachable. If not done properly the code might NEVER be used in a program. |
|
| 47. |
Multiple catch blocks __________________(a) Are mandatory for each try block(b) Can be combined into a single catch block(c) Are not possible for a try block(d) Can never be associated with a single try blockI have been asked this question in unit test.My question is based upon Exception Handling in portion Exception Handling & Static Class Members of Object Oriented Programming |
|
Answer» Correct CHOICE is (b) Can be combined into a SINGLE catch block |
|
| 48. |
To catch the exceptions ___________________(a) An object must be created to catch the exception(b) A variable should be created to catch the exception(c) An array should be created to catch all the exceptions(d) A string have to be created to store the exceptionThe question was posed to me in quiz.My enquiry is from Exception Handling in chapter Exception Handling & Static Class Members of Object Oriented Programming |
|
Answer» Correct CHOICE is (a) An object MUST be created to catch the exception |
|
| 49. |
Which among the following is not a method of Throwable class?(a) public String getMessage()(b) public Throwable getCause()(c) public Char toString()(d) public void printStackTrace()This question was posed to me in an internship interview.Enquiry is from Exception Handling topic in division Exception Handling & Static Class Members of Object Oriented Programming |
|
Answer» CORRECT CHOICE is (c) public Char TOSTRING() The best I can explain: Actually all the functions are available in throwable class. But the return type given in the option is WRONG. The function toString RETURNS string value. Hence the return type must be a String and not a char. |
|
| 50. |
How many catch blocks can a single try block can have?(a) Only 1(b) Only 2(c) Maximum 127(d) As many as requiredI have been asked this question in exam.Enquiry is from Exception Handling topic in division Exception Handling & Static Class Members of Object Oriented Programming |
|
Answer» Correct answer is (d) As MANY as required |
|