Discussion :: Declarations and Access Control - General Questions (Q.No.16)
Sris said: (Jul 3, 2014) | |
1 is absolutely wrong, I do agree with that. But 2, I have a confusion that is it compulsory to mention the size? I heard if we won't specify the size it will take the value how many we are going to add to the array. Clarify please. |
Nitin said: (Jun 30, 2015) | |
What is the error in 2nd one? Its absolutely correct. |
Abhishek said: (Dec 5, 2015) | |
I do Agree that 2 will throw compile time error. Because as per Java API. We must have to give no of size of array. Array always work on fixed length. |
Anusha said: (Aug 23, 2016) | |
What is the error in 2nd one? Its absolutely correct, I do Agree that 2 will throw compile time error. Because as per Java API. We must have to give no of size of array. Array always work on fixed length. |
Rita said: (Nov 16, 2016) | |
Option three shouldn't compile as well. I see no space between float[]f1. Hasn't anyone noticed it? Please tell me. |
Sanjog said: (Oct 20, 2017) | |
How will option 5 be compiled? |
Hindustan said: (Aug 29, 2021) | |
Hi , 2 nd one won't compile because we do not set size explicitly. package JAVA_PROGRAMS; public class immutable { public static void main(String[] args) { float f5[ ] = {1.0f, 2.0f, 2.0f}; //ok float[ ]f1 = new float[3];//ok float f2[ ] = new float[ ]; //invalid } } |
Post your comments here:
Name *:
Email : (optional)
» Your comments will be displayed only after manual approval.