<div class="ugc-base question-body-text"> <div class=""><p><strong>4. The question refer to the following declarations.</strong></p> <p>public class Point</p> <p>{</p> <p>private double myX;</p> <p>private double myyY;</p> <p>// postcondition: this Point has coordinates (0,0)</p> <p>public Point ()</p> <p>{ /* implementation not shown */ }</p> <p>// postcondition: this Point has coordinates (x,y)</p> <p>public Point(double x, double y)</p> <p>{ /* implementation not shown */ }</p> <p>// other methods not shown</p> <p>}</p> <p>public class Circle</p> <p>{</p> <p>private Point myCenter;</p> <p>private double myRadius;</p> <p>// postcondition: this Circle has center at (0, 0) and radius 0.0</p> <p>public Circle()</p> <p>{ /* implementation not shown */ }</p> <p>// postcondition: this Circle has the given center and radius</p> <p>public Circle(Point center, double radius)</p> <p>{ /* implementation not shown */ }</p> <p>// other methods not shown</p> <p>}</p> <p>In a client program which of the following correctly declares and initializes Circle circ with center at (29.5, 33.0) and radius 10.0 ?</p> <ul> <li> <p>Circle circ = new Circle(29.5, 33.0, 10.0);</p> <p>Circle circ = new Circle(29.5, 33.0, 10.0);,</p> <p>A</p> </li> <li> <p>Circle circ = new Circle((29.5, 33.0), 10.0);</p> <p>Circle circ = new Circle((29.5, 33.0), 10.0);</p> <p>B</p> </li> <li> <p>Circle circ = new Circle(new Point (29.5, 33.0), 10.0);</p> <p>Circle circ = new Circle(new Point (29.5, 33.0), 10.0);</p> <p>C</p> </li> <li> <p>Circle circ = new Circle();</p> <p>circ.myCenter = new Point(29.5, 33.0);</p> <p>circ.myRadius = 10.0;</p> <p>Circle circ = new Circle();, , circ.myCenter = new Point(29.5, 33.0);, , circ.myRadius = 10.0;,</p> <p>D</p> </li> <li> <p>Circle circ = new Circle();</p> <p>circ.myCenter = new Point();</p> <p>circ.myCenter.myX = 29.5;</p> <p>circ.myCenter.myY = 33.0;</p> <p>cire.myRadius = 10.0;</p> </li> </ul> <p><strong>5. </strong></p> <p>Consider the following classes.</p> <p>public class Base</p> <p>{</p> <p>public Base()</p> <p>{</p> <p>System.out.print("Base" + " ");</p> <p>}</p> <p>}</p> <p>public class Derived extends Base</p> <p>{</p> <p>public Derived()</p> <p>{</p> <p>System.out.print("Derived" + " ");</p> <p>}</p> <p>}</p> <p>Assume that the following statement appears in another class.</p> <p>Derived d1 = new Derived();</p> <p>What is printed as a result of executing the statement?</p> <ul> <li> <p>Nothing is printed because the statement is a variable declaration.</p> <p>Nothing is printed because the statement is a variable declaration.</p> <p>A</p> </li> <li> <p>Base</p> <p>Base</p> <p>B</p> </li> <li> <p>Derived</p> <p>Derived</p> <p>C</p> </li> <li> <p>Base Derived</p> <p>Base Derived</p> <p>D</p> </li> <li> <p>Derived Base</p> <p>Derived Base</p> <p>E</p> </li> </ul> <p><strong>6.</strong></p> <p>Consider the following declaration of the class NumSequence, which has a constructor that is intended to initialize the instance variable seq to an ArrayList of numberOfValues random floating-point values in the range [0.0, 1.0).</p> <p>public class NumSequence</p> <p>{</p> <p>private ArrayList<Double> seq;</p> <p>// <strong>precondition:</strong> numberOfValues > 0</p> <p>// <strong>postcondition</strong>: seq has been initialized to an ArrayList of</p> <p>// length numberOfValues; each element of seq</p> <p>// contains a random Double in the range [0.0, 1.0)</p> <p>public NumSequence(int numberOfValues)</p> <p>{</p> <p>/* <em>missing code</em> */</p> <p>}</p> <p>}</p> <p>Which of the following code segments could be used to replace /* <em>missing code</em> */ so that the constructor will work as intended?</p> <p>I. ArrayList<Double> seq = new ArrayList<Double>();</p> <p>for (int k = 0; k < numberOfValues; k++)</p> <p>seq.add(new Double(Math.random()));</p> <p>II. seq = new ArrayList<Double>();</p> <p>for (int k = 0; k < numberOfValues; k++)</p> <p>seq.add(new Double(Math.random()));</p> <p>III. ArrayList<Double> temp = new ArrayList<Double>();</p> <p>for (int k = 0; k < numberOfValues; k++)</p> <p>temp.add(new Double(Math.random()));</p> <p>seq = temp;</p> <ul> <li> <p>II only</p> <p>II only</p> <p>A</p> </li> <li> <p>III only</p> <p>III only</p> <p>B</p> </li> <li> <p>I and II</p> <p>I and II</p> <p>C</p> </li> <li> <p>I and III</p> <p>I and III</p> <p>D</p> </li> <li> <p>II and III</p> <p>II and III</p> <p>E</p> </li> </ul> </div> </div>
Write, Run & Share HTML code online using OneCompiler's HTML online Code editor for free. It's one of the robust, feature-rich online Code editor for HTML language, running on the latest version HTML5. Getting started with the OneCompiler's HTML compiler is simple and pretty fast. The editor shows sample boilerplate code when you choose language as HTML
. You can also specify the stylesheet information in styles.css
tab and scripts information in scripts.js
tab and start coding.
HTML(Hyper Text Markup language) is the standard markup language for Web pages, was created by Berners-Lee in the year 1991. Almost every web page over internet might be using HTML.
<!DOCTYPE html>
<html>
and ends with </html>
<h1>
to <h6>
where <h1>
is the highest important heading and <h6>
is the least important sub-heading.<p>..</p>
tag.<a>
tag.
<a href="https://onecompiler.com/html">HTML online compiler</a>
<img>
tag, where src
attribute consists of image name.<button>..</button>
tag<ul>
for unordered/bullet list and <ol>
for ordered/number list, and the list items are defined in <li>
.<a href="https://onecompiler.com/html">HTML online compiler</a>
CSS(cascading style sheets) describes how HTML elements will look on the web page like color, font-style, font-size, background color etc.
Below is a sample style sheet which displays heading in green and in Candara font with padding space of 25px.
body{
padding: 25px;
}
.title {
color: #228B22;
font-family: Candara;
}
<table>
tag.<tr>
tag<th>
tag<td>
tag<caption>
tag<script>
is the tag used to write scripts in HTML<script src="script.js"></script>