Home Tuitions

chapter-Methods

Important MCQ-Based Questions on Informatics Practices (IP) class 11 chapter-Methods

This page consists of Important MCQ-Based Questions on Informatics Practices (IP) class 11 chapter-Methods all the questions are uploaded for practice with detailed explanations of every question. To check the solution, click on the answer. 

Find below Important MCQ-Based Questions on Informatics Practices (IP) class 11 chapter-Methods

Important Questions for Informatics Practices (IP) class 11 chapter-Methods set-1

Informatics Practices - MCQ on Methods

Class XI

Q.1 A member function with the same name as its class that initialises class objects with legal initial class objects is called

a) construction.

b) destroyer.

c) constructor.

d) temporary object.

Answer:

(c)

Explanation: In object-oriented programming, a constructor in a class is a special block of statements called, when an object is created, either when it is declared or dynamically constructed on the heap through the keyword “new”.

Q.2 A constructor that takes no arguments is known as

a) copy constructor.

b) virtual constructor.

c) default constructor.

d) destructor.

Answer:

(c)

Explanation: A default constructor is a constructor that either has no parameters, or if it has parameters, all the parameters have default values.

Q.3 A constructor with default arguments is equivalent to

 

a) constructor.

b) destructor.

c) default constructor.

d) implicit constructor.

Answer:

(c)

Explanation: A default constructor is a constructor that either has no parameters, or if it has parameters, all the parameters have default values.

Q.4 The constructor which can take values as arguments is known as

a) copy constructor.

b) parameterized constructor.

c) default constructor.

d) destructor.

Answer:

(b)

Explanation: In an object-oriented programming, a constructor in a class is a special block of statements called when an object is created, either when it is declared or dynamically constructed on the heap through the keyword “new”. Parameterized constructors take values as arguments into the constructor function when objects are created.

Q.5 The number of constructors a class can have is

a) one.

b) two.

c) three.

d) many.

Answer:

(d)

Explanation: A class can have a number of constructors: default constructor, parameterized constructor and copy constructor.

Q.5 A constructor is called at the time of

a) beginning of the program.

b) end of the program.

c) execution of the program.

d) deletion of the program.

Answer:

(a)

Explanation: A constructor is called at the beginning of the program when the object is created.

Q.7 Static data members are defined

a) within the class definition.

b) outside the class definition.

c) outside the main ().

d) with static keyword always.

Answer:

(b)

Explanation: A static data member must be defined outside the class definition, as these are stored separately rather than as a part of the object.

Q.8 Constructors do not have a return type because

a) constructor is not a function.

b) constructor de-allocates memory.

c) constructor is called whenever an object is deleted.

d) constructor is called whenever an object gets created.

Answer:

(d)

Explanation: Constructors are called whenever an object gets created and there can never be a situation, when we want to return a value at the time of creation of n object.

Q.9 An object can be created dynamically with the help of keyword

a) dynamic.

b) create.

c) new.

d) fresh.

Answer:

(c)

Explanation: The keyword new allows us to create an object dynamically.

Q.10 In Java programs, the executable instructions are specified through

a) constructors.

b) methods.

c) variables.

d) data types.

Answer:

(b)

Explanation: A method or a function is a sequence of some declaration statements

and executable statements.

Q.11 To cope with complexity in computer programs, we use the technique of

a) divide-and-conquer.

b) modularity.

c) aggregation.

d) segregation.

Answer:

(a)

Explanation: A complex task is divided into smaller tasks. Smaller, more easily understood tasks are implemented as methods.

Q.12 We treat method as a

a) white-box.

b) closed-box.

c) open-box.

d) black-box.

Answer:

(d)

Explanation: We treat method as a black-box, because we accept the result without concern for the details.

Q.13 A method can be called or invoked

a) only once in a program.

b) twice in a program.

c) only thrice in a program.

d) any number of times in a program.

Answer:

(d)

Explanation: It can be called or invoked or accessed more than once in a program, i.e., any number of times, and it can be called from other programs. A method can be reused.

Q.14 In Java, we define a method

a) before using it in the program.

b) after using it in the program.

c) at the same place of using it.

d) in a separate file.

