Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Answer All the Questions Q1,Q2 and Q3 Q3. What will be the output of the following program? public class Staticdemo { static int x=10; public

image text in transcribed

Answer All the Questions Q1,Q2 and Q3

Q3. What will be the output of the following program?

public class Staticdemo { static int x=10; public static void main(string[]args) { Staticdemo t1 = new Staticdemo();

Staticdemo t2 = new Staticdemo();

t1.x = 45; System.out.print(t1.x+""); System.out.print(t2.x); } }

Q2. Which of the following lines of output are displayed by this program? class OuterClass{ String s1="java"; String s2 = "2"; public static void main(string []args){ OuterClass outer = new OuterClass(); System.out.println(outer.s2); } OuterClass(){ Inner inner = new Inner (); System.out.println(inner.s1); } class Inner{ String s1="Certification"; String s2="Exam";

Inner () { System.out.println(OuterClass.this.s1); System.out.println(this.s1); System.out.println(s2); } } }

Q1. Suppose you are designing an admission process that is part of a school program. The program only takes children aged between 6 and 15 years as well as weight between 20 and 50 kg into consideration. If you provide age outside the range, the program will cause an exception and show the message: Age is outside the range". If you provide weight outside the range, the program will cause another exception and show the message: "Weight is outside the range. Now, write down a program for the school using throw and throws keywords to implement the scenario. Q2. Which of the following lines of output are displayed by this program? class OuterClass { String si = "Java"; String s2 = "2"; | public static void main(String[] args) { OuterClass outer = new OuterClass(); System.out.println(outer.s2); } | OuterClass() { Inner inner = new Inner(); System.out.println(inner.s1); } | class Inner String 51 = "Certification"; String s2 = "Exam"; 1 Inner() { System.out.println(OuterClass.this.s1); System.out.println(this.s1); System.out.println(s2); } } }

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

Information Modeling And Relational Databases

Authors: Terry Halpin, Tony Morgan

2nd Edition

0123735688, 978-0123735683

More Books

Students also viewed these Databases questions

Question

2. Identify four types of migrant groups.

Answered: 1 week ago