chapter-Java
Important MCQ-Based Questions on Informatics Practices (IP) class 11 chapter-Java
This page consists of Important MCQ-Based Questions on Informatics Practices (IP) class 11 chapter-Java 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-Java
Important Questions for Informatics Practices (IP) class 11 chapter-Java set-1
Informatics Practices - MCQ on In Java
Class XI
Q.1 The data types based on fundamental data types, are known as
a) composite data types.
b) primitive data types.
c) complex data types.
d) simple data types.
Answer:
(a)
Explanation: Java offers eight primitive data types. The data type that we create using primitive data types are composite data types. Since, these are created by users, these are also known as user-defined data types.
Q.2 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.3 The other name for primitive data types is
a) user-defined data types.
b) complex data types.
c) built-in data types.
d) composite data types.
Answer:
(c)
Explanation: A built-in–data type is a fundamental data type that the database server defines. It is also called primitive data type.
Q.4 byte, short, int are examples of
a) user-defined data types.
b) complex data types.
c) built-in data types.
d) composite data types.
Answer:
(c)
Explanation: Java offers eight primitive data types. These are: byte, short, int, long, float, double, char, and boolean.
Q.5 A class is a
a) primitive data type.
b) built-in data type.
c) complex data type.
d) user-defined data type.
Answer:
(d)
Explanation: A class is a user-defined composite data type. All reference types can be referred to composite data types.
Q.5 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.7 The process of creating an object is called
a) object creation.
b) object formation.
c) instantiation.
d) instant object.
Answer:
(c)
Explanation: An object is an instance of a class. It is the root of class hierarchy and the process of creating it, is called instantiation.
Q.8 Usually, the data and member functions in a class are
a) public and private.
b) public.
c) private.
d) private and public.
Ans. d)
Explanation: The data within a class is private i.e. the data is hidden so that it will be safe from accidental manipulation. The functions are public, so that they can be accessed from outside the class.
Q.9 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.10 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.11 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.12 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) initialized members.
d) abstract members.
Answer:
(b)
Explanation: A static data member is globally available for all the objects of that class type.
Q.13 The size of a composite data type depends upon
a) all of its constituent members.
b) only one constituent member.
c) the compiler.
d) the calling arguments.
Answer:
(a)
Explanation: It is generally the total of all sizes of its constituent members.
Q.14 The sizes of primitive data types are
a) not fixed.
b) variable.
c) equal to null.
d) fixed.
Answer:
(d)
Explanation: byte, short, int, long, boolean are examples of primitive data types. These have fixed sizes.
Q.15 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.15 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.17 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.18 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.19 A static member function can access
a) static members of the same class only.
b) static members of any class.
c) static and non-static members of the same class.
d) static and non-static members of any class.
Answer:
(a)
Explanation: A member function that accesses only the static members of a class may be declared as static.
Q.20 If we declare the object of a particular class type and the class does not have a constructor, then
a) it would be compiler error.
b) default constructor gets called automatically.
c) default constructor has to be called explicitly.
d) it would give a run time error.
Answer:
(b)
Explanation: When no constructor is present in the class, the compiler builds an implicit constructor.
Important Questions for Informatics Practices (IP) class 11 chapter-Java set-2
Q.21 The body of the class is terminated by
a) colon.
b) comma.
c) semicolon.
d) curly braces.
Ans . d)
Explanation: The body of a class is started and delimited by curly braces.
Q.22 Private members of a class are available to
a) only members outside the class.
b) only members of the class.
c) members of a program.
d) members of a package.
Answer:
(b)
Explanation: Any member having private keyword is accessible to members within the class.
Q.23 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.24 The number of access labels provided by the 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.25 Reusability of classes is one of the major characteristics of OOPS. It is implemented through
a) polymorphism.
b) inheritance.
c) data abstraction.
d) encapsulation.
Answer:
(b)
Explanation: Inheritance is the property by which derived class inherits the characteristics and properties of base class.
Q.25 The size of user-defined data types is
a) fixed.
b) variable.
c) equal to null.
d) equal to 2 bytes.
Answer:
(b)
Explanation: The size of user-defined data type depends on all of its constituent member variables. Hence, it is variable.
Q.27 The Java operator which is used to create a new object is
a) create operator.
b) create object operator.
c) new operator.
d) create obj operator.
Answer:
(c)
Explanation: new operator creates a new object and allocates space for it.
Q.28 An empty reference is known as
a) null reference.
b) open reference.
c) closed reference.
d) object reference.
Answer:
(a)
Explanation: We can create a null reference by dereferencing a null pointer.
Q.29 Declaring an object variable will
a) create a new object.
b) allocate memory to the object.
c) instantiate an object.
d) not create a new object.
Answer:
(d)
Explanation: Declarations do not create new objects. It just declares a variable.
Q.30 To create an object we need to
a) declare the object variable.
b) initialize an object.
c) instantiate an object using a new operator.
d) instantiate an object by passing constructor arguments.
Answer:
(c)
Explanation: The new operator instantiates a class by allocating memory for a new object.
Q.31 Objects receive their storage from the
a) stack.
b) heap memory.
c) pool memory.
d) static memory.
Answer:
(b)
Explanation: It is simply a memory pool area managed by Java Interpreter to create objects dynamically.
Q.32 When objects are dynamically created, they are created during
a) program execution.
b) program compilation.
c) program creation.
d) instance creation.
Answer:
(a)
Explanation: During program run or program execution, objects are dynamically created.
Q.33 To initialize an object, initial values are passed as
a) object’s arguments.
b) method’s arguments.
c) constructor’s argument.
d) class arguments.
Answer:
(c)
Explanation: Constructor is a method having same name as that of the class, and is used to initialize an object as soon as it is created.
Q.34 A method having the same name as that of the class is called
a) identity method.
b) same method.
c) class method.
d) constructor.
Answer:
(d)
Explanation: A constructor is used to initialize an object as soon as it is created, and has same name as that of the class.
Q.35 The operator used to refer to members of an object is
a) dot (.) operator.
b) reference operator.
c) relational operator.
d) this operator.
Answer:
(a)
Explanation: dot operator is used in the following format as objectreference.membername.
Q.35 The arguments are passed by value when
a) the changes occurring during the called function’s execution are not to be reflected to the original variables.
b) the default argument value is missing its function call.
c) the entire function call can be assigned to a variable.
d) the function returns a value.
Answer:
(a)
Explanation: The main benefit of call by value method is, that we cannot alter the variables that are used to call the function, because any changes that occurs inside function is on the function’s copy of the argument value.
Q.37 When an argument is passed by reference,
a) a variable is created in the function to hold the argument’s value.
b) the function cannot access the argument’s value.
c) a temporary variable is created in the calling program to hold the argument’s value.
d) the function accesses the argument’s original value in the calling program.
Answer:
(d)
Explanation: In call by reference method, a reference to the original variable is passed. A reference is an alias for a predefined variable.
Q.38 The significance of the empty parenthesis in a function declaration is that the
a) function passes actual parameters.
b) function passes formal parameters.
c) function pass informal parameters.
d) function does not pass parameters.
Answer:
(d)
Explanation: A function declared with an empty argument list as void display(); means that the function does not pass any parameters.
Q.39 The difference between a static variable and a static function is that
a) a static variable has a function scope but the static function has a program scope.
b) a static variable has a file scope but the static function has a program scope.
c) a static variable has a function scope but the static function has a file scope.
d) a static variable has a file scope but the static function has a function scope.
Answer:
(c)
Explanation: A static function is a function whose scope is limited to the current source file. A static function has a file scope instead of program scope.
Q.40 When a function returns a value, the entire function can be assigned to
a) constant.
b) variable.
c) entity.
d) register.
Answer:
(b)
Explanation: All the functions except those of type void, return a value. The return statement explicitly specifies this value. When a value is returned, the entire function can be assigned to a variable.
Q.41 The benefit of using functions is
a) reduced program size.
b) non-readable to user.
c) increased ambiguity.
d) complex program handling.
Answer:
(a)
Explanation: Use of function avoids ambiguity. It reduces the program size and thus, makes the program more readable and understandable to the programmer.
Q.42 The variables or values passed to a function are known as
a) parameters.
b) arguments.
c) formal parameters.
d) function call.
Answer:
(b)
Explanation:Actual parameters are the variables or expressions referenced in the parameter list of a subprogram call.
Q.43 The variables that receive the incoming values in a function, are known as
a) actual parameters.
b) formal parameters.
c) functional parameters.
d) global parameters
Answer:
(b)
Explanation: Formal parameters are the variables declared in the parameter list of a subprogram (such as a procedure or a function) specification.
Q.44 Member functions of the class have to be called
a) explicitly.
b) automatically.
c) implicitly.
d) locally.
Answer:
(a)
Explanation: Member functions are used to modify, retrieve or print the data whenever required and hence, are not called automatically.
Q.45 The constructor gets called
a) explicitly.
b) automatically.
c) implicitly.
d) locally.
Answer:
(b)
Explanation: The object creation is a two-step process. Firstly, the memory is allocated and secondly, its data members are initialized. For initialization, constructors are provided which always get called automatically.
Q.45 The difference between constructors and the other member function is
a) constructors cannot be overloaded.
b) constructors have a return type.
c) constructors do not return any value.
d) constructors are called explicitly.
Answer:
(c)
Explanation: Constructors are like other member functions of the class and hence can be overloaded. The only difference is that the constructors do not return any value.
Q.47 Static memory allocation takes place during
a) execution.
b) compilation.
c) linking.
d) initialization.
Answer:
(b)
Explanation: Static memory allocation takes place during compilation, whereas, dynamic memory allocation takes place during execution. For example: int i;
Q.48 Dynamic memory allocation takes place during
a) execution.
b) compilation.
c) linking.
d) initialization.
Answer:
(a)
Explanation: Static memory allocation takes place during compilation, whereas, dynamic memory allocation takes place during execution, when objects are created using new operator.
Q.49 The initialization in which the initial values is provided during runtime is
a) static initialization.
b) dynamic initialization.
c) public initialization.
d) private initialization.
Answer:
(b)
Explanation: In dynamic initialization, the values are assigned to the variables at the time of execution.
Q.50 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”.
Q.51 The number of methods in which the parameterized constructors can pass the value is
a) one.
b) two.
c) three.
d) infinite.
Answer:
(b)
Explanation: Parameterized constructors can pass the values in two ways: by implicit call and by explicit call.
Q.52 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.53 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.54 The new operator requires a call to a/an
a) object.
b) constructor.
c) destructor.
d) pointer.
Answer:
(b)
Explanation: The new operator instantiates a class by allocating memory for a new object.
Q.55 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.55 The size of object of empty class is
a) 0 byte.
b) 1 byte.
c) 2 bytes.
d) 10 bytes.
Answer:
(b)
Explanation: The minimum amount of memory that can be reserved is 1 byte. Hence, the object size turns out to be 1 byte.
Q.57 A function declared within the definition of a class is called
a) data.
b) method.
c) variable.
d) object.
Answer:
(b)
Explanation: A class is a collection of data types and functions, which operate on them. The functions defined within a class are called member functions or methods.
Q.58 A user-defined data type
a) contain main method.
b) do not contain main method.
c) is same as primitive data type.
d) is same as fundamental data type.
Answer:
(b)
Explanation: A user-defined composite data type is different from an application, in the context that it does not contain main method.
Q.59 An application has a class
a) containing main method.
b) that does not contain main method.
c) containing secondary method.
d) that contains instance method.
Answer:
(a)
Explanation: The prototype is public static void main(String args[]).
Q.60 A reference to the current object within an instance method or a constructor is
a) reference keyword.
b) current keyword.
c) class keyword.
d) this keyword.
Answer:
(d)
Explanation: We can refer to any member of the current object from within an instance method by using this keyword.
Q.61 A blue-print defining the characteristics (data items) and behavior(methods) of a set of similar objects is called
a) object.
b) class.
c) instance.
d) data type.
Answer:
(b)
Explanation: Class is a programming language construct that describes the state and behavior of all the objects created.
Q.62 A class encapsulates state through data placeholders called
a) attributes.
b) behavior.
c) methods.
d) objects.
Answer:
(a)
Explanation: A class is an abstraction of a concept within a computer program. It encapsulates state and behavior of the concept, it represents.
Q.63 A class encapsulates behavior through reusable code called
a) attributes.
b) methods.
c) objects.
d) metadata.
Answer:
(b)
Explanation: A class is an abstraction of a concept within a computer program. It encapsulates state and behavior of the concept, it represents.
Q.64 An instance of a class is referred to as
a) method.
b) data.
c) function.
d) object.
Answer:
(d)
Explanation: An object represents an entity with specific characteristics and behavior.
Q.65 The keyword used to call another constructor in the same class, is
a) reference keyword.
b) current keyword.
c) class keyword.
d) this keyword.
Ans. d)
Explanation: We can refer to any member of the current object from within an instance method by using this keyword.
Q.65 When we use this keyword to call another constructor in the same class, it is called
a) implicit constructor invocation.
b) explicit constructor invocation.
c) default constructor invocation.
d) copy constructor invocation.
Answer:
(b)
Explanation: Explicit constructor invocation appears as the first statement in the body of some other constructor.
Q.67 When a number of objects are created from the same class blueprint, they each have their own distinct copies of
a) instance variables.
b) class variables.
c) global variables.
d) static variables.
Answer:
(a)
Explanation: Each object has their own values for these instance variables, stored in different memory locations.
Q.68 If we create a class Bicycle, then cadence, gear, and speed are all
a) global variables.
b) static variables.
c) instance variables.
d) class variables.
Answer:
(c)
Explanation: Each Bicycle
object has its own values for these variables, stored in different memory locations.
Q.69 The variable shared by every instance of the class, which is in one fixed location in memory is called
a) global variable.
b) local variable.
c) instance variable.
d) class variable.
Answer:
(d)
Explanation: Class variables are associated with class rather than objects.
Q.70 The other name for class variable is
a) static variable.
b) global variable.
c) instance variable.
d) object variable.
Answer:
(a)
Explanation: Class variables are common to all objects. They have static modifier in their declaration. Hence, they are called class variables or static variables.
Q.71 If I create a number of Bicycle objects, and assign each a serial number ID, then this ID is a/an
a) class variable.
b) instance variable.
c) global variable.
d) local variable.
Answer:
(b)
Explanation: Since, ID number is unique to every object hence, it is an instance variable.
Q.72 If I create a variable “No of Bicycles” to keep track of how many Bicycle objects are created, then this variable is a/an
a) class variable.
b) instance variable.
c) global variable.
d) local variable.
Answer:
(a)
Explanation: This field is not related to any individual object, but to the class as a whole. Hence, it is a class variable.
Q.73 Instantiating a class means the same thing as
a) initializing a class.
b) initializing an object.
c) declaring an object.
d) creating an object.
Answer:
(d)
Explanation: When we create an object, we are creating an instance of a class.
Q.74 If I create an object car then height, weight, acceleration and top speed are its
a) methods.
b) attributes.
c) functions.
d) classes.
Answer:
(b)
Explanation: Every object is associated with data and functions, which perform meaningful operations on the object. These are the properties or characteristics or attributes of an object.
Q.75 If I create an object car, then drive, move, applying brake are its
a) classes.
b) data.
c) functions.
d) attributes.
Answer:
(c)
Explanation: These are the functions which can be performed on an object.
Q.75 Once a class is declared, we can create and declare variables of this class type, known as
a) final.
b) static.
c) objects.
d) functions.
Answer:
(c)
Explanation: Objects are the basic run-time entities in an object oriented system.
Q.77 If I declare a class Rectangle, then its object can be created through statement
a) Rectangle obj;
b) Rectangle create obj;
c) Rectangle obj=new Rectangle;
d) Rectangle obj=new Rectangle();
Answer:
(d)
Explanation: The correct syntax is classname objectname =new classname();
Q.78 An application has a class containing method with the prototype
a) public static void main(String args[]).
b) private static void main(String args[]).
c) public static void main(String).
d) public static void main(args String).
Ans. a) Explanation: This is the correct declaration: public static void main(String args[])
Q.79 Declaring a reference variable
a) creates an object.
b) does not create an object.
c) create a class.
d) initialize an object.
Answer:
(b)
Explanation: When we declare a reference variable, it tells the compiler to use that variable to refer to the given object. It does not create a new object.
Q.80 The new operator invokes the
a) object constructor.
b) object destructor.
c) class constructor.
d) class destructor.
Answer:
(a)
Explanation: The new operator returns a reference to the object it created, and also invokes the object’s constructor.
Related Links
- chapter-Hardware Concepts
- chapter-Software Concepts
- chapter-Getting Started with Programming using IDE
- chapter-Programming Fundamentals
- chapter-Java
- chapter-DBMS Concepts
- chapter-Introduction to MySQL
- chapter-Simple Queries in SQL
- Chapter-MySQL Functions
- chapter-Table Creation and Data Manipulation Commands
- chapter-IT Applications
- chapter-Flow Of Control
- chapter-Java GUI Programming Using Swing-II
- chapter-Java GUI Programming Using Swing-I
- chapter-Java GUI Programming Using Swing-III
- chapter-Methods