Answer:

(a)

Explanation: The general form of a method definition is:

[access specifier] [modifier] return-type method-name (parameter list)

{

body of the method

}

Q.15 A method can have

a) only one parameter.

b) only two parameters.

c) maximum three parameters.

d) any number of parameters.

Answer:

(d)

Explanation: Parameters are a comma-separated list of variables of a method.

Q.15 The data type used for methods that do not return a value is

a) void.

b) non-void.

c) empty.

d) compound.

Answer:

(a)

Explanation: void data type specifies empty set of values. It is used for methods that do not return a value.

Q.17 A method, that does not expect any argument, is invoked by specifying

a) curly braces.

b) square brackets.

c) empty parenthesis.

d) parameters within braces.

Answer:

(c)

Explanation: volume( );

Here, no arguments are passed in method volume in its call statement.

Q.18 The parameters that appear in method definition are called

a) actual parameters.

b) real parameters.

c) formal parameters.

d) defining parameters.

Answer:

(c)

Explanation: A formal parameter is a variable in method declaration. Its purpose is to store a value while the method is running.

Q.19 The parameters that appear in method call statement are called

a) actual parameters.

b) real parameters.

c) formal parameters.

d) defining parameters

Answer:

(a)

Explanation: The statement that invokes the method is method call statement and actual parameters r arguments appear in method call statement.

Q.20 The function code is given below:

int func( int x, char y, float &z)

{

int a;

char b;

…….

}

Here, x, y and z are

a) actual parameters.

b) real parameters.

c) formal parameters.

d) defining parameters

Answer:

(c)

Explanation: x, y and z appear in a function func definition. Hence, they are formal parameters.

Q.21 A class represents a group of

a) similar objects.

b) different types of objects.

c) different entities.

d) same variables and different data types.

Answer:

(a)

Explanation: A class is a way to bind the data describing an entity and its associated functions together.

Q.22 The function code is given below:

int func( int x, char y, float &z)

{

int a;

char b;

…….

}

Here, a and b are

a) static variables.

b) global variables.

c) class variables.

d) local variables.

Answer:

(d)

The variables that appear inside curly braces, inside a method are local variables.

Q.23 When a method invokes itself, it is called

a) repetition.

b) recursion.

c) redefinition.

d) re-calling a method.

Answer:

(b)

Explanation: In a recursion, a function calls itself within the program text.

Q.24 When a variable is accessible or visible within the function only, it has a

a) global scope.

b) limited scope.

c) local scope.

d) class scope.

Answer:

(c)

Explanation: The scope of the variable is then limited to the function itself.

Q.25 Variables that are declared inside an opening brace and a terminating curly brace are termed as

a) local variables.

b) global variables.

c) class variables.

d) main variables.

Answer:

(a)

Explanation: Local variables are declared inside any function.

Q.25 The changes are not reflected back to the original values in

a) call by reference.

b) pass by reference.

c) call by value.

d) call by name.

Answer:

(c)

Explanation: In call by value, the called method creates a new set of variables, and copies the values of arguments into them. The original copy of the argument value remains intact.

Q.27 When the changes are reflected back to the original values, it is

a) call by reference.

b) pass by value.

c) call by value.

d) call by name.

Answer:

(a)

Explanation: In place of passing a value to the method being called, a reference to the original variable is passed. It does not create its own copy of original values; rather, it refers to the original values only by different names.

Q.28 Math.sqrt() and Math.cos() are examples of

a) manipulative methods.

b) computational methods.

c) procedural methods.

d) special methods.

Answer:

(b)

Explanation: Methods that calculate or compute some value, and return the computed values are computational methods.

Q.29 System.out.println is an example of

a) manipulative methods.

b) computational methods.

c) procedural methods.

d) special methods.

Answer:

(c)

Explanation: Methods that perform an action, and have no explicit return value are procedural methods.

Q.30 The keyword used for storing the address of the current object is

a) current.

b) cur.

c) these.

d) this.

Answer:

(d)

Explanation: this is actually a reference currently calling object.

Q.31 Calling a method is same as

a) method definition.

b) method prototype.

c) method invocation.

d) method declaration.

