Infosys Certified Scala Programmer
Practice with real exam-pattern questions for Infosys Certified Scala Programmer. Each question includes a detailed explanation to help you understand the concept, not just memorise the answer. Try 10 questions free — no login required.
Full question bank for this exam + 1,357+ others. Cancel anytime.
Join Premium10 Infosys Certified Scala Programmer practice questions with answers
Real Lex exam-pattern multiple-choice questions for the Infosys Certified Scala Programmer certification. Each question includes the correct answer. The full question bank is available to Premium members.
- Question 1
John is trying a pattern in Regular expression to get the output for the given code as "scar". Which code from the given option needs to be placed at Line1 to get the required output?
Note: Assume all necessary imports have been done
object RegExDemo { def main(args: Array[String]) { //Line 1 val str = "Scam needs to be avoided so that it does not scare public" println((pattern findAllIn str).mkString(",")) } }- ✓
val pattern = new Regex("sca[mr]\\d+")
Correct - B
val pattern = new Regex("sca[mr]\\d*")
- C
val pattern = new Regex("scar\\d&")
- D
val pattern = new Regex("Sca[mr]\\d*)
- ✓
- Question 2
Find the output for the below code
val items=List("Chain ","Pin ","HairBand")
var details="NailPolish "
items.foreach((item:String)=>details+=item)
println(details)
- ✓
Chain Pin HairBand
Correct - B
NailPolish
- C
Chain Pin HairBand NailPolish
- D
NailPolish Chain Pin HairBand
- ✓
- Question 3
What is the output of the following code ?
Note: Assume necessary imports have been done
object DemoApp extends App {
def findDivision(number: Int) =
Future {
5 / number
}
val response = findDivision(0)
response.onSuccess { case value => print(value) } //Line1
Thread.sleep(5)
}- ✓
Nothing will be printed on screen
Correct - B
java.lang.ArithmeticException: / by zero
- C
Failure("java.lang.ArithmeticException: / by zero")
- D
Success("java.lang.ArithmeticException: / by zero")
- ✓
- Question 4
Janet is working on Scala Future and map collection concept. Help Janet predict the output for the given code.
(Assume all the necessary imports have been done.)
object ScalaFuture extends App { val myList = Future{List('a', 2, "hey", 3)} val result = myList.map(x => x.apply(3).equals("hey")) result.onSuccess { case x => println(x) } result.onFailure { case y => println("Error") } }- ✓
hey
Correct - B
error
- C
true
- D
false
- ✓
- Question 5
InfySkyWave is working on a Student portal to display the winner for a quiz contest conducted in various batches. Janet is working on the following incomplete code where collections with futures is used to retreive the details in an easier way. (Assume necessary imports have been done.)
object ScalaFutList extends App { val f: Future[List[String]] = Future { List("Sharon Levin Leon", "Sneha Sweta Sherin", "John Riya Mega") } //Line 1 val result = Await.result(f1, Duration(2, "sec")) println(result) }What code should be placed at Line 1 to get the winners as shown below?
List(Sharon, Sneha, John)
- ✓
val f1: Future[List[String]] = f.map(x => x.map(y => y.split(" ")(0)))
Correct - B
val f1: Future[List[String]] = f.map(x => x.split(" ")(1))
- C
val f1: Future[List[String]] = f.map(x => x(1))
- D
val f1: Future[List[String]] = f.map(x => x.map(y => y.split(" ")(1)))
- ✓
- Question 6
Find the below given code
object Main
{
def main(args: Array[String]): Unit = {
val stud = new Student("Sharon", "John", 80)
println(stud.fName + "\t" + stud.lName + "\t" + stud.marks)
val stud2 = new Student("Rekha")
println(stud2.fName + "\t" + stud2.lName + "\t" + stud2.marks)
}
class Student(val fName: String, val lName: String, val marks: Int)
{
def this(fName: String)
{
// Line 1
println("\nStudent Marks")
}
}
}
Choose the option which should be placed at Line 1 to avoid compilation error?- ✓
this(fName)
Correct - B
this(fName, "", 90);
- C
this(fName,80)
- D
this()
- ✓
- Question 7
Find the below code
class Apartment(color:String)
{
def col()=color
def disp()=color + "House"
}
John is analyzing the above code and the following statements has been derived. Choose the statement which is not valid?
- ✓
Code compiles successfully
Correct - B
Scala class Apartment definition is not proper
- C
col() methods get the color
- D
disp() method gets the color and concatenates with the string “House”
- ✓
- Question 8
Which of the following options will not compile and execute successfully?
I. var covid="Corona Test"
println(covid+"is a type of test")
II. val covid:String = "Corona Test"
println(covid+" a horse ");
III. val covid='Corona Test'
println(covid=covid+Test)
IV. var covid="Corona Test"
println("Covid :"+(covid=covid+" " +covid)- ✓
Only i and ii
Correct - B
Only iii
- C
Only i and iv
- D
Only ii and iii
- ✓
- Question 9
Have a close look at the following code snippets and identify the correct option
trait DeductTax {
def taxCalculation1()
def taxCalculation2() = { println("version1") }
}class SalaryUtil() extends DeductTax {
override def taxCalculation1() = { println("given implementation") } //line1
override def taxCalculation2() = { println("version2") } //line2
}
- ✓
"override" keyword is optional at line1
Correct - B
"override" keyword is optional at line2
- C
"override" keyword is optional at both line1 and line2
- D
"override" keyword is neither optional at line1 nor at line2
- ✓
- Question 10
Find the output for the below code
import scala.util.{Try, Success,Failure}object Main extends App
{
def justTry(n:Int) ={ val tryMap=Map(0->Try(0),1->Try(1), 2->Try(2), 3->Try("3"))
Try(tryMap(n))
}
for(n<-2 to 4)
{
println(justTry(n).filter(y=>y.isFailure==false))
}
}- ✓
Success(Success(2))
Correct
Success(Success(3)) - B
Success(Success(2))
Success(Success(3))
Failure(java.util.NoSuchElementException: key not found: 4) - C
Success(Success(2))
Success(Success(3))
Failure - D
Success(Success(2))}
Success(Success(3))
Success(Success(4))
- ✓
More in Java
Infosys Certified Expert Programmer-Level 1
Infosys Certified Go Programmer
Infosys Certified Go REST Developer
Pay once. Clear every cert this year.
One subscription, full Telegram channel access, every PDF posted during your membership.
- Full access to all 1,357+ certifications
- Monthly updated question banks
- Telegram private channel access
- Cancel anytime
- Everything in Monthly
- Save ₹2,100 vs monthly billing
- Priority answer key requests
- Best for increasing DQ score fast
- Everything in Quarterly
- Lifetime channel access — no renewals
- All future certifications included
- Priority response from admin team
Common questions, straight answers.
A monthly-updated Telegram channel where we post real exam-pattern question banks and detailed answer keys for 1,357+ Infosys Lex certifications. You join once, you get every PDF posted during your membership.
Right after payment on our Graphy page, you'll receive a private invite link to the Telegram channel. Access is instant — usually under 30 seconds.
We compile question banks from the actual Lex test pattern, sourced and verified by 180K+ community members who've recently cleared these exams. Match rate is consistently 85–95%.
Every single month. When Infosys rolls out new versions of certifications, we post updated dumps within 7–10 days. You'll see channel activity weekly.
Clearing certifications is one of the highest-weighted DQ factors. Members typically clear 3–5 certifications in their first 3 months, which moves DQ scores up by a full band.