Quiz Space

Modern Application Development II · Quiz 1 · 25 Feb 2024 · January 2024 term

Question 8: Consider the following JavaScript code. What will be logg…

Question 8

+3 marksOne correct option

Consider the following JavaScript code. What will be logged on to the console once the code is executed?

javascript
class Album {
constructor(creator, albumName) {
this.creator = creator
this.albumName = albumName
this.songs = []
}
addSong(song) {
this.songs.push(song)
}
}
class Song {
constructor(name, duration) {
this.name = name
this.duration = duration
this.album = null
}
addAlbum(album) {
this.album = album
}
}
a1 = new Album('creator1', 'Album1')
s1 = new Song('Song1')
s1.addAlbum(a1)
console.log(a1.songs.length)
  1. A

    0

  2. B

    1

  3. C

    2

  4. D

    None of these

Show answer

Correct answer

  • A

    0

Question 8 of 16 in the IIT Madras BS Modern Application Development II (MAD 2) Quiz 1 paper sat on 25 Feb 2024, in the January 2024 term (IIT M DIPLOMA AN2 EXAM QDD2 25 Feb 2024). It carries 3 marks.

More questions from this paper

  1. Q1Consider the following JavaScript code. What will be logged on to the console once the code is executed?
  2. Q2Consider the following JavaScript code. What will be logged on to the console once the code is executed?
  3. Q3Consider the following JavaScript code. What will be logged on to the console once the code is executed?
  4. Q4Consider the following JavaScript code. What will be logged on to the console once the code is executed?
  5. Q5Consider the following Vue application with markup index.html and JavaScript app.js index.html app.js Suppose the appli…
  6. Q6Consider the following Vue application with markup index.html and JavaScript app.js index.html app.js Suppose the appli…
  7. Q7Consider the following JavaScript code. What will be logged on to the console once the code is executed?
  8. Q9Which of the following statement(s) is/are true regarding JavaScript language?
  9. Q10Consider the below JavaScript program. What will be the output of the above program, if executed?
  10. Q11Which of the following is/are example(s) of application state (i.e., system as seen by an individual user)?
  11. Q12Which of the following statement(s) is/are true?
  12. Q13Which of the following is a valid function definition to return the sum of 2 numbers passed as parameter?
  13. Q14Consider the below JavaScript program. What will be the output of the above program, if executed?
  14. Q15Which of the following is not a valid Vue directive?
  15. Q16Consider the below javascript program. What will be the output of the above program, if executed?