course homepage course calendar
- Sytem.out.println("Everyone is born free!");
- float myRootBeerFloat = rootBeer + vanillaIceCream;
- myAnswer = 2 + mySum(myNumber + myOtherNumber);
public _____ Person
{
private _____ firstName;
private _____ lastName;
private Date birthDate;
/**
* This is the constructor for the class Person
* it takes the name as parameter
*/
public _____ Person(String firstName, String lastName, Date birthDate)
{
___________ = firstName;
this.lastName = __________;
___________ = birthDate;
}
/**
* This method returns the first name of the person
* followed by the last name.
*/
public String getName()
{
return _________________________;
}
}
public interface Shape
{
public _______ void draw(Graphics g);
public ______ ______ getArea();
public ______ ______ getPerimiter();
}
in the blanks):
// in the file MyGreatExample.java
______ ______________ MyGreatExample
{
________ String value;
private MyGreatExample(String _____, String ______)
{
value = value1 + value2;
System.___.println("Hello, your are initializing an
instance of MyGreatExample!");
}
public MyGreatExample()
{
this("A name", _________);
}
public abstract void doSomething();
public _______ computeValue()
{
return 1.0 + 3.14;
}
public _______ computeValue()
{
return 1.0 + 3.14;
}
}
// still in the same file!
class MyOtherClass _________ MyGreatExample()
{
public MyOtherClass()
{
______("one", "two");
}
public void doSomething()
{
return _______;
}
}
public abstract class MyClass
{
private String name = 1;
public Myclass()
{
}
public void getName()
{
return name;
}
public String getSomethingElse()
{
// do something here
// and do more around here
return;
}
public void setName(String name)
{
name = name;
}
public void doSomethingElse(int somethingElse)
{
somethingElse += (somethingElse / somethingElse);
return somethingElse;
}
}
5. mark and correct the different errors in this code:
public class TestClass
{
private TestClass()
{
}
public static void main(String args[])
{
for (i = 0; true; i ++)
{
if (i > 54)
break;
if (i < 10)
System.out.println("I am happy.");
if ( (i > 10) & (i < 30))
System.out.println("I am still happy.");
else
{
System.out.println("Okay, I am annoyed")
}
}
}
}
- 0
- 1
- 67
- 3
- 5
- 6
- 2
public class TestClass2
{
public int convert(int value);
{
int returnValue = 0;
switch (value)
{
case 0:
returnValue = value;
break;
case 5:
returnValue = value+3;
case 3:
case 6:
case 9:
return value;
case 2:
break;
case 1:
returnValue = value*value;
default:
returnValue = value * returnValue;
break;
}
return returnValue;
}
}
8. what is the output of the hello method for the following inputs:
value1 = 3; value2 = 5;
value1 = 0; value2 = 3;
value1 = 5; value2 = 2;
public class MyHelloTest
{
public int hello(int value1, int value2)
{
while (true)
{
value1 += value2;
if ((value1 % 3) != 0)
return value2;
if ((value2 % 3) == 1)
value1 += 10;
else if (value1 > 23)
break;
if (value1 == value2)
return 123;
}
for (int i = 0; i < 3; i++)
{
value2 += value2;
}
switch (value1)
{
case 1:
case 5:
case 10:
case 23:
case 24:
return value1;
case 33:
break;
default:
value2 = 67;
break;
}
return 0;
}
}
_____________________
course
homepage course
calendar