Question
1. Consider the Cool program below c l a s s Main i n h e r i t s IO { x : I
1. Consider the Cool program below
c l a s s Main i n h e r i t s IO {
x : I n t <− 5 ;
main ( ) : Ob jec t {
l e t newa : A <− new A, newb : A <− new B, newc : A <− new C i n
{
o u t s t r i n g ( newa .m( 1 ) ) ;
o u t s t r i n g ( newb .m( 1 ) ) ;
o u t s t r i n g ( newc .m( 1 ) ) ;
o u t s t r i n g (newc@A .m( 2 ) ) ;
}
} ;
} ;
c l a s s A {
v : I n t ;
m ( x : I n t ) : S t ri n g {
i f x < v then
” H ell o ”
e l s e
”Goodbye”
f i
} ;
setV ( newv : I n t ) {
v <− newv
} ;
} ;
c l a s s B i n h e r i t s A {
m ( x : I n t ) : S t ri n g {
i f x > v then
”Hola ”
e l s e
” Adios ”
f i
} ;
setV ( newv : I n t ) {
v <− newv + 1
} ;
} ;
1
c l a s s C i n h e r i t s A {
m ( x : I n t ) : S t ri n g {
i f x = v then
”Nihao”
e l s e
” Z a i j i a n ”
f i
} ;
} ;
What is the output of this program?
Step by Step Solution
3.44 Rating (154 Votes )
There are 3 Steps involved in it
Step: 1
The output of the program will be Hello Hola Nihao Goodbye Heres a breakdown of th...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get StartedRecommended Textbook for
Income Tax Fundamentals 2013
Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill
31st Edition
1111972516, 978-1285586618, 1285586611, 978-1285613109, 978-1111972516
Students also viewed these Accounting questions
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
View Answer in SolutionInn App