FREE E LEARNING PLATFORM
HOMEEXCEPTIONSOOPSJVMINTRO
 

I.C.S.E Board Java objective questions practise Paper 3 Answers




21. Which is odd in given option

  1. Function
  2. Method
  3. A block of code in {}
  4. Package

Answer : d. Package

22. A function that modifies its parameters is

  1. Virtual function
  2. Pure function
  3. Impure function
  4. None

Answer : impure function
Pure functions : Pure functions take objects and/or primitive data types as arguments but does not modify the objects.Pure functions doesn't have side effects.
Impure Functions: Impure functions change the state of received objects. Impure functions have side effects.

23. The prototype of a function take ( that returns an int and receives an array ) is

  1. Public int take ( int ar [])
  2. Public int take ( int ar )
  3. Public int take ( int int ar [])
  4. None of the above

Answer a. Public int take ( int ar [])

24. Given the code int Change(int p, int q)

  1. Change(10,20)
  2. R = Change(10,20)
  3. Change(10.5, 12. 5 )
  4. None

Answer Change(10,20)

25. Which is odd in given option

  1. Import statement
  2. Function prototype
  3. Signature of a function
  4. Function Declaration

Answer : Import Statement.

26. Which of the following is used to call default contsructor in java

  1. super()
  2. that()
  3. sub
  4. This

Answer : This
Here is given the 6 usage of java this keyword.
this can be used to refer current class instance variable.
this can be used to invoke current class method (implicitly)
this() can be used to invoke current class constructor.
this can be passed as an argument in the method call.
this can be passed as argument in the constructor call.
this can be used to return the current class instance from the method.

27. Which principal in Object Oriented Programming is followed during Java Constructor Overloading

  1. Polymorphism
  2. Encapsulation
  3. Inheritance
  4. None

Answer a. Polymorhism

28. Which is od in the given option

  1. Use of pointers
  2. Dyanmic
  3. Object Oriented
  4. Architectural Neutral

Answer Use of Pointers

29. What is the output if this() and super() is used in the method

  1. Compile Time Error
  2. Run Time Error
  3. Throws Exception
  4. Runs Succesfully

Answer : Compile Time Error
super() as well as this() both are used to make constructor calls. super() is used to call Base class's constructor(i.e, Parent's class) while this() is used to call current class's constructor.
super() is use to call Base class's(Parent class's) constructor.
We can use super() only inside constructor and nowhere else, not even in static context not even inside methods and super() should be first statement inside constructor.
this() is used to call current class's constructor.
We can use this() only inside constructor and nowhere else, not even in static context not even inside methods and this() should be first statement inside constructor.
Important points about this() and super()
We can use super() as well this() only once inside constructor. If we use super() twice or this() twice or super() followed by this() or this() followed by super(), then immediately we get compile time error i.e, we can use either super() or this() as first statement inside constructor and not both.
It is upto you that whether you use super() or this() or not because if we are not using this() or super() then by default compiler will put super() as first statement inside constructor.

29. A constructor is initialized when

  1. There is a constant variable in the class
  2. There is a reference variable in the class
  3. There is an object of another class , and other class doesn't have a default constructor
  4. All the above

Answer All the above

30. In derived class, can the constructor be overloaded

  1. Yes, if the derived class have no constructor
  2. Yes, always
  3. No
  4. Both a and b

Answer no

You may also Find this interesting

Java Set 1

Java Set 2

JAVA Practise Paper Set 1 Answers

JAVA Practise Paper Set 2 Answers

JAVA Practise Paper Set 3 Answers







Leave Comment