Answer:

(c)

Explanation: Method invocation means calling or executing a method.

Q.32 Static data members are also called

a) variables.

b) fundamental data types.

c) class variables.

d) abstract data members.

Answer:

(c)

Explanation: Since, static data members are associated with class itself rather than with any class object, they are also known as class variables.

Q.33 When the value being passed in a caller method remain unchanged, we use

a) pass by value.

b) pass by reference.

c) pass by name.

d) call by reference.

Answer:

(a)

Explanation: In call by value, we cannot alter the variables that are used to call the method because any change that occurs inside called method is on the method’s copy of the argument value.

Q.34 A method that is passed as a reference to String object

a) can change the original object.

b) cannot change the original object.

c) can change the original object only once.

d) cannot create new object and store changes.

Answer:

(b)

Explanation: String objects are immutable in Java. This is an exception. Even if, we try to store something in an existing String type object, Java would internally create a new object and store the changes.

Q.35 The region within which a variable is accessible is called

a) restricted region.

b) scope.

c) inside region.

d) outside region.

Answer:

(b)

Explanation: The program part in which a particular piece of code or a data value can be accessed is known as the piece-of-code’s or variable’s scope.

Q.35 When a field is accessible from all the classes, the access modifier used is

a) private.

b) protected.

c) public.

d) friend.

Answer:

(c)

Explanation: When we use the public keyword, it means that the member declaration that immediately follows public is available to everyone, in particular to the client programmer who uses the library.

Q.37 When a field is accessible only within its own class, the access modifier used is

a) private.

b) protected.

c) public.

d) friend.

Answer:

(a)

Explanation:The private keyword means no one can access the member, except the particular class in which it is defined or inside methods of that class.

Q.38 The list of variables in a method declaration are called

a) arguments.

b) actual values.

c) data types.

d) parameters.

Answer:

(d)

Explanation: There can be one parameter, or more parameters in a method declaration statement.

Q.39 The data that can be accessed only through the member functions of that class is

a) public data.

b) private data.

c) public or private data.

d) protected data.

Answer:

(b)

Explanation: Private data is accessible within a class only.

Q.40 Primitive arguments, such as an int or a double are passed into methods by

a) reference.

b) value.

c) name.

d) address.

Answer:

(b)

Explanation: This means that any changes to the values of the parameters exist only within the scope of the method.

Q.41 Reference data types, such as objects, are passed into methods by

a) reference.

b) value.

c) name.

d) address.

Answer:

(b)

Explanation: This means that when the method returns, the passed-in reference still references the same object as before. However, the values of the object's fields can be changed in the method, if they have the proper access level.

Q.42 If we try to return a value from a method that is declared void, we will get a

a) syntax error.

b) correct output.

c) compiler error.

d) run time error.

Answer:

(c)

Explanation: void is used for methods that do not return a value.

Q.43 Fields that have the static modifier in their declaration are called

a) local variables.

b) class variables.

c) instance variables.

d) inner variables.

Answer:

(b)

Explanation: They are associated with class rather than with any object.

Q.44 The final modifier indicates that the value of variable

a) cannot be changed.

b) can be changed.

c) is universal truth.

d) is same in one class and different in another class.

Answer:

(a)

Explanation: The parameters cannot be modified in the method.

Q.45 To pass a reference to the current object as a parameter to other methods, we use

a) current.

b) cur.

c) this.

d) these.

Answer:

(d)

Explanation: It stores the address of the current object.

Q.46 The number of primitive data types available in Java are

a) five.

b) six.

c) seven.

d) eight.

Answer:

(d)

Explanation: Java offers eight primitive data types. These are: byte, short, int, long, float, double, char and boolean.

Q.47 An identifiable entity with some characteristics and behaviour is known as

a) class.

b) object.

c) group.

d) module.

Answer:

(b)

Explanation: An object is a real-world entity that has certain attributes and behaviour.

Q.48 The data that can be accessed by the non–member functions through the objects of that class is

a) protected data.

b) private data.

c) public data

d) local data.

Answer:

(c)

Explanation: Public data is accessible even outside the class.

Q.49 The data members that are usually maintained to store values common to the entire class are

