61. What will be the result of compiling and running the given code?
class A{
int b=10;
private A(){
this.b=7;
}
int f(){
return b;
}
}
class B extends A{
int b;
}
public class Test{
public static void main(String[] args){
A a = new B();
System.out.println(a.f());
}
}
class A{
int b=10;
private A(){
this.b=7;
}
int f(){
return b;
}
}
class B extends A{
int b;
}
public class Test{
public static void main(String[] args){
A a = new B();
System.out.println(a.f());
}
}
62. Which component is responsible to run java program?
63. Which of the below is not a Java Profiler?
64. What is true about constructor?
65. Which statement is true about java?
66. What is not the use of "this" keyword in Java?
67. When does method overloading is determined?
68. Which of these operators is used to allocate memory for an object?
69. What is true about Class.getInstance()?
70. What will be the output of the following Java program?
class recursion
{
int func (int n)
{
int result;
result = func (n - 1);
return result;
}
}
class Output
{
public static void main(String args[])
{
recursion obj = new recursion() ;
System.out.print(obj.func(12));
}
}
class recursion
{
int func (int n)
{
int result;
result = func (n - 1);
return result;
}
}
class Output
{
public static void main(String args[])
{
recursion obj = new recursion() ;
System.out.print(obj.func(12));
}
}
Read More Section(Constructors and Methods)
Each Section contains maximum 100 MCQs question on Constructors and Methods. To get more questions visit other sections.