JAva
JAva
JAva
In such case, JVM will create a new string object in normal (non-pool) heap memory,
and the literal "Welcome" will be placed in the string constant pool. The variable s
will refer to the object in a heap (non-pool).
32. Java StringBuffer class is thread-safe i.e. multiple threads cannot access it
simultaneously. So it is safe and will result in an order.
33. The capacity() method of the StringBuffer class returns the current capacity of the
buffer. The default capacity of the buffer is 16. If the number of character increases
from its current capacity, it increases the capacity by (oldcapacity*2)+2.
34. Java StringBuilder class is used to create mutable (modifiable) String. The Java
StringBuilder class is same as StringBuffer class except that it is non-synchronized.
It is available since JDK 1.5.
35. Also, observe that a string literal can also invoke the concat() method .
String s = "India is my ".concat(str);
36. Java String Contains() method does case sensitive search.
37. The contains() method only checks for the presence or absence of a string in
another string.
38. Java String endsWith() method check for case sensitivitiness and also it returns
true if we pass empty string(str.endsWith(“”)) as an argument because every string
ends with “” but if we pass null (str.endsWith(null)) as argument then it returns
false.
39. A thread is a lightweight sub-process, the smallest unit of processing.
Multiprocessing and multithreading, both are used to achieve multitasking. Threads
are independent. Thread class extends Object class and implements Runnable
interface.
40. If you want to make a user thread as Daemon, it must not be started otherwise it
will throw IllegalThreadStateException.
41. The Garbage collector of JVM collects only those objects that are created by new
keyword. So if you have created any object without new, you can use finalize
method to perform cleanup processing (destroying remaining objects).
42. If you make any static method as synchronized, the lock will be on the class not on
object.
43. If parent class constructor throws any checked exception, compulsory child class
constructor should throw the same checked exception as its parent, otherwise code
won’t compile.
44. this() and super() cannot be used in a method. This throws compile time error.
45. If a static method is present in the program then it will be executed first, then main
will be executed.
46. Recursion is always managed by operating system.
47. Type IV JDBC driver is a driver which communicates through Java sockets.