What is serialization?
Serialization is the conversion of an object to a series of bytes, so that the object can be easily saved to persistent database or streamed across a communication media. The byte stream can be serialized and converted into original object.
What is the difference between web server and app server?
A Web server exclusively handles HTTP requests, whereas an application server serves business logic to application programs through any number of protocols.
What are difference between final finally and finalize?
final :final keyword is used along the variables in java. If you make variable as final, then it value can't be alerted.
If method is final, then that method can't be overridden.
If a class is final, then that class can't be extended.
finally : finally is used in the Exception handling using try , catch and finally blocks.
finally block has some special features like, finally block will be executed all the time even if the exception is occurred in the method.
finally block is mainly used to close/kill the resources opened in the try or any part of the method body.
finally block wont be called if JVM got killed wanted by using System.exist();
finalize() : finalize() method is called Garbage collection thread to collect the un-referenced java objects and
What is a transient variable in Java?
A transient variable is a variable that may not be serialized. If you don't want some field to be serialized, you can mark that field transient or static.
What are different types of access modifiers?
Access specifiers are keywords that determine the type of access to the member a class.
Public
Protected
Private
Default
What is String Pooling?
Below prints true,
Name 'string pool' comes from the idea that all already defined string are stored in some 'pool' and before creating new String object compiler checks if such string is already defined.As result, both str1 and str2 point to the same object and some little memory saved.
Why String id Immutable?
The mail reason behind the String is immutable is
a) Security - As most of the parameters requried in our dialy life programming such as database connection url, port number, host name, file name supplied to the I/O operation in creating of files, userid and passwords all the above will be declared by String object because, as String is final and cannt be changed in middle of code excution.
b) String Pooling - Name 'string pool' comes from the idea that all already defined string are stored in some 'pool' and before creating new String object compiler checks if such string is already defined
c) Faster - As String variables cannot be manuplated, its hashcode will be one, so it can be retrieved fast every time
Serialization is the conversion of an object to a series of bytes, so that the object can be easily saved to persistent database or streamed across a communication media. The byte stream can be serialized and converted into original object.
What is the difference between web server and app server?
A Web server exclusively handles HTTP requests, whereas an application server serves business logic to application programs through any number of protocols.
What are difference between final finally and finalize?
final :final keyword is used along the variables in java. If you make variable as final, then it value can't be alerted.
If method is final, then that method can't be overridden.
If a class is final, then that class can't be extended.
finally : finally is used in the Exception handling using try , catch and finally blocks.
finally block has some special features like, finally block will be executed all the time even if the exception is occurred in the method.
finally block is mainly used to close/kill the resources opened in the try or any part of the method body.
finally block wont be called if JVM got killed wanted by using System.exist();
finalize() : finalize() method is called Garbage collection thread to collect the un-referenced java objects and
What is a transient variable in Java?
A transient variable is a variable that may not be serialized. If you don't want some field to be serialized, you can mark that field transient or static.
What are different types of access modifiers?
Access specifiers are keywords that determine the type of access to the member a class.
Public
Protected
Private
Default
Below prints true,
String str1="st"+"r";When compiler optimizes your string literals, it sees that both str1 and str2 have same value and thus you need only one string object.
String str2="s"+"tr";
System.out.println(str1==str2);
Name 'string pool' comes from the idea that all already defined string are stored in some 'pool' and before creating new String object compiler checks if such string is already defined.As result, both str1 and str2 point to the same object and some little memory saved.
Why String id Immutable?
The mail reason behind the String is immutable is
a) Security - As most of the parameters requried in our dialy life programming such as database connection url, port number, host name, file name supplied to the I/O operation in creating of files, userid and passwords all the above will be declared by String object because, as String is final and cannt be changed in middle of code excution.
b) String Pooling - Name 'string pool' comes from the idea that all already defined string are stored in some 'pool' and before creating new String object compiler checks if such string is already defined
c) Faster - As String variables cannot be manuplated, its hashcode will be one, so it can be retrieved fast every time
good questions, post more question
ReplyDeletenice set of questions !!!
ReplyDelete