KnowledgeBoat Logo
|

Computer Applications

What is the output of the following code ?

void func(String s)	{ 
    String s = s1 + "xyz" ;
    System.out.println("s1 =" + s1) ; 
    System.out.println("s =" + s) ;
}

Java

User Defined Methods

5 Likes

Answer

The given code generates error because of the following :

  1. String s is already declared in the function signature. Its redeclaration inside func() will cause a compile time error.
  2. String s1 is not declared and that is also a compile time error.

Answered By

4 Likes


Related Questions