Java Classes Interview Questions And Answers
Download Java Classes Interview Questions and Answers PDF
Prepare comprehensively for your Java Classes interview with our extensive list of 76 questions. Each question is designed to test and expand your Java Classes expertise. Suitable for all experience levels, these questions will help you prepare thoroughly. Secure the free PDF to access all 76 questions and guarantee your preparation for your Java Classes interview. This guide is crucial for enhancing your readiness and self-assurance.
76 Java Classes Questions and Answers:
Java Classes Job Interview Questions Table of Contents:
1 :: A stack stores data using first-in, last-out ordering.
A) True
B) False
Yes it is true ... Stack works on the Startegy of First In First Out
Read More2 :: The type of data returned by a method need not be compatible with the return type specified by the method
A) True
B) False
Explanation: The type of data returned by a method must be compatible with the return type specified by the method. For example, if the return type of some method is boolean, you could not return an integer
A) its False
The return type must be compatible
Read MoreA) its False
The return type must be compatible
3 :: This can be used inside any method to refer to the current object
A) True
B) False
Answer is False and i got it wrong inspite of being correct!!
Explanation:
this cannot be used within a static method. It can be used only within non-static methods.So the question asks whether it can be used inside any method......
Read MoreExplanation:
this cannot be used within a static method. It can be used only within non-static methods.So the question asks whether it can be used inside any method......
4 :: In System.out.println() explain it.My doubt, we call static method with Class name but here what is "out"?
Actually System is class define in java.lang package...
class System{ //Member variables... static PrintStream out;
.................................
//Member methods...
.................
}
so out is a static reference of PrintStream class,which is define in java.io package and println() is a method of PrintStream class...
So ultimately, we can call println() method of static out reference of System class.
Syste.out.println();
Read Moreclass System{ //Member variables... static PrintStream out;
.................................
//Member methods...
.................
}
so out is a static reference of PrintStream class,which is define in java.io package and println() is a method of PrintStream class...
So ultimately, we can call println() method of static out reference of System class.
Syste.out.println();
5 :: What is the difference between instantiation & initialization?
Instance ation will not allocate memory, just a instance will be created.
Initialization will actually allocate memory.
Read MoreInitialization will actually allocate memory.
6 :: If the method does not return a value, its return type must be void
A) True
B) False
It's true. If a method is not returning any value then we must have to specify it's return type as void.void indicates that method is not returning any value.
Read More7 :: In this example class-var = new classname( ); The class name followed by parentheses specifies the _________ for the class
A) Variables
B) Constructor
C) Objects
D) Memory
Constructor
Read More8 :: Methods declared as static have several restrictions:1) They can only call other static methods.2) They must only access static data.3) They cannot refer to this or super in any way Which of these are TRUE?
A) 1 and 2
B) 1 and 3
C) 2 and 3
D) 1, 2 and 3
Ans is :(c)
b'coz static methods can call static as well as non static methods.
Read Moreb'coz static methods can call static as well as non static methods.
9 :: Stacks are controlled through two operations traditionally called ___ and _____
A) Push and Pull
B) Push and Pop
C) Pop and Pull
D) Pop and Peep
Ans is :(B)push and pop
Push :Push is used to insert elements in the stack.
Pop : Pop is used to extract elements from the stack.
Read MorePush :Push is used to insert elements in the stack.
Pop : Pop is used to extract elements from the stack.
10 :: In Java it is possible to define two or more methods within the same class that share the same name, as long as their parameter declarations are different
A) True
B) False
Yes it is True ...
In Java we can have to or more classes with the same name but the parameter list should be Different ... This Concept is called
Method Overloading or Function Overloading
In C++ we have the same Concept too ..
Read MoreIn Java we can have to or more classes with the same name but the parameter list should be Different ... This Concept is called
Method Overloading or Function Overloading
In C++ we have the same Concept too ..
11 :: Suppose I have a rtf file generated out of jasper report.I want to print this file.I tried using Runtime.getRuntime().exec.
But, it is not printing.
My questions are: How to print the file and how do I specify the path of the file for printing?
Please share your answers.
Read More12 :: Tell me is it ok to say interfaces, classes are of polymorphism(i.e we can use those for different purposes). if not then why?
Inorder to reduce memory space and accessing the class members without instanciate Object is the Interface which will contain only abstract methods
Read More13 :: Explain why the StringBuffer and the wrapper classes defined as final?
By defining a class as final we are restricting the one of the main feature of OOP ie., INHERITANCE. But JavaSoft(SUN) has provided this restricting feature because Java Developers thought that some methods cannot be modified by the users. Eg. for those are the methods in String , StringBuffrer ,StringBuilder , all Wrapper classes. As String is a standard class those methods should be as they are as developed by Sun. The user can not be permitted to change the functionality of those methods. If your application needs this type of situation u can decalre your class as final.
The user can't implement the method toUppercase( ) in String class as that it can convert only some of the characters into Uppercase.
Read MoreThe user can't implement the method toUppercase( ) in String class as that it can convert only some of the characters into Uppercase.
14 :: Methods that have a return type other than void return a value to the calling routine using the following form of the return statement:return value;
A) True
B) False
It's TRUE
Read More16 :: What is meant by OO paradigm?
OO paradigm = Object Oriented Paradigm.
This is the basic concept of Object Oriented Languages.It actually means we have to only work out with objects.Communications take place between classes with the help of objects
Ex:- Java,C++ ,But not C(Function Oriented)
Read MoreThis is the basic concept of Object Oriented Languages.It actually means we have to only work out with objects.Communications take place between classes with the help of objects
Ex:- Java,C++ ,But not C(Function Oriented)
17 :: How to load a class from a remote server?
How can classes are loaded from remote server? Don't worry.... please visit the hypelink and will get your ans.... http://java.sun.com/developer/JDCTechTips/2001/tt0227.html#dynamic
Read More18 :: By using finalization, you can define specific actions that will occur when an object is just about to be reclaimed by the garbage collector.
A) True
B) False
True.
Read More20 :: A parameter is a variable defined by a method that receives a value when the method is called.
A) True
B) False
True
Read More21 :: What are static methods?
Static methods dont need class objects to call them where as nonstatic methods needs class objects to call them
Read More22 :: Explain can a abstract class have a constructor? When would the constructor in the abstract class be called?
constructor can not be created in an abstract class.even though we write the constructor, when the constructor will be called..?only if the object is created. but we cannot create an object of abstract class.even though we create object using indirect way, there also, we cannot call the constructor of the abstract class.finally, constructor for the abstract class cannot be called.
Read More23 :: Java does not supports recursion
A) True
B) False
Answer is B) False. Java supports recursion.
Read More24 :: In interfaces the methods just defined without implementation then what is the purpose of defining the methods?
As By giving the Methods(Declaring) in Interface , We are telling to must follow exactly the same Signature for the given Methods. This wil be used when we are writing RMI Applications . Because in this case we just give the Interface to the User, so that user will come to know the Signature of the Method and later he/she will call it.
Read More25 :: The data, or variables, defined within a class are called _______ variables
A) Object
B) Class
C) Instance
D) None of the above
Class variables
Read More