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

1 Expert Approved Answer
Step: 1 Unlock

The output of the program will be Hello Hola Nihao Goodbye Heres a breakdown of th... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Accounting Questions!