InterviewSolution
This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.
| 51. |
Which of the following is a garbage collection technique?(a) Cleanup model(b) Mark and sweep model(c) Space management model(d) Sweep modelI got this question in an international level competition.Origin of the question is Heap and Garbage Collection in division Classes and Methods of Java |
|
Answer» Correct answer is (b) Mark and SWEEP model |
|
| 52. |
Which of the following has the highest memory requirement?(a) Heap(b) Stack(c) JVM(d) ClassI had been asked this question at a job interview.Question is taken from Heap and Garbage Collection in chapter Classes and Methods of Java |
|
Answer» CORRECT ANSWER is (c) JVM For EXPLANATION: JVM is the super SET which contains HEAP, stack, objects, pointers, etc. |
|
| 53. |
Where is a new object allocated memory?(a) Young space(b) Old space(c) Young or Old space depending on space availability(d) JVMThe question was posed to me in quiz.Question is from Heap and Garbage Collection in chapter Classes and Methods of Java |
|
Answer» Correct option is (a) Young space |
|
| 54. |
What would be the behaviour if one parameterized constructor is explicitly defined?(a) Compilation error(b) Compilation succeeds(c) Runtime error(d) Compilation succeeds but at the time of creating object using default constructor, it throws compilation errorThe question was asked in an international level competition.This intriguing question comes from Constructor topic in section Classes and Methods of Java |
|
Answer» The correct OPTION is (d) COMPILATION succeeds but at the time of creating OBJECT using default constructor, it throws compilation error |
|
| 55. |
What is not the use of “this” keyword in Java?(a) Passing itself to another method(b) Calling another constructor in constructor chaining(c) Referring to the instance variable when local variable has the same name(d) Passing itself to method of the same classI had been asked this question in examination.This is a very interesting question from Constructor in division Classes and Methods of Java |
|
Answer» Right choice is (d) Passing itself to method of the same class |
|
| 56. |
Abstract class cannot have a constructor.(a) True(b) FalseI have been asked this question in unit test.My enquiry is from Constructor topic in chapter Classes and Methods of Java |
|
Answer» The correct OPTION is (B) False |
|
| 57. |
What is true about constructor?(a) It can contain return type(b) It can take any number of parameters(c) It can have any non access modifiers(d) Constructor cannot throw an exceptionThis question was posed to me in an international level competition.I would like to ask this question from Constructor topic in section Classes and Methods of Java |
|
Answer» The correct answer is (B) It can take any number of parameters |
|
| 58. |
What is true about protected constructor?(a) Protected constructor can be called directly(b) Protected constructor can only be called using super()(c) Protected constructor can be used outside package(d) protected constructor can be instantiated even if child is in a different packageI got this question during an interview.Question is from Constructor in chapter Classes and Methods of Java |
|
Answer» Right choice is (b) Protected constructor can only be called using SUPER() |
|
| 59. |
What is true about Class.getInstance()?(a) Class.getInstance calls the constructor(b) Class.getInstance is same as new operator(c) Class.getInstance needs to have matching constructor(d) Class.getInstance creates object if class does not have any constructorI have been asked this question in class test.The origin of the question is Constructor topic in chapter Classes and Methods of Java |
|
Answer» The CORRECT ANSWER is (d) Class.GETINSTANCE creates object if class does not have any constructor |
|
| 60. |
What is false about constructor?(a) Constructors cannot be synchronized in Java(b) Java does not provide default copy constructor(c) Constructor can have a return type(d) “this” and “super” can be used in a constructorThis question was addressed to me in examination.I would like to ask this question from Constructor topic in chapter Classes and Methods of Java |
|
Answer» Correct ANSWER is (c) Constructor can have a return type |
|
| 61. |
What is true about private constructor?(a) Private constructor ensures only one instance of a class exist at any point of time(b) Private constructor ensures multiple instances of a class exist at any point of time(c) Private constructor eases the instantiation of a class(d) Private constructor allows creating objects in other classesThis question was posed to me in quiz.Origin of the question is Constructor in portion Classes and Methods of Java |
|
Answer» The correct option is (a) Private CONSTRUCTOR ensures only one instance of a CLASS exist at any point of time |
|
| 62. |
What would be the behaviour if this() and super() used in a method?(a) Runtime error(b) Throws exception(c) compile time error(d) Runs successfullyThe question was posed to me during a job interview.This is a very interesting question from Constructor in portion Classes and Methods of Java |
|
Answer» RIGHT answer is (C) COMPILE time error The EXPLANATION: this() and super() cannot be USED in a method. This throws compile time error. |
|
| 63. |
Which operator is used by Java run time implementations to free the memory of an object when it is no longer needed?(a) delete(b) free(c) new(d) none of the mentionedI got this question in semester exam.My question is based upon Constructors & Garbage Collection topic in portion Classes and Methods of Java |
|
Answer» Correct choice is (d) none of the mentioned |
|
| 64. |
Which function is used toperform some action when the object is to be destroyed?(a) finalize()(b) delete()(c) main()(d) none of the mentionedI had been asked this question in an online quiz.My doubt stems from Constructors & Garbage Collection in division Classes and Methods of Java |
|
Answer» RIGHT choice is (a) FINALIZE() Easiest EXPLANATION: NONE. |
|
| 65. |
Which of the following is a method having same name as that of its class?(a) finalize(b) delete(c) class(d) constructorI have been asked this question in examination.My question is based upon Constructors & Garbage Collection in division Classes and Methods of Java |
|
Answer» The correct choice is (d) CONSTRUCTOR |
|
| 66. |
What is the return type of Constructors?(a) int(b) float(c) void(d) none of the mentionedThe question was asked in semester exam.My enquiry is from Constructors & Garbage Collection topic in division Classes and Methods of Java |
|
Answer» RIGHT answer is (d) none of the mentioned The explanation: CONSTRUCTORS does not have any RETURN TYPE, not even void. |
|
| 67. |
Which keyword is used by the method to refer to the object that invoked it?(a) import(b) catch(c) abstract(d) thisI had been asked this question in an interview.This question is from Constructors & Garbage Collection in section Classes and Methods of Java |
|
Answer» The correct answer is (d) this |
|
| 68. |
What is the return type of a method that does not return any value?(a) int(b) float(c) void(d) doubleThis question was addressed to me in an interview for job.I'd like to ask this question from Introduction To Methods in portion Classes and Methods of Java |
|
Answer» The correct option is (C) VOID |
|
| 69. |
What is the process of defining more than one method in a class differentiated by method signature?(a) Function overriding(b) Function overloading(c) Function doubling(d) None of the mentionedI had been asked this question by my college director while I was bunking the class.My question is based upon Introduction To Methods in section Classes and Methods of Java |
|
Answer» Correct choice is (B) Function overloading |
|
| 70. |
Which of the following is a method having same name as that of it’s class?(a) finalize(b) delete(c) class(d) constructorThe question was posed to me in class test.My question is from Introduction To Methods topic in chapter Classes and Methods of Java |
|
Answer» The CORRECT answer is (d) constructor |
|
| 71. |
Which of these operators is used to allocate memory for an object?(a) malloc(b) alloc(c) new(d) giveThis question was posed to me during an online interview.This interesting question is from Class Fundamentals & Declaring objects topic in chapter Classes and Methods of Java |
|
Answer» The correct choice is (C) new |
|
| 72. |
Which of these statement is incorrect?(a) Every class must contain a main() method(b) Applets do not require a main() method at all(c) There can be only one main() method in a program(d) main() method must be made publicThis question was posed to me in an online quiz.This interesting question is from Class Fundamentals & Declaring objects topic in division Classes and Methods of Java |
|
Answer» Right choice is (a) Every class MUST contain a main() method |
|
| 73. |
Which of the following is a valid declaration of an object of class Box?(a) Box obj = new Box();(b) Box obj = new Box;(c) obj = new Box();(d) new Box obj;This question was addressed to me in a job interview.Query is from Class Fundamentals & Declaring objects topic in portion Classes and Methods of Java |
|
Answer» CORRECT choice is (a) Box OBJ = new Box(); EXPLANATION: None. |
|
| 74. |
Which of these keywords is used to make a class?(a) class(b) struct(c) int(d) none of the mentionedThe question was asked during an interview for a job.My question is from Class Fundamentals & Declaring objects in chapter Classes and Methods of Java |
|
Answer» The CORRECT CHOICE is (a) class |
|