What will be the result of compilation and execution of the following code?
public class TestClass {
    
    public static void main(String[] args) {
                String s = new String(){
                    public String toString(){
                        return "new method";
                    }                    
                }
                System.out.println(s);
        }
    }        

Follow CodeGalaxy

Mobile Beta

Get it on Google Play
Send Feedback
Keep exploring
Java quizzes
Cosmo
Sign Up Now
or Subscribe for future quizzes