Ask Experts Questions for FREE Help !
Ask
    admiral9932's Avatar
    admiral9932 Posts: 2, Reputation: 1
    New Member
     
    #1

    May 10, 2013, 11:58 AM
    java
    A programmer has written the following methods, which are supposed to insert an int into an OBT, and return the depth of an OBT respectively. Unfortunately there are some errors. Assume appropriate definitions for the instance variables empty, value, left and right, and the method setValue(), as shown in COMP16212.

    public void insert(int insertValue)
    {
    }
    public int getDepth()
    {
    else
    {
    } }
    if (empty) setValue(insertValue);

    else if (insertValue < value) left.insert(insertValue);

    else right.insert(insertValue);

    if (empty) return 0;
    int leftDepth = left.getDepth(); int rightDepth = right.getDepth(); if (leftDepth > rightDepth)
    return leftDepth + value; else
    return rightDepth + value;

    He or she creates an OBT by starting with an empty one, and inserting the numbers 15, 12, 8, 13, 20, 16, 25 in that order. What value would be returned by the getDepth() method, if it was invoked on the root node of the resulting tree?
    admiral9932's Avatar
    admiral9932 Posts: 2, Reputation: 1
    New Member
     
    #2

    May 10, 2013, 12:02 PM
    java
    Given the following initialized Java declaration:

    PrintWriter out = new PrintWriter(new FileWriter("films.txt"));
    which one of the following statements is true?

    A. Whenever the statement
    out.println("Welcome to films.txt");
    is executed it will always write the string "Welcome to films.txt" to standard
    output.

    B. An exception is thrown when the declaration is executed in a context where the
    file named films.txt has write-only permission.

    C. IftheStringvariablesisnullwhenthestatement
    out.print(s);
    is executed, a NullPointerException object will be thrown.

    D. ARuntimeExceptionexceptionwillalwaysbethrownwhenth estatement out.print("What is infinity? " + 1.0/0.0);
    is executed.

    E. The statement
    out.close();
    will compile without error because the PrintWriter class has a close() method,
    as files are not closed safely on normal termination.
    JTLUOM's Avatar
    JTLUOM Posts: 1, Reputation: 1
    New Member
     
    #3

    May 14, 2013, 08:52 PM
    Hi there admiral9932. I just wanted to ask you how did you get this question? The thing is you cannot have this because it is not available and allowed in our uni website . As a corollary of this, we are going to find your address and who you are by your IP address. We will take these all into account and if you are CS student in Manchester university. You will be out of university. Good luck in your exams
    Mr John Latham

Not your question? Ask your question View similar questions

 

Question Tools Search this Question
Search this Question:

Advanced Search

Add your answer here.


Check out some similar questions!

Java [ 1 Answers ]

public class Over { public int stack(int j, int k) { return j + k; } public int stack(int m) { return m * m; } public int stack(float f) { return (int)f * 5; } public static void main(String args) { int n = 3;

Ask for help in java [ 0 Answers ]

Hi guys can you help me on java. I want to add some data on a jcombobox from mysql database. I created 2 comboboxes. After I retrieve the necessary data from the database it will automatically fill up the first combobox. And then in the first combobox the user chooses the data he wants...

Something about java [ 1 Answers ]

Halo, I want to ask something about java question, some question had confuse, I need some hints, someone help me please, thank you! Calculate the value of π from the infinite series. Π = 4 – 4/3 +4/5 - 4/7 + 4/9 - 4/11 + …… Print a table that shows the value of π using...

Java! [ 2 Answers ]

Please will you help me with these questions... where can I find a great site that will help me answer these... 1/ Who developed Java and when? 2/ What are some unique features of Java? 3/ Is java used for websites or stand alone programs? 4/ What does it mean when I say java is an "object...

By using vc++ or java? [ 1 Answers ]

Hi, I want to make image processing application.which programming language I should use? Either vc++ or java or anything else? Please guide me early.


View more questions Search