Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. Assume we have a file readme.txt that contains the following data [10 points] hi 2 bye What is the output after executing the following

image text in transcribed

image text in transcribed

1. Assume we have a file readme.txt that contains the following data [10 points] hi 2 bye What is the output after executing the following main method, assume all import statements for Scanner & Exceptions have been imported. public static void main(String[] args) throws FileNotFoundException { String d =""; String a = "readme.txt"; File b = new File(a): Scanner in = new Scanner (b); String data -"*"; while (in.hasNext()) d += datat in.next(); } String output -d; System.out.println (output); } Answer: 2. Given class A1, A2, A3 below, what gets printed after executing the following code: Answer: package a3; class A1 int age = 20; } 1 } public String toString() { return "years"; public int getAge() { return age; } public void updateAmount (float f) { f = age; public void updateAge (int i) { age = i; 1 class A2 extends Al { public A2() { updateAmount (25); } public String toString() { return "age: " + ( getAge()); } } public class A3 public A3( ) { A2 b = new A2(); Al a = new Al(); System.out.println(a + " = " ); System.out.print( b); } public static void main(String[] args) A3 a = new A3(); { Al b = new Al(); System.out.println(b.getAge()); System.out.println(b + " = " ); System.out.print (b.age +1+ "old" ); } 1

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

Handbook Of Database Security Applications And Trends

Authors: Michael Gertz, Sushil Jajodia

1st Edition

1441943056, 978-1441943057

More Books

Students also viewed these Databases questions