1.
Creating an object is called
Correct Answer
A. Instantiation
Explanation
Instantiation refers to the process of creating an object from a class. It involves allocating memory for the object and initializing its state. In other words, instantiation is the act of creating an instance of a class, which can then be used to access the methods and properties defined within that class. Therefore, the correct answer for this question is "instantiation".
2.
Which of the following is not a part of the string class?
Correct Answer
D. ToString
Explanation
The toString method is not a part of the string class. The toString method is a method of the Object class, which is the superclass of all classes in Java. It is used to return a string representation of an object. However, the other options (compareTo, length, and concat) are all methods that are directly available in the string class. The compareTo method is used to compare two strings lexicographically, the length method is used to return the length of a string, and the concat method is used to concatenate two strings.
3.
A ___________ is a collection of classes that we can use when developing programs.
Correct Answer
B. Class library
Explanation
A class library is a collection of classes that can be utilized during program development. It provides a set of pre-defined classes that can be used to create objects and perform various operations. By using a class library, developers can save time and effort by reusing existing classes instead of creating them from scratch. This allows for more efficient and streamlined programming, as well as promoting code consistency and modularity.
4.
Which of the following is not a part of the Java standard class library
Correct Answer
C. Keyboard
Explanation
The System class and String class are both part of the Java standard class library, which contains a collection of pre-defined classes and interfaces that provide commonly used functionality. However, the Keyboard class is not a part of the Java standard class library. It is likely a custom class that is not included in the standard library.
5.
TThe Java standard class library is part of any Java development environment
Correct Answer
A. True
Explanation
The Java standard class library is a collection of pre-written classes and interfaces that provide a wide range of functionality for Java developers. It includes classes for input/output, networking, data structures, GUI components, and much more. This library is an integral part of any Java development environment and is automatically included when setting up a Java project. Therefore, the statement "The Java standard class library is part of any Java development environment" is true.
6.
Which of the following classes would allow random numbers to be generated?
Correct Answer
D. Random
Explanation
The Random class would allow random numbers to be generated. The Math class provides mathematical functions but does not generate random numbers. The Keyboard class is not a standard class in most programming languages and does not have a built-in function for generating random numbers. The String class is used for manipulating and working with strings, not generating random numbers. Therefore, the correct class for generating random numbers is the Random class.
7.
The Keyboard class is part of a package called_________
Correct Answer
B. Cs1
Explanation
The correct answer is Cs1. The Keyboard class is part of the Cs1 package.
8.
When using JCreator a shortcut to run the current program is_________
Correct Answer
A. F5
Explanation
When using JCreator, the shortcut to run the current program is F5. This shortcut allows users to quickly execute their code without having to navigate through menus or use the mouse. It is a commonly used shortcut in many programming environments and helps to streamline the development process.
9.
An applet doesn't have a _______ method
Correct Answer
A. Main
Explanation
An applet doesn't have a main method because the main method is the entry point for standalone Java applications, not applets. Applets have a different lifecycle and are typically embedded within webpages and run within a web browser. Instead of a main method, applets have init, start, stop, and destroy methods that are called at different stages of the applet's lifecycle.
10.
What do the first two numbers in page.drawLine (10, 20, 150, 45); mean?
Correct Answer
B. X & Y Coordinate
Explanation
The first two numbers in the page.drawLine function represent the X and Y coordinates. In this case, the line will start at the point (10, 20) on the page and end at the point (150, 45). The X coordinate determines the horizontal position, while the Y coordinate determines the vertical position.
11.
What do the 2nd two numbers in page.drawLine (10, 20, 150, 45); mean?
Correct Answer
A. Width and Height
Explanation
The 2nd two numbers in the page.drawLine function (10, 20, 150, 45) represent the width and height of the line being drawn. The first two numbers (10, 20) correspond to the starting point of the line, while the last two numbers (150, 45) represent the ending point. Therefore, the 2nd two numbers determine how wide and tall the line will be on the page.
12.
Which of the following would be used to draw a curved line within a Java Applet?
Correct Answer
C. DrawArc
Explanation
The drawArc method in Java Applet is used to draw a curved line. It allows the programmer to specify the starting and ending angles, as well as the width and height of the arc. This method is commonly used to create curved shapes or to draw portions of circles. Therefore, drawArc is the correct choice for drawing a curved line within a Java Applet.
13.
Within Java an oval is always drawn inside of a__________ _________
Correct Answer
B. Bounding rectangle
Explanation
In Java, when drawing an oval, it is always drawn inside a bounding rectangle. The bounding rectangle is a rectangle that completely encloses the oval shape. This rectangle acts as a reference frame for the oval, determining its position and size. The oval is then drawn within this rectangle, ensuring that it fits perfectly inside. This approach allows for easy manipulation and positioning of the oval shape within the Java program.
14.
How many numbers must be supplied with the drawArc method?
Correct Answer
C. 6
Explanation
The drawArc method in programming typically requires six numbers to be supplied. These numbers represent the coordinates and dimensions of the arc to be drawn, including the starting point, width, height, and angles. By providing these six numbers, the drawArc method can accurately render the desired arc on the screen or canvas.
15.
Applets open up using what program within JCreator?
Correct Answer
C. AppletViewer
Explanation
Applets open up using the program called AppletViewer within JCreator. This program allows developers to view and test their applets before deploying them on the web. It provides a virtual environment for running and debugging applets, making it an essential tool for applet development.
16.
Applets and Applications are coded the same way.
Correct Answer
B. False
Explanation
Applets and Applications are not coded the same way. Applets are small applications that are designed to run within a web browser, while applications are standalone programs that can be run independently. Applets are typically written in Java and require a Java Virtual Machine to run, whereas applications can be written in various programming languages and do not require a specific runtime environment. Therefore, the statement that "Applets and Applications are coded the same way" is false.
17.
Applets use a X and Y coordinate system.
Correct Answer
A. True
Explanation
Applets use a X and Y coordinate system because they are graphical programs that are designed to be embedded within web pages. The X and Y coordinate system allows applets to position and manipulate graphical elements on the screen. This system is commonly used in computer graphics to represent the location of objects in a two-dimensional space. Therefore, the statement "Applets use a X and Y coordinate system" is true.
18.
The X,Y coordinate in the upper left hand corner of an Applet screen would be___,____.
Correct Answer
C. 0,0
Explanation
The X,Y coordinate in the upper left hand corner of an Applet screen is (0,0) because the coordinate system used in computer graphics and programming typically starts at (0,0) in the upper left corner of the screen. This means that the X-axis increases as you move to the right and the Y-axis increases as you move down the screen. Therefore, the upper left corner has the coordinates (0,0).
19.
One can use negative values within x,y coordinates when designing a Java Applet?
Correct Answer
A. True
Explanation
In Java Applet, negative values within x, y coordinates can be used. This allows for positioning elements or drawing graphics outside the visible area of the applet window. It can be useful in certain cases, such as when creating animations or implementing scrolling functionality.
20.
Custom colors can be added into a Java applet
Correct Answer
A. True
Explanation
In Java, custom colors can be added into a Java applet. The Graphics class in Java provides methods such as setColor() that allow developers to specify custom colors using RGB values. These custom colors can then be used to draw shapes, fill areas, or set the background color in a Java applet. Therefore, the statement "Custom colors can be added into a Java applet" is true.
21.
Page.setColor (new Color(255,255,255)); would set the color within an Applet to.
Correct Answer
A. White
Explanation
The given code page.setColor (new Color(255,255,255)); sets the color within an Applet to white. The values (255,255,255) represent the RGB values for white, where each value ranges from 0 to 255. Therefore, the correct answer is White.
22.
Page.setColor (new Color(0,0,0)); would set the color within an Applet to.
Correct Answer
A. Black
Explanation
The given code is setting the color within an Applet to black. The method setColor is being called on the page object, and a new Color object is being passed as an argument with RGB values (0,0,0), which represents black. Therefore, the color within the Applet will be set to black.
23.
Print and println are the same
Correct Answer
B. False
Explanation
The statement "print and println are the same" is false. Although both "print" and "println" are used to display output in programming, they have different functionalities. "print" displays the output without adding a new line, while "println" displays the output and adds a new line after it. This subtle difference allows for more control over the formatting and presentation of the output.