Methods Quiz

By Mickey Arnold
Last updated 10 months ago
10 Questions

What is a method?

When writing a method, you must always have an open and close what ?

What is output by the code below?
public class CS
{
public void one()
{
System.out.print("fun");
}
}
//code in the main of another class
CS test = new CS();
test.one();

What is output by the code below?
public class CS
{
public void one()
{
System.out.print("fun");
}
}
//code in the main of another class
CS test = new CS();
test.one();
test.one();

What is output by the code below?
public class CS
{
public void one()
{
System.out.print("fun");
}
}
//code in the main of another class
CS test = new CS();
test.one();
test.one();
test.one();
test.one();

What is output by the code below?
public class CS
{
public void one()
{
System.out.print("go");
}
public void two()
{
System.out.print("back");
}
}
//code in the main of another class
CS test = new CS();
test.one();
test.two();

What is output by the code below?
public class CS
{
public void one()
{
System.out.print("go");
}
public void two()
{
System.out.print("back");
}
}
//code in the main of another class
CS test = new CS();
test.one();
test.two();
test.two();

What is output by the code below?
public class CS
{
public void one()
{
System.out.print("go");
}
public void two()
{
System.out.print("back");
}
}
//code in the main of another class
CS test = new CS();
test.one();
test.two();
test.one();
test.two();

What is output by the code below?
public class CS
{
public void one()
{
System.out.print("go");
}
public void two()
{
System.out.print("back");
}
}
//code in the main of another class
CS test = new CS();
test.two();
test.one();
test.two();

What is output by the code below?
public class CS
{
public void one()
{
System.out.print("go");
}
public void two()
{
System.out.print("back");
}
}
//code in the main of another class
CS test = new CS();
test.one();
test.two();
test.two();
test.one();