JAVA Classes and Methods Mcqs
Our collections of Multiple choice questions and answers focuses on study of Java Classes and Methods . These questions are chosen from a collection of most authoritative and best reference books on Java Classes and Methods. Our aim is to prepare an individual for competitive exams like NTS, GAT, ECAT, University and College entrance exams and various tests and job interviews. One should practice our Mcqs to assimilate Java Classes and Methods comprehensively.
Java Programming Mcqs
- Data Types Variables and Arrays Mcqs
- Exception Handling in Java Mcqs
- Interfaces and Packages Mcqs
- Java Classes and Methods Mcqs
- Java Event Handling Mcqs
- Java Inheritance Mcqs
- Java IO and Applets Mcqs
- java lang and java io Mcqs
- Java Language Fundamentals Mcqs
- Java Operators and Control Statements Mcqs
- java utilities Mcqs
- Miscellaneous Topics in Java Mcqs
- Multithreading in Java Mcqs
- Serialization and Networking Mcqs
- Session Management and JSP and Servlet Mcqs
- String Handling
Computer MCQS
Sciences MCQS
2.
What is the process of defining more than one method in a class differentiated by method signature?
Function overriding
Function overloading
Function doubling
None of the mentioned
Answer & Solution
No Solution for this Answer..! Report or Discus this Question
4.
Which method can be defined only once in a program?
Main method
Finalize method
Static method
Private method
Answer & Solution
No Solution for this Answer..! Report or Discus this Question
5.
What is the output of this program?
class box
{
int width;
int height;
int length;
int volume;
void volume(int height, int length, int width)
{
volume = width*height*length;
}
}
class Prameterized_method
{
public static void main(String args[])
{
box obj = new box();
obj.height = 1;
obj.length = 5;
obj.width = 5;
obj.volume(3,2,1);
System.out.println(obj.volume);
}
}
class box
{
int width;
int height;
int length;
int volume;
void volume(int height, int length, int width)
{
volume = width*height*length;
}
}
class Prameterized_method
{
public static void main(String args[])
{
box obj = new box();
obj.height = 1;
obj.length = 5;
obj.width = 5;
obj.volume(3,2,1);
System.out.println(obj.volume);
}
}
0
1
6
25
6.
What is the output of this program?
class equality
{
int x;
int y;
boolean isequal()
{
return(x == y);
}
}
class Output
{
public static void main(String args[])
{
equality obj = new equality();
obj.x = 5;
obj.y = 5;
System.out.println(obj.isequal());
}
}
class equality
{
int x;
int y;
boolean isequal()
{
return(x == y);
}
}
class Output
{
public static void main(String args[])
{
equality obj = new equality();
obj.x = 5;
obj.y = 5;
System.out.println(obj.isequal());
}
}
False
True
0
1
7.
Which keyword is used by the method to refer to the object that invoked it?
Import
Catch
Abstract
This
8.
Which of the following is a method having same name as that of its class?
Finalize
Delete
Class
Constructor
Answer & Solution
No Solution for this Answer..! Report or Discus this Question
9.
Which operator is used by Java run time implementations to free the memory of an object when it is no longer needed?
Delete
Free
New
None of the mentioned
Answer & Solution
No Solution for this Answer..! Report or Discus this Question
10.
Which function is used to perform some action when the object is to be destroyed?
Finalize()
Delete()
Main()
None of the mentioned
Answer & Solution
No Solution for this Answer..! Report or Discus this Question
11.
What is the output of this program?
class box
{
int width;
int height;
int length;
int volume;
box()
{
width = 5;
height = 5;
length = 6;
}
void volume()
{
volume = width*height*length;
}
}
class constructor_output
{
public static void main(String args[])
{
box obj = new box();
obj.volume();
System.out.println(obj.volume);
}
}
class box
{
int width;
int height;
int length;
int volume;
box()
{
width = 5;
height = 5;
length = 6;
}
void volume()
{
volume = width*height*length;
}
}
class constructor_output
{
public static void main(String args[])
{
box obj = new box();
obj.volume();
System.out.println(obj.volume);
}
}
100
150
200
250
12.
What is the output of this program?
class Compsci
{
Compsci()throws IOException
{
}
}
class Bits extends Compsci
{
Bits()
{
}
public static void main(String[]args)
{
}
}
class Compsci
{
Compsci()throws IOException
{
}
}
class Bits extends Compsci
{
Bits()
{
}
public static void main(String[]args)
{
}
}
Compile time error
Run time error
Compile and runs fine
Unreported exception java.io.IOException in default constructor
Answer & Solution
No Solution for this Answer..! Report or Discus this Question
13.
What is true about private constructor?
Private constructor ensures only one instance of a class exist at any point of time
Private constructor ensures multiple instances of a class exist at any point of time
Private constructor eases the instantiation of a class
Private constructor allows creating objects in other classes
Answer & Solution
No Solution for this Answer..! Report or Discus this Question
14.
What would be the behaviour if this() and super() used in a method?
Runtime error
Throws exception
Compile time error
Runs successfully
Answer & Solution
No Solution for this Answer..! Report or Discus this Question
15.
What is false about constructor?
Constructors cannot be synchronized in Java
Java does not provide default copy constructor
Constructor can be overloaded
Answer & Solution
No Solution for this Answer..! Report or Discus this Question
16.
What is true about Class.getInstance()?
Class.getInstance calls the constructor
Class.getInstance is same as new operator
Class.getInstance needs to have matching constructor
Class.getInstance creates object if class does not have any constructor
Answer & Solution
No Solution for this Answer..! Report or Discus this Question