Groovy Quiz 25 | Classes & Objects


Reference video | Groovy Playground


1 Point for every correct answer | Let’s Get Started

1.

Guess the output

class Fruits{
    
    String fruitName
    String fruitColor
    
    def setName(String name){
        fruitName = name
    }
    
    def getFruitName(){
        println "Name of the fruit is $fruitName"
    }
    static void main(args){
        println "I am inside main"
        Fruits apple = new Fruits()
        apple.setName("Apple")
        apple.getFruitName()
    }
}

 
 
 

7