Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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 TempClassint j
int ;
public class C
public static void mainString args
TempClass temp new TempClass ;
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 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 ;
public Test String t
System.out.println Test;
public static void mainString args
Test test new Test;
System.out.println testx ;
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 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:
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 compiletime; this is called dynamic binding.
A polymorphic reference is declared as class but unless is final or base type, can refer to an object of class or to an object of any class derived from
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started