Share on Google+Share on Google+

SCJP Module-1 Question-29

The Sample program given below will test your understanding about the methods in Java.

Given a sample code:

1    class Test3 {

2    public Integer showval;

3    public void methodOne() {
4    Integer i = new Integer(1);
5    showval = i;
6    methodTwo(i);

7    private void methodTwo(Integer val) {
8    val = val.intValue();
9    System.out.print(val + " ");

10    public static void main(String[] args) {
11    Test3 t = new Test3();
11    t.methodOne();
12    t.methodTwo(9);

What will be the result? Choose the correct option?

(A) 1 9
(B) 9 1
(C) Compilation error at line no-5
(D) Compilation error at line no-8




Posted on: July 21, 2010 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Share this Tutorial Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.