Submitted by c-admin on Thu, 05/30/2019 - 01:44
You can call only public and protected constructors of the super class from a subclass if the subclass is not in the same package because only those are inherited.
Select 1 option
A. True
B. False
Submitted by c-admin on Thu, 05/30/2019 - 01:41
Which of the following are true about the "default" constructor?
Select 2 options
A. It is provided by the compiler only if the class does not define any constructor.
B. It initializes the instance members of the class.
C. It calls the default 'no-args' constructor of the super class.
D. It initializes instance as well as class fields of the class.
E. It is provided by the compiler if the class does not define a 'no- args' constructor.
Submitted by c-admin on Thu, 05/30/2019 - 01:39
What will the following program print?
public class TestClass{
static int someInt = 10;
public static void changeIt(int a){
a = 20; }
public static void main(String[] args){
changeIt(someInt);
System.out.println(someInt); } }
Select 1 option
A. 10
B. 20
C. It will not compile.
D. It will throw an exception at runtime.
E. None of the above.
Submitted by c-admin on Thu, 05/30/2019 - 01:34
Complete the code using blue labels on the right so that the ouput will 210.
(You may have some blanks empty.)
public int a= a+offset;
return a;
u.update(a,111);
a= u.update(a,111);
return;
public void
public class Updater
{
update(int a, int offset)
{
}
public static void main(String [] args)
{
Updater u= new Updater();
int a = 99;
System.out.println(a);
}
}
Submitted by c-admin on Thu, 05/30/2019 - 01:17
Consider the following class definition:
public class TestClass{
public static void main(){ new TestClass().sayHello(); } //1
public static void sayHello(){ System.out.println("Static Hello World"); public void sayHello() { System.out.println("Hello World "); } //3
}
What will be the result of compiling and running the class?
Select 1 option
A. It will print Hello World.
B. It will print Static Hello World.
C. Compilation error at line 2.
D. Compilation error at line 3.
E. Runtime Error.
Pages