Question: What is wrong in the following code? class TempClass int i; public void TempClass ( int j ) ( int i = j ; }

What is wrong in the following code?
class TempClass
int i;
public void TempClass(int j)(
int i=j;
}
}
public class C
public static void main(String[] args)(
TempClass temp = new TempClass (2);
}
}
A. The program has a compile error because TempClass does not have a default constructor.
B. The program has a compile error because TempClass does not have a constructor with an int argument.
C. The program compiles fine, but it does not run because class C is not public.
D. The program compiles and runs fine.
Which of the following statements are true?
A. Local variables do not have default values.
B. Data fields have default values.
C. A variable of a primitive type holds a value of the primitive type.
D. A variable of a reference type holds a reference to where an object is stored in the memory.
E. You may assign an int value to a reference variable.
Analyze the following code.
public class Test
int x;
public Test (String t)(
System.out.println ("Test");
}
public static void main(String[] args)(
Test test = new Test();
System.out.println (test.x) ;
}
}
A. The program has a compile error because System.out.println method cannot be invoked from the constructor.
B. The program has a compile error because x has not been initialized.
C. The program has a compile error because you cannot create an object from the class that defines the object.
D. The program has a compile error because Test does not have a default constructor.
State weather the following statements is True or False:
[2
Marks]
Two or more references can refer to the same object.
Assigning an ancestor object to a reference is considered to be a widening () conversion and must be done with a cast.
Polymorphic references are resolved at compile-time; this is called dynamic () binding.
A polymorphic reference v is declared as class C, but unless C is final or base () type, v can refer to an object of class C or to an object of any class derived from C.
 What is wrong in the following code? class TempClass int i;

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!