Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. What will happen when you compile and run the following code? class One{ public static void process(){ System.out.print(Parent); } } class Two extends One{

1. What will happen when you compile and run the following code? class One{ public static void process(){ System.out.print("Parent"); } } class Two extends One{ public static void process(){ super.process(); System.out.print("Child"); } } public class Test{ public static void main(String args[]){ One one = new Two(); one.process(); } }

a. Parent

b. Compilation Error

c. Child

d. ParentChild

2.

Given the code fragment, what will be the output when you compile and run the code.

class One{ String className = "One"; } class Two extends One{ String className = "Two"; } public class Test{ public static void main(String[] args) { One one = new Two(); System.out.println(one.className); } }

a. Compilation error

b. Two

c. Runtime error

d. One

3.

What will happen when you compile and run the following code?

class One{ public abstract One(); } class Two extends One{ public Two(){ System.out.println("Two"); } } public class Test{ public static void main(String[] args) { Two two = new Two(); } }

a. Compilation error

b. Runtime error

c. Two

4.

What will happen when you compile and run the following code?

public class Test{ public void doNothing(Object object){ System.out.println("Object"); } public void doNothing(Integer i){ System.out.println("Integer"); } public void doNothing(Double i){ System.out.println("Integer"); } public static void main(String[] args) { Test test = new Test(); test.doNothing(args); } }

a. Double

b. Integer

c. None of the above

d. Object

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

Expert Performance Indexing In SQL Server

Authors: Jason Strate, Grant Fritchey

2nd Edition

1484211189, 9781484211182

More Books

Students also viewed these Databases questions

Question

What is the difference between Needs and GAP Analyses?

Answered: 1 week ago

Question

What are ERP suites? Are HCMSs part of ERPs?

Answered: 1 week ago