Note 1

Take Note:

Take a note while surfing.





Note With Ink

Give your Note a Colorful Tag.




Easy to Access

Stay on same information and in Sync wherever you are.

Note 2

Take Note:

Organize your information,It may take Shape.





Think With Ink

Differ your Content by Color.




Easy to Access

Easy to pull up your content from anywhere anytime.

Note 3

Take Note:

Don't Let information to miss,Because it take shape





Note With Ink

Simple an Easy Way to take a note.




Easy to Access

Get the same in next visit.

JAVA Programming :: Basic Concepts

Home > JAVA Programming > Basic Concepts > General Questions

51. Find the Output:

String valid = "true";
if(valid)
System.out.println("valid");
else
System.out.println("not valid");

View Answer | Discuss in Forum | Workspace | Asked In |

Answer: Option C

Explanation:

Here is no explanation for this answer

Workspace

Tags:

No Tags on this question yet!

52. What is the number of bytes used by Java primitive long. Select the one correct answer.

View Answer | Discuss in Forum | Workspace | Asked In |

Answer: Option D

Explanation:

Here is no explanation for this answer

Workspace

Tags:

No Tags on this question yet!

View Answer | Discuss in Forum | Workspace | Asked In |

Answer: Option B

Explanation:

Here is no explanation for this answer

Workspace

Tags:

No Tags on this question yet!

54. What is the output for the below code ?

public class Test {
public static void main(String... args) {
int x =5;
x *= 3 + 7;
System.out.println(x);
}
}

View Answer | Discuss in Forum | Workspace | Asked In |

Answer: Option B

Explanation:

x *= 3 + 7; is same as x = x * (3 +7) = 5 * (10) = 50 because expression on the right is always placed inside parentheses.

Workspace

Tags:

No Tags on this question yet!

55. What is the output for the below code ?

public class Test {
enum Month { JAN, FEB, MAR };
public static void main(String... args) {
Month m1 = Month.JAN;
Month m2 = Month.JAN;
Month m3 = Month.FEB;
System.out.println(m1 == m;
System.out.println(m1.equals(m);
System.out.println(m1 == m;
System.out.println(m1.equals(m);
}
}

View Answer | Discuss in Forum | Workspace | Asked In |

Answer: Option B

Explanation:

m1 and m2 refer to the same enum constant So m1 == m2 returns true BUT m1 and m3 refer to different enum constant So m1 == m3 returns false. m1.equals(m returns true because enum constant value is same (JAN and JAN). m1.equals(m return false because enum constants values are different (JAN and FEB).

Workspace

Tags:

No Tags on this question yet!

56. class A {
class A1 {
void printValue(){
System.out.println("A1");
}
}
}
public class Test{
public static void main (String[] args){
A a = new A();
// INSERT CODE
a1.printValue();
}
}
Which of the below code inserted at line 4, compile and produce the
output "A1"?

View Answer | Discuss in Forum | Workspace | Asked In |

Answer: Option A

Explanation:

correct inner class instantiation syntax is A a = new A(); A1 a1 = new A1();

Workspace

Tags:

No Tags on this question yet!

57. What is the name of the Collection interface used to represent elements in a sequence (in a particular order). Select the one correct answer.

View Answer | Discuss in Forum | Workspace | Asked In |

Answer: Option C

Explanation:

Here is no explanation for this answer

Workspace

Tags:

No Tags on this question yet!

58. What is the output for the below code ?

public class A {
public void printValue(){
System.out.println("Value-A");
}
}
public class B extends A{
public void printNameB(){
System.out.println("Name-B");
}
}
public class C extends A{
public void printNameC(){
System.out.println("Name-C");
}
}
public class Test{
public static void main (String[] args) {
B b = new B();
C c = new C();
newPrint(b);
newPrint(;
}
public static void newPrint(A {
printValue();
}
}

View Answer | Discuss in Forum | Workspace | Asked In |

Answer: Option B

Explanation:

Class B extended Class A therefore all methods of Class A will be available to class B except private methods. Class C extended Class A therefore all methods of Class A will be available to class C except private methods.

Workspace

Tags:

No Tags on this question yet!

59. What will be the output of the below program:

public class SwitchTest {
public static void main(String argv[]) {
SwitchTest ms=new SwitchTest();
ms.display();
}
public void display() {
int k=10;
switch(k){

default:
System.out.println("This is the default output");
break;
case 10:
System.out.println("ten");
break;
case 20:
System.out.println("twenty");
break;
}
}
}

View Answer | Discuss in Forum | Workspace | Asked In |

Answer: Option A

Explanation:

Here is no explanation for this answer

Workspace

Tags:

No Tags on this question yet!

60. What all gets printed when the following code is compiled and run?

public class xyz {
public static void main(String args[]) {
for(inti = 0; i< 2; i++) {
for(int j = 2; j>= 0; j) {
if(i == j) break;
System.out.println("i=" + i + " j="+j);
}
}
}
}

View Answer | Discuss in Forum | Workspace | Asked In |

Answer: Option B

Explanation:

Here is no explanation for this answer

Workspace

Tags:

No Tags on this question yet!