MCQ questions for graphics class method in Java

Introduction of Graphics class in Java :

  • The Graphics class is in java is the abstract base class for all graphics contexts.
  • A Graphics object encapsulates state information needed for the basic rendering operations that Java supports.
  • A Graphics class is allow an application to draw onto components that are realized on various devices, as well as onto off-screen images. 

MCQ questions for graphics class method in Java :

1. The Graphics class is the_____for all graphics contexts.
     a) Main class
     b) Abstract super class 
     c) Super class
     d) Object class

Answer: b) Abstract super class 

2. The Graphics class is resides in_____
     a) java.util
     b) java.lang
     c) java.applet
     d) java.awt

Answer: d) java.awt

 3. Syntax to create new Graphics object is create()
     a) True
     b) False
    
Answer: a) True

4. Which method is not part of the Graphics() class
     a) clearRect(int x, int y, int width, int height)
     b) dispose()
     c) drawLine(int x1, int y1, int x2, int y2)
     d) All of the above
    
Answer: d) All of the above

5. Graphics it is the top level abstract class for all graphics contexts.
     a) True
     b) False

Answer: a) True

6. Correct declaration of -drawPolygon method is____
     a) drawPolygon(Polygon p)
     b) drawPolygon()
     c) drawpolygon(Polygon p)
     d) None of the above
    
Answer: a) drawPolygon(Polygon p)

7. The dispose() is used for the disposes of this graphics context and releases any system resources that it is using.
     a) True
     b) False

Answer: a) True

8. Where are the following four methods commonly used?
     a) public void add(Component c)
     b) public void setSize(int width,int height)
     c) public void setLayout(LayoutManager m)
     d) public void setVisible(boolean)
    
Answer: Component class

9. These two ways are used to create a Frame
    By creating the object of Frame class (association)
    By extending Frame class (inheritance)

     a) True
     b) False

Answer: a) True

10. AWT stands for?
     a) Applet Windowing Toolkit
     b) Abstract Windowing Toolkit
     c) Absolute Windowing Toolkit
     d) None of the above
    
Answer: a) Abstract Windowing Toolkit

11. Which following method is used to set the graphics current color to the specified color in the    graphics class? 
     a) public abstract void setFont(Font font)
     b) public abstract void setColor(Color c)
     c) public abstract void drawString(String str, int x, int y)
     d) None of the above
    
Answer: b) public abstract void setColor(Color c)

12. Which following method can set or change the text in a Label 
     a) setText()
     b) getText()
     c) All the above
     d) None of the above
    
Answer: a) setText()

13. Which following class is provides many methods for graphics programming?
     a) java.awt
     b) java.Graphics
     c) java.awt.Graphics
     d) None of the above
    
Answer: c) java.awt.Graphics

14. AWT is used for GUI programming in java
     a) True
     b) False

Answer: a) True

Comments

  1. Lucky Club Live Casino Site | 100% up to €200
    Lucky Club is the best and most reliable online casino. With over 80 online 카지노사이트luckclub casinos powered by Microgaming, you can choose from over 200.

    ReplyDelete

Post a Comment

Popular Post

Part-2 | Perform API Testing or Automation of Rest APIs/Web Services using Rest-assured Java Library

Exception Handling Methods In TestNG | How do you handle TestNG exception?