Home Tutorial Java Scjp Part1 SCJP Module-1 Question-23

 
 

Share on Google+Share on Google+
SCJP Module-1 Question-23
Posted on: July 21, 2010 at 12:00 AM
Advertisement
The Sample program given below will test your understanding of Java programs.

Given a sample code:

1    class SetVar {

2    private int i = 0;

3    public int plusOne() {
4    return + ++i ;
}}

5    public class Test {
6    public static void main(String[] args) {
7    System.out.println(new SetVar().plusOne());
}}

What will be the result? Choose the correct option?

(A) 2
(B) 1
(C) 0
(D) Compilation error at line no 9.

Answer:

(B)

Advertisement

Related Tags for SCJP Module-1 Question-23:


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.

Posted on: July 21, 2010

Recommend the tutorial

Advertisements Advertisements
 

 

 

DMCA.com