| Back to Questions Page |
| |
| Question |
could you run the java program without main method? |
Rank |
Answer Posted By |
|
Question Submitted By :: Naga |
|
I also faced this Question!! |
© ALL Interview .com |
| Answer | yes,we can write and run a java program without using the
main method.
i.e By using static
example program...!
public void static( )
public class
{
public void static( )
{
System.out.println( "Without main method" );
System.exit(0);
}
}  |
| Naga |
| |
| |
| Question |
Accenture NJ mostly ask question on Collection like
1)How to sort Objcts and how treeset sort them
2)Explain mechanism of Hashcode finding in Java
3)Name some of the Sorted collection. |
Rank |
Answer Posted By |
|
Question Submitted By :: Guest |
| This Interview Question Asked @ Accenture |
|
I also faced this Question!! |
© ALL Interview .com |
| Answer | The answer to all this question is easy but i think they
want answer from internal mechanism how it works inside
Java!!!
You think you answered well but they will always fail you
just hate then  |
| Guest |
| |
| |
| Question |
Given:
11. public static void main(String[] args) {
12. Integer i = uew Integer(1) + new Integer(2);
13. switch(i) {
14. case 3: System.out.println(”three”); break;
15. default: System.out.println(”other”); break;
16. }
17. }
‘What is the result?
1 three
2 other
3 An exception is thrown at runtime.
4 Compilation fails because of an error on
line 12.
|
Rank |
Answer Posted By |
|
Question Submitted By :: Rakesh |
|
I also faced this Question!! |
© ALL Interview .com |
| Answer | Compilation fails because of an error on  |
| Harish |
| |
| |
|
|
| |
| Answer | Three will be the answer.  |
| Amit Mittal |
| |
| |
| Question |
Given:
1. package test;
2.
3. class Target {
4. public String name = “hello”;
5. }
What can directly access and change the value of the
variable name?
1 any class
2 only the Target class
3 any class in the test package
4 any class that extends Target
|
Rank |
Answer Posted By |
|
Question Submitted By :: Rakesh |
|
I also faced this Question!! |
© ALL Interview .com |
| Answer | any class  |
| Dilip |
| |
| |
| Answer | any class in the test package  |
| Ram |
| |
| |
| Answer | any class that extends Taget  |
| Lakshman |
| |
| |
| Question |
84. try {
85. ResourceConnection con =
resourceFactory.getConnection();
86. Results r = con.query(”GET INFO FROM CUSTOMER”);
87. info = r.getData();
88. con.close();
89. } catch (ResourceException re) {
90. errorLog.write(re.getMessage());
91. }
92. return info;
Which is true if a ResourceException is thrown on line 86?
1 Line 92 will not execute.
2 The connection will not be retrieved in line
85.
3 The resource connection will not be closed
on line 88.
4 The enclosing method will throw an exception
to its caller.
|
Rank |
Answer Posted By |
|
Question Submitted By :: Rakesh |
|
I also faced this Question!! |
© ALL Interview .com |
| Answer | The resource connection will not be closed on line 88.  |
| Nik |
| |
| |
| Question |
11. static class A {
12. void process() throws Exception { throw new Exception();
}
13. }
14. static class B extends A {
15. void process() { System.out.println(”B”); }
16. }
17. public static void main(String[] args) {
18. new B().process();
19. }
What is the result?
1 B
2 The code runs with no output.
3 Compilation fails because of an error in
line 12.
4 Compilation fails because of an error in
line 15. |
Rank |
Answer Posted By |
|
Question Submitted By :: Rakesh |
|
I also faced this Question!! |
© ALL Interview .com |
| Answer | B  |
| Neil |
| |
| |
| Question |
Given:
10. interface A { void x(); }
11. class B implements A { public void x() { } public
voidy() { } }
12. class C extends B { public void x() {} }
And:
20. java.util.List list = new java.util.ArrayList();
21. list.add(new B());
22. list.add(new C());
23. for (A a:list) {
24. a.x();
25. a.y();;
26. }
What is the result?
1 Compilation fails because of an error in
line 25.
2 The code runs with no output.
3 An exception is thrown at runtime.
4 Compilation fails because of an error in
line 20.
|
Rank |
Answer Posted By |
|
Question Submitted By :: Rakesh |
|
I also faced this Question!! |
© ALL Interview .com |
| Answer | Compilation fails because of an error in
line 25.  |
| Neil |
| |
| |
| Question |
33. try {
34. // some code here
35. } catch (NullPointerException e1) {
36. System.out.print(”a”);
37. } catch (RuntimeException e2) {
38. System.out.print(”b”);
39. } finally {
40. System.out.print(”c”);
41. }
What is the result if a NullPointerException occurs on line
34?
1 c
2 a
3 ab
4 ac
|
Rank |
Answer Posted By |
|
Question Submitted By :: Rskesh |
|
I also faced this Question!! |
© ALL Interview .com |
| Answer | 1. c  |
| Deepak Chawla |
| |
| |
| Question |
10. class Nav{
11. public enum Direction { NORTH, SOUTH, EAST, WEST }
12. }
13. public class Sprite{
14. // insert code here
15. }
Which code, inserted at line 14, allows the Sprite class to
compile?
a)Direction d = NORTH;
b)Nav.Direction d = NORTH;
c)Direction d = Direction.NORTH;
d)Nav.Direction d = Nav.Direction.NORTH; |
Rank |
Answer Posted By |
|
Question Submitted By :: Nikunj |
|
I also faced this Question!! |
© ALL Interview .com |
| Answer | Nav.Direction d = Nav.Direction.NORTH;  |
| Neil |
| |
| |
|
| |
|
Back to Questions Page |