Labels

Tuesday, August 12, 2014

Java quiz 1 Answer

Java quiz 1 Answer
  1.  B
  2.  B,D,E
  3. D-At line 3, we created a string object and its value is 'Java'. Because no new assignment was made, the new String object created with the 'concat()' method and the 'replace()' method was abandoned instantly. In the end, the value of 's' remains 'Java'
  4.  False- The code segments B and D will compile without any error. A is not a valid way to construct a StringBuffer, you need to create a StringBuffer object using "new". B is a valid construction of a Boolean (any string other than "true" or "false" to the Boolean constructor will result in a Boolean with a value of "false"). C will fail to compile because the valid range for a byte is -128 to +127 (i.e., 8 bits, signed). D is correct, 0x1234 is the hexadecimal representation in java. E fails to compile because the compiler interprets 1.2 as a double being assigned to a float (down-casting), which is not valid. You either need an explicit cast, as in "(float)1.2" or "1.2f", to indicate a float.

Java Quiz 1

Q1- 
1. class Ex1{
2.   public static void main(String[] args) {
3.      int a[][] = new int[3][];
4.       a[1] = new int[]{1,2,3};
5.       a[2] = new int[]{4,5};
6.    System.out.print(a[1][1]);
7.    }
8.  }
 
Which is the output?

A. Compilation fails due to line 3.
B. Compilation fails due to line 4.
C. An exception will be thrown in runtime.
D. 2
E. 3
F. 5
 Ans 
Q2.
 
Choose the three legal identifiers.
A. 1stName
B. _4_
C. @name
D. $
E. getSize
 Ans:
Q3.


Given
1. class S{ 
2. public static void main(String [] args){ 
3. String s = "Java"; 
4. s.concat(" SE 6"); 
5. s.replace('6','7'); 
6. System.out.print(s); 
7. } 
8. }
What is the result?

A. Java SE 6
B. Java SE 7
C. Java SE
D. Java
E. Compilation fails.
  Ans 
Q4.
In the following pieces of code, A and D will compile without any error. True or false?
A: StringBuffer sb1 = "abcd";
B: Boolean b = new Boolean("abcd");
C: byte b = 255;
D: int x = 0x1234;
E: float fl = 1.2;
True
False
 Ans 
 

Thursday, August 7, 2014

How to get back lost PhpMyAdmin password?


 Ans: Your credentials should be the same as you used to login to your Hosting account.