Answered step by step
Verified Expert Solution
Link Copied!

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 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.
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Driven Web Sites

Authors: Joline Morrison, Mike Morrison

2nd Edition

? 061906448X, 978-0619064488

More Books

Students also viewed these Databases questions

Question

How do Dimensional Database Models differ from Relational Models?

Answered: 1 week ago

Question

What type of processing do Relational Databases support?

Answered: 1 week ago

Question

Describe several aggregation operators.

Answered: 1 week ago