Java Quiz

Welcome to your Java Quiz

class SC2 
{

public static void main(String [] args)
{
SC2 s = new SC2();
s.start();
}

void start()
{
int a = 3;
int b = 4;
System.out.print(" " + 7 + 2 + " ");
System.out.print(a + b);
System.out.print(" " + a + b + " ");
System.out.print(foo() + a + b + " ");
System.out.println(a + b + foo());
}

String foo()
{
return "foo";
}
}
public class Test 
{

public static void aMethod() throws Exception
{
try /* Line 5 */
{
throw new Exception(); /* Line 7 */
}
finally /* Line 9 */
{
System.out.print("finally "); /* Line 11 */
}
}
public static void main(String args[])
{
try
{
aMethod();
}
catch (Exception e) /* Line 20 */
{
System.out.print("exception ");
}
System.out.print("finished"); /* Line 24 */
}
}
Which is a valid keyword in java?
Which is a reserved word in the Java programming language?
You want a class to have access to members of another class in the same package. Which is the most restrictive access that accomplishes this objective?
Given a method in a protected class, what access modifier do you use to restrict access to that method to only the other members of the same class?
The syntax to import a package is

Leave a comment