a) non-static members.

b) static data members.

c) initialised members.

d) abstract members.

Answer:

(b)

Explanation: A static data member is globally available for all the objects of that class type.

Q.50 The actual values that are passed in when a method is invoked are called

a) arguments.

b) actual values.

c) data types.

d) Parameters.

Answer:

(a)

Explanation: When we invoke a method, the arguments used must match the declaration’s parameters in type and order.

Q.51 A function call is given below:

func( 4* 5, ‘G’, s)

Here, 4, 5 and s are

a) actual parameters.

b) real parameters.

c) formal parameters.

d) defining parameters

Answer:

(a)

Explanation: 4, 5 and s are present in the function func call. Hence, they are actual parameters, or arguments.

Q.52 The number of copies of static data member maintained for the entire class

a) is only one.

b) are two copies.

c) can be many.

d) are only 3 copies.

Answer:

(a)

Explanation: There is only one copy maintained for the entire class, which is shared by all the objects of that class.

Q.53 Static data members are declared

a) within the class definition.

b) outside the class definition.

c) outside the main().

d) with virtual keyword always.

Answer:

(a)

Explanation: For making a data member static, the declaration is done within the class definition always.

Q.54 Variables of primitive data types are

a) passed by value.

b) passed by reference.

c) passed by name.

d) passed by creating objects.

Answer:

(a)

Explanation: Primitive data types include char, byte, short, int, long, float, double and boolean.

Q.55 The number of times the error value can be returned from a constructor is

a) one.

b) two.

c) never.

d) infinite.

Answer:

(c)

Explanation: An error value can never be returned from a constructor. However, when a runtime error occurs, an exception can be thrown from within a constructor.

Q.55 While manipulating objects for user programs, the internal pointer that points to the current object being operated upon, is called

a) this pointer.

b) pointer.

c) friend function.

d) abstraction.

Answer:

(a)

Explanation: Whenever a member function of an object is called, the compiler places the address of the object in pointer “this” before invoking the function.

Q.57 The number of access labels provided by class are

a) one.

b) two.

c) three.

d) four.

Answer:

(c)

Explanation: There are three access labels provided by the class: private, protected and public.

Q.58 The other name for static variable is

a) class variable.

b) instance variable.

c) local variable.

d) global variable.

Answer:

(a)

Explanation: A static variable is also called class variable because there is only one copy of it for all objects of the class.

Q.59 Method prototype is another name for

a) method definition.

b) method call.

c) method declaration.

d) invoking method.

Answer:

(c)

Explanation: method declaration is the statement that declares a method’s name, return type, number and type of its arguments.

Q.60 A method declaration plus the statements in the body of the method is

a) method definition.

b) method call.

c) invoking method.

d) method prototype.

Answer:

(a)

Explanation: Method declaration comprises the method’s name and the parameter types.

The general form of a method definition is:

[access specifier] [modifier] return-type method-name (parameter list)

{

body of the method

}

Q.61 The other name for a static method is

a) instance method.

b) class method.

c) local method

d) global method.

Answer:

(b)

Explanation: A static method is also called a class method because it can be invoked through the class name, without explicitly creating an object of that class.

Q.62 The objects which are immutable in Java are

a) array objects.

b) class objects.

c) char objects.

d) string objects.

Answer:

(d)

Explanation: In Java, once string objects are created, they cannot be changed. That is why, even though Strings are passed by reference, they cannot be changed.

Q.63 There is only one copy for each instantiated object in a/an

a) class variable.

b) static variable.

c) instance variable.

d) global variable.

Answer:

(c)

Explanation: In a static variable, there is only one copy for all objects of the class, whereas in instance variables, there is a separate copy for each instantiated object.

Q.64 A Java keyword used to create an instance of a class is

a) return.

b) new.

c) void.

d) empty.

Answer:

(b)

Explanation: The new operator returns a reference to a newly created object.

Q.65 A Java keyword used to finish the execution of a method is

a) return.

b) new.

c) void.

d) empty.

Answer:

(a)

Explanation: The return statement tells Java that this method is finished and to return a value of zero to MS-DOS or Windows OS.

