<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&lt;Double&gt; seq;</p>
<p>// <strong>precondition:</strong> numberOfValues &gt; 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&lt;Double&gt; seq = new
ArrayList&lt;Double&gt;();</p>
<p>for (int k = 0; k &lt; numberOfValues; k++)</p>
<p>seq.add(new Double(Math.random()));</p>
<p>II. seq = new ArrayList&lt;Double&gt;();</p>
<p>for (int k = 0; k &lt; numberOfValues; k++)</p>
<p>seq.add(new Double(Math.random()));</p>
<p>III.   ArrayList&lt;Double&gt; temp = new
ArrayList&lt;Double&gt;();</p>
<p>for (int k = 0; k &lt; 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> 

HTML Online Editor & Compiler

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.

About HTML

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.

Syntax help

Fundamentals

  • Any HTML document must start with document declaration <!DOCTYPE html>
  • HTML documents begin with <html> and ends with </html>
  • Headings are defined with <h1> to <h6> where <h1> is the highest important heading and <h6> is the least important sub-heading.
  • Paragrahs are defined in <p>..</p> tag.
  • Links are defined in <a> tag.

    Example:

    <a href="https://onecompiler.com/html">HTML online compiler</a>
    
  • Images are defined in <img> tag, where src attribute consists of image name.
  • Buttons are defined in <button>..</button> tag
  • Lists are defined in <ul> for unordered/bullet list and <ol> for ordered/number list, and the list items are defined in <li>.

HTML Elements and Attributes

  • HTML element is everything present from start tag to end tag.
  • The text present between start and end tag is called HTML element content.
  • Anything can be a tagname but it's preferred to put the meaningful title to the content present as tag name.
  • Do not forget the end tag.
  • Elements with no content are called empty elements.
  • Elements can have attributes which provides additional information about the element.
  • In the below example, href is an attribute and a is the tag name.

    Example:

    <a href="https://onecompiler.com/html">HTML online compiler</a>
    

CSS

CSS(cascading style sheets) describes how HTML elements will look on the web page like color, font-style, font-size, background color etc.

Example:

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;
}

HTML Tables

  • HTML Tables are defined in <table> tag.
  • Table row should be defined in <tr> tag
  • Table header should be defined in <th> tag
  • Table data should be defined in <td> tag
  • Table caption should be defined in <caption> tag

HTML-Javascript

  • Javascript is used in HTML pages to make them more interactive.
  • <script> is the tag used to write scripts in HTML
  • You can either reference a external script or write script code in this tag.

Example

<script src="script.js"></script>