Qa Given the code snippet below, what would be the output after the code executes? public...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Qa Given the code snippet below, what would be the output after the code executes? public class Person ( } public void display() { } public class Student extends Person { public void display() { } O a. Q System.out.println("Person"); public static void main(String[] args) { Student student = new Student (); Person person = student; } System.out.println("Student"); O b. Student Student person.display(); student.display(); O c. Person Person Person Student O d. Student Person } Given the code snippet below, what would be the output after the code executes? public class Person { public void display() { System.out.println("Person"); public class Lecturer extends Person { public void myMethod () { System.out.println("Method in Lecturer"); } public static void main(String[] args) { Person objRef= new Lecturer(); objRef.display(); objRef.myMethod(); O a. The code will not execute as there is a compile-time error. O b. Person Method in Lecturer O c. Method in Lecturer Person (3 O d. The code will not execute as there is a run-time error. Which is NOT a correct explanation of the code given below. public class Person { public String name; public void display() { } } System.out.println("Person"); public class Lecturer extends Person ( public int age; public void display() { } System.out.println("Lecturer"); } public static void main(String[] args) { Person objRef = new Lecturer(); objRef.name= "Goo"; Lecturer lec (Lecturer) objRef; lec.age = 21; objRef.display (); lec.display(); System.out.println(lec.name "/" lec.age); O a. Person objRef = new Lecturer(); objRef.name = "Goo"; is an example of Upcasting O b. Lecturer lec = (Lecturer) objRef; lec.age = 21; O c. objRef.display(); lec.display(); outputs: Lecturer Lecturer O d. System.out.println(lec.name + "/" + lec.age); outputs: Goo/21 Oe. The code will not compile. Qa Given the code snippet below, what would be the output after the code executes? public class Person ( } public void display() { } public class Student extends Person { public void display() { } O a. Q System.out.println("Person"); public static void main(String[] args) { Student student = new Student (); Person person = student; } System.out.println("Student"); O b. Student Student person.display(); student.display(); O c. Person Person Person Student O d. Student Person } Given the code snippet below, what would be the output after the code executes? public class Person { public void display() { System.out.println("Person"); public class Lecturer extends Person { public void myMethod () { System.out.println("Method in Lecturer"); } public static void main(String[] args) { Person objRef= new Lecturer(); objRef.display(); objRef.myMethod(); O a. The code will not execute as there is a compile-time error. O b. Person Method in Lecturer O c. Method in Lecturer Person (3 O d. The code will not execute as there is a run-time error. Which is NOT a correct explanation of the code given below. public class Person { public String name; public void display() { } } System.out.println("Person"); public class Lecturer extends Person ( public int age; public void display() { } System.out.println("Lecturer"); } public static void main(String[] args) { Person objRef = new Lecturer(); objRef.name= "Goo"; Lecturer lec (Lecturer) objRef; lec.age = 21; objRef.display (); lec.display(); System.out.println(lec.name "/" lec.age); O a. Person objRef = new Lecturer(); objRef.name = "Goo"; is an example of Upcasting O b. Lecturer lec = (Lecturer) objRef; lec.age = 21; O c. objRef.display(); lec.display(); outputs: Lecturer Lecturer O d. System.out.println(lec.name + "/" + lec.age); outputs: Goo/21 Oe. The code will not compile.
Expert Answer:
Answer rating: 100% (QA)
The image shows two code snippets along with multiplechoice questions about the expected output after execution Starting with the first code snippet T... View the full answer
Related Book For
Fundamentals Of Electric Circuits
ISBN: 9780073301150
3rd Edition
Authors: Matthew Sadiku, Charles Alexander
Posted Date:
Students also viewed these programming questions
-
(a) Explain how a limit worth may be tended to at run-time, both in a syntaxtree middle person and in collected code. What is the importance word "settled" already? [3 marks] (b) Give a model program...
-
Data set Theory Assume an informational record with one association parent including matches (a, b) where a can't try not to be a parent of b. (a) Write a Datalog demand which gives the graph of...
-
Consider the following reaction: 2 NO(g) 2 N(g) + O(g) part A: Express the rate of the reaction in terms of the change in concentration of each of the reactants and products. Part B: In the first...
-
FirstIn Company reported profit of $90,000 in 2016. When counting its inventory on December 31, 2016, the company forgot to include items stored in a separate room in the warehouse. As a result,...
-
A 1600-kg (empty) truck rolls with a speed of 2.5 m/s under a loading bin, and a mass of 3500 kg is deposited into the truck. What is the trucks speed immediately after loading?
-
Use a temperature sensor and a motion sensor to determine the average temperature in a room when a person is present.
-
You were requested to personally deliver your auditors report to the board of directors of Sebal Manufacturing Corporation and answer questions posed about the financial statements. While reading the...
-
what ways do emerging technologies, such as artificial intelligence and genetic engineering, challenge traditional ethical paradigms, and how should society navigate the ethical dilemmas they present...
-
Write a simple Java calculator program that perform addition, subtraction, multiplication, or division of two numbers entered by the user. The user should select the required operation and the...
-
A man needed money to but lawn equipment. he borrowed $790.00 for five months and paid $67.96 in interest. what was the rate of interest? (round to one decimal place as needed)
-
In addition to out-of-pocket expenses, many health insurance plans have waiting periods and exclusions that limit what the insurance plan needs to pay in benefits. A waiting period is a set period of...
-
Mrs. Pulido, a Filipina residing in Malabon died a widow on October 1, 2000, leaving the following properties: A parcel of land in New York Php 1, 000, 000 House and lot (conjugal family home) 600,...
-
Periodic inventory by three methods; cost of goods sold The units of an item available for sale during the year were as follows: Jan. 1 Inventory 40 units at $126 Mar. 10 Purchase 40 units at $138...
-
Sam Incs last annual dividend (D0) was $2.40 per share, and the firms required return is 14%. Dividends are expected to grow at a constant 5% annually, what should be the market value of Sams share?
-
Calculate the cost of lime and soda required for softening 1 million litres of water containing: (MgHCO3)2 = 73 mg/L; MgSO4 = 120 mg/L; CaSO4 = 68 mg/L; CaCl2 = 111 mg/L. The cost of lime of 80%...
-
Pearson Education, a publisher of college textbooks, would like to know if students prefer traditional textbooks or digital textbooks. A random sample of students was asked their preference and the...
-
If v0 (0) = -1V,obtain v0 (t) in the circuit of Fig. 16.42. 1 1 Yo 0.5 F (t) 411(1)
-
Find the Laplace transforms of the following: (a) g(t) = 6cos(4t 1) (b) f (t) = 2tu(t)+ 5e3(t2)u(t 2)
-
Use PSpice to determine the z parameters of the circuit in Fig. 19.125. Take = 2 rad/s. 2 0.25 F 2 H 4
-
Which of the following statements best describes corporate governance with respect to fraud? 1. Auditors are primarily responsible for the detection of fraud, the Board of Directors for the...
-
Which of the following is not a reason that the prevention and detection of fraud resulting from management override and collusion presents a significant challenge for the antifraud community? 1....
-
Which of the following is not an inherent part of Statement on Auditing Standards, No. 99/113? 1. Greater scrutiny of the chief executive and chief financial officers personal financial condition 2....
Study smarter with the SolutionInn App