Sail E0 Webinar

MCQs

Total Questions : 9
Question 1. Which of these methods can be used to output a sting in an applet?
  1.    display()
  2.    print()
  3.    drawString()
  4.    transient()
 Discuss Question
Answer: Option C. -> drawString()


drawString() method is defined in Graphics class, it is used to output a string in an applet.


Question 2. Which of these functions is called to display the output of an applet?
  1.    display()
  2.    print()
  3.    displayApplet()
  4.    PrintApplet()
 Discuss Question
Answer: Option B. -> print()


Whenever the applet requires to redraw its output, it is done by using method paint().


Question 3. Which of these methods is a part of Abstract Window Toolkit (AWT) ?
  1.    display()
  2.    print()
  3.    drawString()
  4.    transient()
 Discuss Question
Answer: Option B. -> print()


paint() is an abstract method defined in AWT.


Question 4. What does AWT stands for?
  1.    All Window Tools
  2.    All Writing Tools
  3.    Abstract Window Toolkit
  4.    Abstract Writing Toolkit
 Discuss Question
Answer: Option C. -> Abstract Window Toolkit


AWT stands for Abstract Window Toolkit, it is used by applets to interact with the user.


Question 5. Which of these modifiers can be used for a variable so that it can be accessed from any thread or parts of a program?
  1.    transient
  2.    volatile
  3.    global
  4.    No modifier is needed
 Discuss Question
Answer: Option B. -> volatile


The volatile modifier tells the compiler that the variable modified by volatile can be changed unexpectedly by other part of the program. Specially used in situations involving multithreading.


Question 6. Which of these operators can be used to get run time information about an object?
  1.    getInfo
  2.    Info
  3.    instanceof
  4.    getinfoof
 Discuss Question
Answer: Option C. -> instanceof


instanceof


Question 7. What is the length of the application box made by this program?import java.awt.*;import java.applet.*;public class myapplet extends Applet {Graphic g;g.drawString("A Simple Applet", 20, 20);    }
  1.    20
  2.    Default value
  3.    Compilation Error
  4.    Runtime Error
 Discuss Question
Answer: Option C. -> Compilation Error


To implement the method drawString we need first need to define abstract method of AWT that is paint() method. Without paint() method we can not define and use drawString or any Graphic class methods.


Question 8. What is the length of the application box made by this program?import java.awt.*;import java.applet.*;public class myapplet extends Applet {public void paint(Graphics g) {g.drawString("A Simple Applet", 20, 20);    }}
  1.    20
  2.    50
  3.    100
  4.    System dependent
 Discuss Question
Answer: Option A. -> 20


the code in pain() method “ g.drawString("A Simple Applet,20,20); draws a applet box of length 20 and width 20.


Question 9. What is the Message is displayed in the applet made by this program?import java.awt.*;import java.applet.*;public class myapplet extends Applet {public void paint(Graphics g) {g.drawString("A Simple Applet", 20, 20);    }}
  1.    A Simple Applet
  2.    A Simple Applet 20 20
  3.    Compilation Error
  4.    Runtime Error
 Discuss Question
Answer: Option A. -> A Simple Applet


A Simple Applet


Latest Videos

Latest Test Papers