This language is influenced by Groovy
1.Ruby
2.Kotlin
3.Go
4.None of these
Groovy is both a static and dynamic language
1.True
2.False
3.Error
4.All of the above
Groovy is Java-syntax-compatible language
1.True
2.False
3.Error
4.None of These
// << left shift operator Guess the output File myFile = new File("file1.txt") myFile << "This is Line 1"
1.File with name file1.txt will get created and data will be written in the file
2.An empty file will get created
3.Exception
4.None of These
// Renaming file Guess the output File myFile = new File("file1.txt") myFile.write("This is Line 1") myFile.renameTo(new File("newfile.txt"))
1.file1.txt will get renamed to newfile.txt
2.A new file named newfile.txt will get created
3.both (a) and (b)
4.None of these
// using withWriter Guess the output File myFile = new File("file1.txt") myFile.write("This is line 1") myFile.withWriter { writer -> writer.writeLine("This is Line 2") } println myFile.text
1.This is Line 1 This is Line 2
2.This is Line 2
3.This is Line 1
4.None of these
A regular expression, regex or regexp is a sequence of characters that define a search pattern. Patterns used to find substrings in a text
1.True
2.False
3.Error
4.None of the above
An abstract class can have final method static method constructors
1.True
2.False
3.Error
4.None of These
An abstract class cannot be instantiated. (Objects cannot be created for an abstract class)
1.True
2.False
3.Error
4.None of These
An abstract class cannot have non-abstract methods hint abstract methods have only method signature and no body. abstract methods are declared with keyword abstract e.g. public abstract void maxSpeed();
1.True
2.False
3.Error
4.None of these
An abstract class is declared with a keyword abstract e.g. abstract class Car{ }
1.True
2.False
3.Error
4.None of these
An interface can have only abstract methods whereas An abstract class can have both abstract and non-abstract (concrete) methods non-abstract methods also have body
1.True
2.False
3.Error
4.None of These
Groovy code is compiled to JVM byte code
1.True
2.False
3.Error
4.All of the above
Groovy was designed by James Strachan
1.Yes
2.No
3.Error
4.None of the above
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() } }
1.Name of the fruit is Apple
2.Exception
3.null
4.None of the above
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() } }
1.Name of the fruit is Apple
2.Exception
3.null
4.None of These
Guess the output File myFile = new File("file1.txt") myFile << "This is Line 1" myFile.text = "This is Line 2" println myFile.text
1.This is Line 1 This is Line 2
2.This is Line 1
3.This is Line 2
4.None of these
Guess the output File myFile = new File("file1.txt") myFile.write("This is Line 1") File newFile = new File("file2.txt") newFile << myFile.text
1.No change
2.A new file named file2.txt will get created and data will be copied from file1.txt
3.exception
4.A new blank file will get created
Guess the output File myFile = new File("file1.txt") myFile.write("This is Line 1") println myFile.length() println myFile.isFile() println myFile.isDirectory() println myFile.isHidden()
1.//size of the file in bytes
2.False
3.true
4.None of these
Guess the output File myFile = new File("file1.txt") myFile.write("This is Line 1") myFile.bytes = []
1.Will empty the file file1.txt
2.no change
3. exception
4.None of the above
Guess the output File myFile = new File("file1.txt") myFile.write("This is Line 1") println myFile.text
1.A file will be created named file1.txt and the text will be written in the file. The text will also get printed on the console
2.A blank file will get created
3.exception
4.None of these
Guess the output You can run and check the code here – https://groovy-playground.appspot.com/ def match = "Groovy" =~ "123" if(match){ println match[0] }else{ println "No match found" }
1.Groovy
2.123
3.nul
4.l No match found
Guess the output You can run and check the code here – https://groovy-playground.appspot.com/ def match = "Groovy" =~ "Groovy" println match[0]
1.Groovy
2.1
3.null
4.exception
Guess the output You can run and check the code here – https://groovy-playground.appspot.com/ def match = "Groovy" =~ "o" if(match){ def num=0 while(match){ print match[num] num++ } }else{ println "No match found" }
1.No match found
2.oo
3.exception
4.None of These
Java is required to install Groovy
1.Yes
2. No
3.Error
4.None of These
The body for abstract methods inside an abstract class has to be provided in its child class
1.True
2.False
3.Error
4.None of These
To use any method or field of an abstract class, it has to be extended in a child class because abstract classes cannot be instantiated.
1.True
2.False
3.Error
4.None of These
What is the command to check groovy version
1.groovy –version
2.groovy -v
3.Both A & B
4.All of the above
What is the command to check java version
1.java -version
2.java -v
3.java – – version
4.None of These
What is the command to install groovy on Mac OS using Homebrew
1.brew install groovy
2.brew get groovy
3.brew add groovy
4.None of These