Click here to Skip to main content
13,447,674 members (50,096 online)

Do my homework for me

Narendrareddy07 asked:

Open original thread
What can directly access and change the value of the variable roomNr?
package com.mycompany;
public class Hotel {
public int roomNr = 100;

A) Only the Hotel class.
B) Any class.
C) Any class in com.mycompany package.
D) Any class that extends Hotel.

d is a valid, non-null java.util.Date object
df is a valid, non-null java.text.DateFormat object set to the current locale.
What outputs the current locale's country name and the appropriate version of date?
Locale l = Locale.getDefault();
System.out.println(l.getDisplayCountry() + " " + df.format(d));

Locale l = Locale.getLocale();

Locale l = Locale.getLocale();
System.out.println(l.getDisplayCountry() + " " + df.setDateFormat(d));

Locale l = Locale.getDefault();
System.out.println(l.getDisplayCountry() + " " + df.setDateFormat(d));


What is true about objects referenced by a, b, aa at the line labeled "// some code goes here"?
class A {
    private B b;
    public A() {
        this.b = new B(this);

class B {
    private A a;
    public B(A a) {
        this.a = a;

public class Test { 
    public static void main(String args[]) {
        A aa = new A();
        aa = null;
        // some code goes here

A) The objects referenced by a and b are eligible for garbage collection.
B) None of these objects are eligible for garbage collection.
C) Only the object referenced by "a" is eligible for garbage collection.
D) Only the object referenced by "b" is eligible for garbage collection.
E) Only the object referenced by "aa" is eligible for garbage collection.

What do you need to do to correct compilation errors? (Select two)
public class Creature {
private int legCount;
private int wingCount;

public Creature(int legCount) {
this.legCount = this.legCount;
this.wingCount = 0;

public String toString() {
return "legs=" + this.legCount + " wings=" + wingCount;

public class Animal extends Creature {
public Animal(int legCount) {
this.wingCount = 0;


A) insert a call to super() into Creature constructor.
B) insert a call to super() into Animal constructor.
C) insert a call to this() into Animal constructor.
D) insert a call to super(legCount) into Animal constructor.
E) change the wingCount variable in the class Creature to protected.
F) change the string "this.wingCount = 0" in the class Animal to "super.wingCount = 0"
Tags: Java


When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
  4. Don't tell someone to read the manual. Chances are they have and don't get it. Provide an answer or move on to the next question.
Let's work to help developers, not make them feel stupid.
Please note that all posts will be submitted under the The Code Project Open License (CPOL).

Advertise | Privacy |
Web03 | 2.8.180318.3 | Last Updated 26 Mar 2009
Copyright © CodeProject, 1999-2018
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100