1. What’s the difference between normal methods and constructors? A Constructors must have the same name of the class and can not have a return type. They are called only once, while regular methods can be called whenever required. We cannot explicitly call a constructor.
2. what is the use of packages in java?
A Packages are a way to organize files in java when a project consists of more than one module. It helps in resolving name conflicts when different modules have classes with the same names.
3. What must be the order of catch blocks when catching more than one exception?
A The sub classes must come first. Otherwise it will give a compile time error.
4. How can we call a method or variable of the super class from child class ?
A We can use super.method() or super.variable syntax for this purpose.
5. If you are overriding equals () method of a class, what other methods you might need to override?
A hash Code
6. How can you create your own exception?
A Our class must extend either Exception or its sub class
7. What is serialization?
A Serialization is the process of saving the state of an object.
8. What is de-serialization?
A De-serialization is the process of restoring the state of an object.
9. What is externalizable ?
A It is an interface that extends Serializable. It is having two different methods writeExternal() and readExternal. This interface allows us to customize the output.
10.what is a transient variable?
A transient variable is a variable that may not be serialized.
2. what is the use of packages in java?
A Packages are a way to organize files in java when a project consists of more than one module. It helps in resolving name conflicts when different modules have classes with the same names.
3. What must be the order of catch blocks when catching more than one exception?
A The sub classes must come first. Otherwise it will give a compile time error.
4. How can we call a method or variable of the super class from child class ?
A We can use super.method() or super.variable syntax for this purpose.
5. If you are overriding equals () method of a class, what other methods you might need to override?
A hash Code
6. How can you create your own exception?
A Our class must extend either Exception or its sub class
7. What is serialization?
A Serialization is the process of saving the state of an object.
8. What is de-serialization?
A De-serialization is the process of restoring the state of an object.
9. What is externalizable ?
A It is an interface that extends Serializable. It is having two different methods writeExternal() and readExternal. This interface allows us to customize the output.
10.what is a transient variable?
A transient variable is a variable that may not be serialized.
0 comments:
Post a Comment