Q 11: Why java is a platform-independent language?
The Java source codes are compiled to an intermediate byte code which is furtherinterpreted by JVM to machine code and then executed. The byte code being an
intermediate code is not dependent on the machine. A byte code created by a MAC or
Linux can be easily run by a JVM in Windows and vice versa
Q 12: Explain the life cycle of a thread

Q 13: Difference between StringBuffer and StringBuilder

Q 14: What are the main pillars of Object-Oriented Programming?
1. Class
2. Object
3. Encapsulation
4. Abstraction
5. Inheritance
6. Polymorphism
7. Interface
Q15: Does Java support multiple inheritance?
Q 16: What are the various modifiers available in java?
1. Public
2. Private
3. Protected
4. Default
5. Final
6. Abstract
7. Static
Q 17: Does finally always execute in Java?
Not in all cases1) System.exit()
2) System Crash
Q 18: Does the constructor return any value?
Yes, The constructor implicitly returns the current instance of the class (You can't use anexplicit return type with the constructor).
Q 19: What do you understand by copy constructor in Java?
There is no copy constructor in java. However, we can copy the values from one object to another like a copy constructor in C++. There are many ways to copy the values of one object into another in java. They are:- By constructor
- By assigning the values of one object to another
- By clone() method of Object class
Q 20: What is the static block?
Static block is used to initialize the static data member. It is executed before the main method, at the time of classloading.class A2{
static{
System.out.println("static block is invoked");
}
public static void main(String args[]){
System.out.println("Hello main");
}
}
Output:
static block is invoked
Hello main
Post a Comment
0 Comments