Q.65 A method which can be called by any subclass within its class, but not by unrelated classes is

a) private method.

b) public method.

c) protected method.

d) special method.

Answer:

(c)

Explanation: Declaring a method protected defines its access level.

Q.67 In Java, the arguments are passed by

a) value only.

b) reference only.

c) both value and by reference.

d) name.

Answer:

(c)

Explanation: The two ways of invoking methods are: Pass by Value and Pass by Reference.

Q.68 The number of main() methods present in a Java program is

a) 0.

b) 1.

c) 2.

d) 3.

Answer:

(b)

Explanation: Every Java program must have one main method. It is the first method, which the Java Virtual machine executes.

Q.69 The variables that hold their value throughout the execution of the program, are

a) local variables.

b) instance variables.

c) inner variables.

d) global variables.

Answer:

(d)

Explanation: They are the variables that are known throughout the program and may be used by any part of the program.

Q.70 Anything that is visible or tangible is

a) a method.

b) a class.

c) an object.

d) an instance.

Answer:

(c)

Explanation: An object is an identifiable entity with some characteristics.

Q.71 A construct that defines objects of the same type is called a/an

a) class.

b) object.

c) method.

d) data field.

Answer:

(a)

Explanation: A class represents a set of similar objects. It is a user-defined data type that is used to implement an abstract object.

Q.72 An object is an instance of a

a) program.

b) class.

c) method.

d) data.

Answer:

(b)

Explanation: Once a class is available; we can create many objects that have the same structure and behaviour. If we create two objects, they are instances of the same class.

Q.73 A method that is associated with an individual object is called a/an

a) static method.

b) class method.

c) instance method.

d) object method.

Answer:

(c)

Explanation: An instance method is a method, which is associated with one object and uses the instance variables of that object.

Q.74 Every letter in a Java keyword is in

a) uppercase.

b) underline.

c) bold.

d) lowercase.

Answer:

(d)

Explanation: Keywords are in lowercase and reserved. Lowercase is used for variable and method names.

Q.75) Object’s behaviour is implemented through

a) methods.

b) variables.

c) data items.

d) objects.

Answer:

(a)

Explanation:Behaviour of the objects is implemented through functions called methods.

Q.75 Method that will immediately stop a program is

a) System.gc().

b) System.exit( 0 ).

c) System.setErr().

d) return().

Answer:

(b)

Explanation: The code System.exit(0, blindly terminates the application.

Q.77 The number of access specifiers available are

a) 1.

b) 2.

c) 3.

d) 4.

Answer:

(c)

Explanation: Access specifiers can either be public, private or protected.

Q.78 final is a type of

a) access specifier.

b) return_type.

c) modifier.

d) method-name.

Answer:

(c)

Explanation: A final method means that the functionality defined inside this very method can never be changed.

Q.79 native, synchronised, transient and volatile are examples of

a) modifier.

b) access specifier.

c) return_type.

d) method-name.

Answer:

(a)

Explanation: public, private and protected are the access specifiers in Java. final, native, synchronised, transient and volatile are the modifiers available in Java.

Q.80 A Java program can have

a) one class only.

b) two classes only.

c) three classes only.

d) many classes.

Answer:

(d)

Explanation: A Java program can have many classes and each class can have several methods.

Q.81 The details like number, type of arguments and the type of return values are given by

a) method prototype.

b) method call.

c) method signature.

d) method invoking statement.

Answer:

(a)

Explanation: A method prototype describes the method interface to the compiler by giving these details. It is the first line of the method definition.

Q.82 A method signature refers to the

a) number of arguments only.

b) types of arguments only.

c) number and types of arguments only.

d) number and types of arguments and type of return values.

Answer:

(c)

Explanation: It is a part of method prototype. Method signature and return type makes a method’s prototype.

Q.83 The syntax of using void keyword is

a) void method’s-name(parameter list);

b) void(parameter list)method’s name;

c) (parameter list)method’s name void;

d) void(parameter list)method’s name

Answer:

(a)

Explanation: void is used when a method does not return a value and every Java statement ends with a semicolon(;).

Q.84 Objects and arrays are examples of

a) primitive data types.

b) reference data types.

