

MCQOPTIONS
Saved Bookmarks
This section includes 916 Mcqs, each offering curated multiple-choice questions to sharpen your Technical Programming knowledge and support exam preparation. Choose a topic below to get started.
251. |
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 function |
Answer» B. Can be called using program name | |
252. |
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 also |
Answer» D. Have direct access to all other class members also | |
253. |
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 programs |
Answer» C. Functions created to define the static members | |
254. |
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; |
Answer» E. | |
255. |
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 operator |
Answer» E. | |
256. |
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 data |
Answer» B. New copy for each object is created | |
257. |
Which data members among the following are static by default? |
A. | extern |
B. | integer |
C. | const |
D. | void |
Answer» D. void | |
258. |
Which among the following is correct syntax to access static data member without using member function? |
A. | className -> staticDataMember; |
B. | className :: staticDataMember; |
C. | className : staticDataMember; |
D. | className . staticDataMember; |
Answer» C. className : staticDataMember; | |
259. |
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 function |
Answer» E. | |
260. |
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 class |
Answer» D. Must not be member function of corresponding class | |
261. |
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; |
Answer» B. dataType className : memberName =value; | |
262. |
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 constructor |
Answer» C. Must be defined in main function | |
263. |
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; |
Answer» D. static dataType memberName; | |
264. |
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 only |
Answer» D. Is constant to that function only | |
265. |
Which keyword should be used to declare static variables? |
A. | static |
B. | stat |
C. | common |
D. | const |
Answer» B. stat | |
266. |
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 method |
Answer» C. Data which is common to all the classes | |
267. |
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 times |
Answer» D. Loop that runs exactly 99 times | |
268. |
Only the base class catch box can handle more than one exception in single block. |
A. | True |
B. | False |
Answer» C. | |
269. |
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 function |
Answer» C. Catch block for both the classes must not be defined | |
270. |
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 program |
Answer» B. Their respective catch blocks are not mandatory | |
271. |
Which among the following handles the undefined class in program? |
A. | ClassNotFound |
B. | NoClassException |
C. | ClassFoundException |
D. | ClassNotFoundException |
Answer» E. | |
272. |
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 used |
Answer» C. The catch parameters are not defined | |
273. |
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. | Modulus |
Answer» B. Hyphen | |
274. |
Since which version of java is multiple exception catch was made possible? |
A. | Java 4 |
B. | Java 5 |
C. | Java 6 |
D. | Java 7 |
Answer» E. | |
275. |
How many catch blocks can a class have? |
A. | Only 1 |
B. | 2 |
C. | 3 |
D. | As many as required |
Answer» E. | |
276. |
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 error |
Answer» D. It always gives compile time error | |
277. |
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 done |
Answer» C. Before derived class is allowed | |
278. |
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 defined |
Answer» B. Then catch block of base class must be defined before the derived class | |
279. |
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 exceptions |
Answer» E. | |
280. |
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 program |
Answer» E. | |
281. |
Which class is used to handle the input and output exceptions? |
A. | InputOutput |
B. | InputOutputExceptions |
C. | IOExceptions |
D. | ExceptionsIO |
Answer» D. ExceptionsIO | |
282. |
Which symbol should be used to separate the type of exception handler classes in a single catch block? |
A. | ? |
B. | , |
C. | – |
D. | | |
Answer» E. | |
283. |
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 block |
Answer» C. Are not possible for a try block | |
284. |
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 exception |
Answer» B. A variable should be created to catch the exception | |
285. |
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() |
Answer» D. public void printStackTrace() | |
286. |
How many catch blocks can a single try block can have? |
A. | Only 1 |
B. | Only 2 |
C. | Maximum 127 |
D. | As many as required |
Answer» E. | |
287. |
There can be a try block without catch block but vice versa is not possible. |
A. | True |
B. | False |
Answer» B. False | |
288. |
Which are the two blocks that are used to check error and handle the error? |
A. | Try and catch |
B. | Trying and catching |
C. | Do and while |
D. | TryDo and Check |
Answer» B. Trying and catching | |
289. |
What are two exception classes in hierarchy of java exceptions class? |
A. | Runtime exceptions only |
B. | Compile time exceptions only |
C. | Runtime exceptions and other exceptions |
D. | Runtime exceptions and other exceptions |
Answer» D. Runtime exceptions and other exceptions | |
290. |
Which is the universal exception handler class? |
A. | Object |
B. | Math |
C. | Errors |
D. | Exceptions |
Answer» E. | |
291. |
If a file that needs to be opened is not found in the target location then _____________ |
A. | Exception will be produced |
B. | Exceptions are not produced |
C. | Exception might get produced because of syntax |
D. | Exceptions are not produced because of logic |
Answer» B. Exceptions are not produced | |
292. |
An exception may arise when _______________ |
A. | Input is fixed |
B. | Input is some constant value of program |
C. | Input given is invalid |
D. | Input is valid |
Answer» D. Input is valid | |
293. |
Why do we need to handle exceptions? |
A. | To prevent abnormal termination of program |
B. | To encourage exception prone program |
C. | To avoid syntax errors |
D. | To save memory |
Answer» B. To encourage exception prone program | |
294. |
What is an exception? |
A. | Problem arising during compile time |
B. | Problem arising during runtime |
C. | Problem in syntax |
D. | Problem in IDE |
Answer» C. Problem in syntax | |
295. |
All the public member functions ___________________ |
A. | Can’t access the private members of a class |
B. | Can’t access the protected members of a class |
C. | Can access only public members of a class |
D. | Can access all the member of its class |
Answer» E. | |
296. |
The function main() must always be public. |
A. | True |
B. | False |
Answer» B. False | |
297. |
If a class have a public member function and is called directly in the main function then ___________________________ |
A. | Undeclared function error will be produced |
B. | Out of memory error is given |
C. | Program gives warning only |
D. | Program shut down the computer |
Answer» B. Out of memory error is given | |
298. |
A derived class object can access the public members of the base class. |
A. | True |
B. | false |
Answer» C. | |
299. |
If public members are to be restricted from getting inherited from the subclass of the class containing that function, which alternative is best? |
A. | Make the function private |
B. | Use private inheritance |
C. | Use public inheritance |
D. | Use public inheritance |
Answer» C. Use public inheritance | |
300. |
Which public function call among the following is correct outside the class, if return type is void (C++)? |
A. | object.void functionName(parameters); |
B. | object.functionName(parameters); |
C. | object.functionName void (parameters) |
D. | object.void functionName(); |
Answer» C. object.functionName void (parameters) | |