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

11. What can directly access and change the value of the variable name?
package test;
class Target {
public String name = "hello";
}

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

Answer: Option C

Explanation:

Here is no explanation for this answer

Workspace

Tags:

Virtusa 

12. What will happen when you attempt to compile and run the following code?

public class MyField{
String s;
public static void main(String argv[]){
MyField m = new MyField();
m.amethod();
}
void amethod(){
System.out.println(s);
}
}

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

Answer: Option D

Explanation:

Here is no explanation for this answer

Workspace

Tags:

Virtusa 

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

Answer: Option B

Explanation:

Here is no explanation for this answer

Workspace

Tags:

Virtusa 

14. Output of the below partial code.
String[] elements = {"Java","is","platform","independent"};
String result = (elements.length > 0) ? elements[0]:null;
System.out.printf(result);

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

Answer: Option B

Explanation:

Here is no explanation for this answer

Workspace

Tags:

Virtusa 

15. What will happen when you attempt to compile and run the code in main method:

for(int i=0;i<5;) {
System.out.println(i);
i++;
continue;
}

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

Answer: Option C

Explanation:

Here is no explanation for this answer

Workspace

Tags:

Virtusa 

16. Given the following constructor what will element 1 of mycon contain?

MyCon(){
int[] mycon= new int[5];
}

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

Answer: Option A

Explanation:

Here is no explanation for this answer

Workspace

Tags:

Virtusa 

17. Consider the following code:

public class ManTin {
public static void main(String[] args) {
int j=2,y=3,z=9;
for(;j<6;j++) {
y = (++y + z++);
System.out.println(y+z);
}
}
}
Which of the following gives the valid output for the above code?

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

Answer: Option C

Explanation:

23 35 48 62

Workspace

Tags:

Virtusa 

18. What exception type does the following program throw?

public class Test {
public static void main(String[] args) {
System.out.println(1/0);
}
}

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

Answer: Option A

Explanation:

ArithmeticException

Workspace

Tags:

Virtusa 

19. What is the Output:

public class SwitchTest {
public static void main(String argv[]) {
SwitchTest ms=new SwitchTest();
ms.display();
}
public void display() {
int k=10;
switch(k){
case 10:
System.out.println("10");
case 30:
System.out.println("30");
case 20:
System.out.println("20");
default:
System.out.println("40");
}
}
}

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

Answer: Option A

Explanation:

10 ,30 , 20 , 40

Workspace

Tags:

Virtusa 

20. Which Exception Will occur

class Test {
public static void main(String[ ] args) {
try {
String s = "5.6";
Integer.parseInt(s); // Cause a NumberFormatException
int i = 0;
int y = 2 / i;
System.out.println("Welcome to Java");
} catch (Exception ex) {
System.out.println(ex);
}
}
}

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

Answer: Option A

Explanation:

NumberFormatException

Workspace

Tags:

Virtusa