c) old data types.

d) new data types.

Answer:

(b)

Explanation: A reference data type is a variable that can contain the reference or an address of dynamically created object.

Q.85 A reference stores a/an

a) value of a variable.

b) memory location of a variable.

c) variable itself.

d) multiple variables.

Answer:

(b)

Explanation: The address of an object or array is stored in a variable in a reference data type.

Q.85 The other name for reference data types are

a) primitive data types.

b) compound data types.

c) non-primitive data types.

d) secondary data types.

Answer:

(c)

Explanation: The non-primitive data types in Java are objects and arrays.

Q.87 The access specifier which is accessible only within its package and subclasses is

a) protected.

b) private.

c) public.

d) default.

Answer:

(a)

Explanation: Only the class and the derived classes can access the members declared as protected.

Q.88 To declare which entity cannot be accessed from where, we use

a) variables.

b) scope.

c) access specifiers.

d) modifiers.

Answer:

(c)

Explanation: In Java code, class and variable and method and constructor declarations can have “access specifiers”, that is one of: private, protected and public.

Q.89 Procedures, subprograms or subroutines are another name for

a) methods.

b) classes.

c) objects.

d) constructors.

Answer:

(a)

Explanation: A method or function is a sequence of some declaration statements and executable statements.

Q.90 The methods that return a success or failure are

a) computational methods.

b) manipulative methods.

c) procedural methods.

d) binary methods.

Answer:

(b)

Explanation: These methods manipulate information and return a success or failure code.

If value 0 is returned, it denotes success.

Q.91 Data declared at the class level can be used

a) only within one method in the class.

b) within that class or outside that class.

c) in every class in the program.

d) by all the methods in that class.

Answer:

(d)

Explanation: When we declare data within a method, we can use it only in that method.

If we declare data at class level, it can be accessed by all the methods inside that class.

Q.92 Variables declared in exterior blocks are

a) not visible to interior blocks.

b) visible to the interior blocks as well as exterior blocks.

c) visible only in exterior blocks and not visible in interior blocks.

d) neither visible in exterior blocks nor in interior blocks.

Answer:

(b)

Explanation: Variables declared in interior blocks are not visible outside that block, whereas variables declared in exterior blocks are visible to the interior blocks.

Q.93 Methods that perform an action and have no explicit return value are

a) computational methods.

b) manipulative methods.

c) procedural methods.

d) binary methods.

Answer:

(c)

Explanation: If a method returns no value, it is declared as void. Example of a procedural method is System.out.println(), which performs the job of printing something.

Q.94 Methods in Java have

a) same name as class name.

b) no return type.

c) only void as return type.

d) void or a valid return type.

Answer:

(d)

Explanation: Constructors have no return type, but methods in Java can have a valid return type. Methods use a return statement to return a value or use void, if it does not return a value.

Q.95 The purpose of using methods in Java is to

a) create an instance of a class.

b) group Java statements.

c) create objects.

d) initialize objects.

Answer:

(b)

Explanation: Methods are the executable instructions in Java. It is a sequence of some declaration statements and executable statements.

Q.95 In Java, methods reside in

a) objects.

b) constructor

c) program.

d) classes.

Answer:

(d)

Explanation: Methods are a group of program statements. They are defined inside classes.

Q.97 The return type that a constructor method has is

a) void.

b) empty.

c) null, means no return type.

d) non-void.

Answer:

(c)

Explanation: A constructor does not have any return type, not even void.

Q.98 One method, many definitions is called

a) method enlargement.

b) method loading.

c) method extras.

d) method overloading.

Answer:

(d)

Explanation: In method overloading, the method definition has different number or different types of parameters.

Q.99 When passing an argument for a primitive type, a copy of the argument’s

a) value is passed.

b) reference is passed.

c) address is passed.

d) index is passed.

Answer:

(a)

Explanation: The actual argument cannot be changed inside the method. A copy of the argument’s value is passed, so the changes are not reflected back to the original values.

Q.100 Generally, a constructor should be defined as

a) private.

b) protected.

c) default.

d) public.

Answer:

(d)

Explanation: A constructor should be defined as public, so that its objects can be created in any method.