Term
what is a string in java? |
|
Definition
in java string is a 16 bit character. |
|
|
Term
why are strings immutable in jav? |
|
Definition
jvm sets aside a string constants pool. if a similar string is detected its reference to new string points to old string. saving memory |
|
|
Term
can some one extendthe string class |
|
Definition
nope that si to ensure the immutability of strings remains intact. |
|
|
Term
what is the difference between the implicit creation of strings and the explicit creation? |
|
Definition
in implicit creation just one string object is created in the pool . in explicit both an object in the pool and a object not in the pool are created. |
|
|
Term
what does the first argumetn in substring method represent? |
|
Definition
starting point from where you should substring . This should be a zero based string. |
|
|
Term
what does the second argument in the substring represent? |
|
Definition
the second arg is the ending point based on 1 based counting |
|
|
Term
what does the trim method in the string class do. |
|
Definition
the trim method eliminateds any white spaces in the string. |
|
|
Term
when would you use StringBuffer instead of String class? |
|
Definition
when you will be a lot of modifications on strings so that you dont end up with too many string objects in the pool |
|
|
Term
what is the difference between String and StringBuffer class. |
|
Definition
the String class is immutable. All created objects are left in a pool. StringBuffer is mutalbe and objects are not left in any pool |
|
|
Term
what is one syntatical sugar you can use due to mutability of StringBuffer. |
|
Definition
you can say sb.append("xyz").reverse().insert(3,---) it is called method chaining. |
|
|
Term
what is the output of StringBuffer sb = new StringBuffer("Hello).insert(4,"---"); |
|
Definition
|
|
Term
why are string methods synchronized. |
|
Definition
because they are all acting on the same data. |
|
|
Term
how shoulc you read chaining of methods? |
|
Definition
from left to right . output of one method becomes input of the other methods. |
|
|
Term
how come we dont have to use import statement ot get access to String class? |
|
Definition
all classes in the java.lang package are imported automatically. |
|
|
Term
can you create object of java.lang.Math |
|
Definition
NO the constructor is private. and you cant extend it the class is final. all methods are static. |
|
|
Term
|
Definition
it is -8.0 !! -8 is greater than -9. |
|
|
Term
can a ceil method take integers can it return integers. |
|
Definition
NO! ceil method takes doubles and returns doubles. |
|
|
Term
what is Math.floor(-9.8)? |
|
Definition
|
|
Term
what is the result of calling Math.random()? |
|
Definition
a double between 0 and .9999 |
|
|
Term
|
Definition
|
|
Term
|
Definition
commits a sin in radians with a double |
|
|
Term
how to convert 90.0 to radians? |
|
Definition
|
|
Term
|
Definition
|
|
Term
how do you determine something is positive infinity , neg infinity of nan |
|
Definition
Float.POSITIVE_INFINITY, Double.NEGATIVE_INFINITY, Double.NaN |
|
|
Term
How do you check that double is Nan? |
|
Definition
|
|
Term
what is double devided by 0.0 |
|
Definition
|
|
Term
What is double devided by -0.0 |
|
Definition
it si Doble.NEGATIVE_INFINITY |
|
|
Term
what happens if you devide integers and floats with 0 |
|
Definition
you get arithemetic exception. |
|
|
Term
Which primitive doesnt have a Wrapper class? |
|
Definition
every primitive has a wrapper class |
|
|
Term
What are the types of constructors which wrapper classes tend to have? |
|
Definition
two constructors one for their respective types and another to take a string and makeit an integer or whatever |
|
|
Term
what kind of values will Boolean take. |
|
Definition
case insensitive string or actual boolean |
|
|
Term
can a boolean object be used in a if statement? |
|
Definition
|
|
Term
what is the significance of the valueOf method()? |
|
Definition
it can take two arguments like Integer.valueOf("101011",2) that becomes 43. ie radix allowed. |
|
|
Term
How do you get primitive out of Wrapper? |
|
Definition
(new Integer(42)).shortValue(); |
|
|
Term
What is the difference between parseXxx() and valueOf()? |
|
Definition
both take strings first one returns the primitive second one returns the wrapper. |
|
|
Term
What is the difference between most methods in Wrappers and the toString() method. |
|
Definition
the toString() method is a non static method. |
|
|
Term
What is the function of the toXxxString() method. |
|
Definition
can be used to convert string to Binary, Hex or Octal. |
|
|
Term
what does using == with two reference variables mean? |
|
Definition
it means weather they do point to the same object |
|
|
Term
when used with wrapper objects how does the equals method behave? |
|
Definition
if both the type of the object and its value are the same ti returns true. |
|
|
Term
does the StringBuffer class have an equals method. |
|
Definition
NO. it uses Object equas method which i tink compares references dont knwo |
|
|