Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- What is the result of compiling and running the following class:
- class Test
- {
- public void methodA(int i)
- {
- System.out.println(i);
- }
- public int methodA(int i)
- {
- System.out.println(i+1);
- return i+1;
- }
- public static void main(String args[])
- {
- Test X = new Test();
- X.methodA(5);
- }
- }
- (A) The program compiles and runs printing 5.
- (B) The program compiles and runs printing 6.
- (C) The program gives runtime exception because it does not find the method Test.methodA(int)
- (D) The program give compilation error because methodA is defined twice in class Test.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement