which one is valid statement in Java ?
int i ( 1=new int (1)
int i=new int:
int i=new int();
int i[ ]=new int()
Answers
Answered by
12
int i=new int(); is valid statement in java
Answered by
0
(c) int i=new int();
Explanation:
- Here int - datatype , I variable New - keyword which we are used to create an object in the heap area (at run time ) Again we have to mention the object name (constructor).
- New int[] means initialize an array object named arr and has a given number of elements ,we can choose any number you want ,but it will be of the type declared yet.
- In Java you have int and Integer . Integer is a wrapper class for int so logically you would need to create a new Integer like this. Integer
i = new Integer(5); You can definitely do this, and it's completely valid.
Similar questions