Que- Which syntax among the following is correct for public member functions?
a. public::void functionName(parameters)
b. public void functionName(parameters)
c. public(void functionName(parameters))
d. public:-void functionName(Parameters)
Ans- public void functionName(parameters)
Que- Which syntax is applicable to declare public member functions in C++?
a. public:
b. public()
c. public void
d. public::
Ans- public:
Que- In java, which rule among the following is applicable?
a. Keyword public can't be preceded with all the public members
b. Keyword public must be preceded with all the public members
c. Keyword public must be post mentioned the function declaration
d. Keyword public is not mandatory
Ans- Keyword public must be preceded with all the public members
Que- How many public members are allowed in a class?
a. Only 1
b. At most 7
c. Exactly 3
d. As many as required
Ans- As many as required
Que- Which is not a proper way to access public members of a class?
a. Using object pointer with arrow operator
b. Using object of class in main function
c. Using object of class with arrow operator
d. Using object anywhere in the program
Ans- Using object of class with arrow operator
Que- Which call is correct for public members of a nested class?
a. Can be called from object of enclosing class
b. Can be called within enclosing class only with direct names
c. Direct names should be used for the nested classes
d. Only with help of nested class object pointer
Ans- Can be called from object of enclosing class
Que- 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();
Ans- object.functionName(parameters);
Que- 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 protected inheritance
Ans- Use private inheritance
Que- 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
Ans- Undeclared function error will be produced
Que- 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
Ans- Can access all the member of its class
Que- What is an exception?
a. Problem arising during compile time
b. Problem arising during runtime
c. Problem in syntax
d. Problem in IDE
Ans- Problem arising during runtime
Que- 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
Ans- To prevent abnormal termination of program
Que- 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
Ans- Input given is invalid
Que- 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
Ans- Exception will be produced
Que- Which is the universal exception handler class?
a. Object
b. Math
c. Errors
d. Exceptions
Ans- Exceptions
Que- 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. Other exceptions
Ans- Runtime exceptions and other exceptions
Que- 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
Ans- Try and catch
Que- 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
Ans- As many as required
Que- 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()
Ans- public Char toString()
Que- 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
Ans- An object must be created to catch the exception
Que- 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
Ans- Can be combined into a single catch block
Que- Which symbol should be used to separate the type of exception handler classes in a single catch block?
a. ?
b. ,
c. <
d. |
Ans- |
Que- Which class is used to handle the input and output exceptions?
a. InputOutput
b. InputOutputExceptions
c. IOExceptions
d. ExceptionsIO
Ans- IOExceptions
Que- 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
Ans- To execute a code with each and every run of program
Que- 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
Ans- Both base class and derived class may produce exceptions
Que- 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
Ans- Then catch block of derived class must be defined before base class
Que- 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 executed
Ans- If catch block of base class is written first, derived class catch block can't be reached
Que- The catching of base class exception ___________________________ in jav
a.
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
Ans- Before derived class is not allowed by compiler
Que- 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
Ans- It may give warning but not error
Que- How many catch blocks can a class have?
a. Only 1
b. 2
c. 3
d. As many as required
Ans- As many as required
Que- Since which version of java is multiple exception catch was made possible?
a. Java 4
b. Java 5
c. Java 6
d. Java 7
Ans- Java 7
Que- 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
Ans- Vertical bar
Que- 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
Ans- The catch parameters are final
Que- Which among the following handles the undefined class in program?
a. ClassNotFound
b. NoClassException
c. ClassFoundException
d. ClassNotFoundException
Ans- ClassNotFoundException
Que- 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
Ans- Their respective catch block must be defined
Que- 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 run
Ans- Both the base and derived class catch blocks are important
Que- 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
Ans- Derived class catch should be defined first
Que- 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
Ans- Infinite loops
Que- 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
Ans- Data which is common to all the objects of a class
Que- Which keyword should be used to declare static variables?
a. static
b. stat
c. common
d. const
Ans- static
Que- 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
Ans- Is reflected to all the objects of that class
Que- 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;
Ans- static dataType memberName;
Que- 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
Ans- Must be defined outside the class
Que- 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;
Ans- dataType className :: memberName =value;
Que- 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
Ans- Must be static member functions
Que- 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
Ans- Can be accessed using class name if not using static member function
Que- 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;
Ans- className :: staticDataMember;
Que- Which data members among the following are static by default?
a. extern
b. integer
c. const
d. void
Ans- const
Que- 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
Ans- Only one copy of the data is created
Que- 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
Ans- Using dot or arrow operator
Que- 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;
Ans- className : dataType -> memberName;
Que- 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
Ans- Functions made to maintain single copy of member functions for all objects
Que- 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
Ans- Have access to only the static members of a class
Que- 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
Ans- Can be called using class name
Que- 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;
Ans- className :: functionName;
Que- Which among the following is not applicable for the static member functions?
a. Variable pointers
b. void pointers
c. this pointer
d. Function pointers
Ans- this pointer
Que- 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 Java
Ans- Static member functions can't be virtual
Que- 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 once
Ans- Created and initialized only once
Que- 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 overloaded
Ans- Static member functions can't be overloaded
Que- 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 volatile
Ans- Can't be declared const, volatile or const volatile
Que- Which keyword should be used to declare the static member functions?
a. static
b. stat
c. const
d. common
Ans- static
Que- 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 function
Ans- With declaration inside class and not with definition outside the class
Que- 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 operator
Ans- Single colon
Que- 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 definition
Ans- Even if class object is not created
Que- The static data member _________________
a. Can be mutable
b. Can't be mutable
c. Can't be integer
d. Can't be characters
Ans- Can't be mutable
Que- 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 members
Ans- Those can be initialized within the class
Que- Passing object to a function _______________
a. Can be done only in one way
b. Can be done in more than one ways
c. Is not possible
d. Is not possible in OOP
Ans- Can be done in more than one ways
Que- The object ________________
a. Can be passed by reference
b. Can be passed by value
c. Can be passed by reference or value
d. Can be passed with reference
Ans- Can be passed by reference or value
Que- Which symbol should be used to pass the object by reference in C++?
a. &
b. @
c. $
d. $ or &
Ans- &
Que- If object is passed by value, ________________
a. Copy constructor is used to copy the values into another object in the function
b. Copy constructor is used to copy the values into temporary object
c. Reference to the object is used to access the values of the object
d. Reference to the object is used to created new object in its place
Ans- Copy constructor is used to copy the values into another object in the function
Que- Pass by reference of an object to a function _______________
a. Affects the object in called function only
b. Affects the object in prototype only
c. Affects the object in caller function
d. Affects the object only if mentioned with & symbol with every call
Ans- Affects the object in caller function
Que- Copy constructor definition requires __________________
a. Object to be passed by value
b. Object not to be passed to it
c. Object to be passed by reference
d. Object to be passed with each data member value
Ans- Object to be passed by reference
Que- What is the type of object that should be specified in argument list?
a. Function name
b. Object name itself
c. Caller function name
d. Class name of object
Ans- Class name of object
Que- If an object is passed by value, _________________
a. Temporary object is used in the function
b. Local object in the function is used
c. Only the data member values are used
d. The values are accessible from the original object
Ans- Local object in the function is used