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

 
 

Share on Google+Share on Google+
SCJP Module-1 Question-4
Posted on: July 6, 2010 at 12:00 AM
Advertisement
The given program will checks the core java knowledge and it is also helpful in preparation of SCJP exams

Given a sample code:

public class SampleCode {
public static void main(String args[]){
SampleCode sc = new SampleCode();
sc.meth();
}
public void meth(){
int arr[] = new int[] {1,2,3,4};
System.out.print(arr.length);
}
}

What will happen when you compile and run the given code?

1) Compile and print 4
2) Cant access method outside class
3) Compile time error
4) Compile but give runtime error.

Answer

(1)

Explanation:

This program will compile and execute with 4 as output.

Advertisement

Related Tags for SCJP Module-1 Question-4:


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 6, 2010

Recommend the tutorial

Advertisements Advertisements
 

 

 

DMCA.com