Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //What will be the result of attempting to compile the following program?
- public class TestClass{
- long l1;
- public void TestClass(long pLong) { l1 = pLong ; } //(1)
- public static void main(String args[]){
- TestClass a, b ;
- a = new TestClass(); //(2)
- b = new TestClass(5); //(3)
- }
- }
- /* Select 1 option
- A. A compilation error will be encountered at (1), since constructors should not
- specify a return value.
- B. A compilation error will be encountered at (2), since the class does not have a
- default constructor.
- C. A compilation error will be encountered at (3).
- D. The program will compile correctly.
- E. It will not compile because parameter type of the constructor is different than the
- type of value passed to it.*/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement