What will be the output of the given program class A { } int m=20, n=30; void display() { } } class B extends A{ int n=40; void display() { System.out.println(m); } System.out.println(n); Main I
Q: public class MyOutput { public static void main(String[] args) { int totalNumbers=6; Double…
A: Given int totalNumber=6 double dblAverage=4.5 Integer yourNumber = new Integer(20);//Wrapper class…
Q: Find error and correct it : public class ProgramLayout { public static void main (String[]…
A: We are going to predict the error in the following code.
Q: PROBLEM STATEMENT: Return a number, 1 greater than the given number. Can you write this assignment…
A: The answer is..
Q: class TenNums { private: int *p; public: TenNums
A: Dear Student, The answer to your question is given below -
Q: Consider the following function: void display() { static int i; if(i<=printf("HELLO")) { i=i+2;…
A: void display(){ static int i; if(i<=printf("HELLO")){ i=i+2; display(); }} int main(){ int i=0;…
Q: Java: ShowStudent.java: class ShowStudent { public static void main (String args[]) {…
A: In this question we have to write a java code for the Student class as per the given problem…
Q: Given the following code segments: class Programme{ b) private String name; private static int…
A: To Do: To write the above class in better design and pattern.
Q: amount the same, y, n, why? public class CheckingAct { private String actNum;…
A: 1. If you declare any variable in the methods then they are local variable and scope of variable is…
Q: Exercise 1 - What is wrong in the code below: public class Main { public static void…
A: Let's solve all the errors code by code: Exercise 1 given code: public class Main { public…
Q: 3. a Given the following code: public class Test { public static void main (String [] args) { Object…
A: ********************** Explaination of the code ************************* In the first part and in…
Q: class Test { private int a; private int b; public Test() { a = 5; b = a - 3; }…
A: The above code contains no error. The program conatins a class named Test with two data members.…
Q: 2. Determine the output from the following program.
A: Given: What is the output of the followong below code public class Walmart extends retailBusiness {…
Q: In C++ class rectangleType { public: void setLengthWidth(double x, double y); //Sets the…
A: A C++ program to compute the area and perimeter of a rectangle using class structure.
Q: 14 out of What will be the output of the given program class A { } int m=20, n=30; void display() {…
A: Problem Analysis:The problem is based on the basics of inheritance in java programming language.
Q: In C++ QUESTION 14 class rectangleType { public: void setLengthWidth(double x, double y);…
A: In order to write and test the function definition of perimeter we also need to write the function…
Q: What will be the output of the given program: class A { } int m=20, n=30; void display() { } } class…
A: 1) Lets analyze the Java program we have in question It contains a parent Class A which has…
Q: Fix all the syntax errors in the following program. 1.//Program to calculate the area of circle…
A: Fixing syntax error in following java code
Q: b) Given the following code segments: class Programme{ private String name; private static int…
A: A class is contains two types of members. Data members and methods.
Q: Java Input. class main { publicstaticvoid main(String args[]) { int a =1; int b =2; int c =3; a…
A: | is bitwise or operator which operates on binary individual bits and do OR operator work. >>…
Q: public class MysteryReturn 2 { 3 public static void main(String[] args) 4 { 5 int x = 1; 6 int y =…
A: Please find the answer below :
Q: What will the given code prints on the output screen.
A: Given, Programming language = JAVA Code: class isNaN_output { public static void main(String…
Q: QUESTION 9 Public Class Employee { public static int y; Private int age; Public Employee0{ age=0;}…
A: I have given the output for the above code.
Q: class Output { public static void main(String args[]) { Integer i = new Integer(557); float x =…
A: Given, The programming language used = JAVA Code: class Output { public static void…
Q: this is my code using System; class Reverse3 { static void Main() { int firstInt =…
A: The mistake that you are making is that by the time you are printing the values in order and in…
Q: r.Show();}} 1.Identify the output of the program above. Please show the tracing table. 2. Identify…
A: 1) Output for above program is :
Q: . What is the output of this program? final class A { int i; } class B extends A { int j;…
A: Two classes are constructed in the above code, one is class-A and the other is class-B, and class-B…
Q: 12. What is the output of this program? class A { int i;
A: Both classes A and B have a display() method; however, because class B inherits class A, when the…
Q: public class MathF{ public static void main(String[] args) { char[] grade=new char[4]; grade[1]='B';…
A: Provided the output of the above code in the next step with a screenshot.
Q: public class AutoBoxingUnboxingDemo { static int f (Integer v) { return v; } public static void main…
A: Here have to determine about find example of autoboxing, unboxing from given code.
Q: Find an incorrect statement about the following code. class TenNums { private: int *p; public:…
A: In class TenNums private int *p; / is an array of integers that is private. public TenNums() // is a…
Q: Lab 9 C balance the same, y, n, why? class CheckingAct { . . . . private int…
A: There is only call by value in java, not call by reference. Thus if we try to change value of formal…
Q: In C++ Find the five errors. For each error, state the line number, explain the error and show a…
A: Answer:)
Q: Complete the below program demonstrating Garbage collection. (1 Mark) public class Test { public…
A: Garbage Collection is process of destroying the unused objects.
Q: Question public class MyProgram ( if (h 30) system.out.print("Evening"); t = t + 5;…
A: I have provided the answer based on java Programming. Detailed comments are included for a better…
Q: Not all tests passed. X 1: Compare output ^ Output differs. See highlights below. Input 100 Annual…
A: I modified the code and provide the code with the correct output and code screenshot and code…
Q: #include int c = 2; int f1(int a, int b); int f2(int a, int b); int main() { int a = 3; int b; b =…
A: Solution- here is the given code which is compiled in C++ and predict 10 as output- #include…
Q: public class Turn{public static void main(String[] args){// Different initial values will be used…
A: Equations that are used to replace the value of variable x and y: - The initial values of the…
Q: 1. Insert the missing part of the code below to output the string. public class MyClass { public…
A: To complete the provided Java code and output the string, you should use the System.out.println…
Q: class Main { public static void main(String args[]) String obj = "I am a programmer.";…
A: Given, Code: class Main { public static void main( String args[]) { String obj =…
Q: Given the following C# code: class Program { static void Main(string[] args) { B obj - new B();…
A: A class is inherited in the B class and the method display() which has the same signature in both…
Q: complete the missing code. public class Exercise09_04Extra { public static void main(String[] args)…
A: After completing the code, I have provided JAVA CODE along with CODE SCREENSHOT and OUTPUT…
Q: public class Main { public static void main(String args[]) { Main m = new Main();…
A: Here is the step by step instructions Make sure that all the files are in the same folder and…
Q: Java Input class main { public static void main(String args[]) {…
A: The output for the given JAVA program is given below
Step by step
Solved in 4 steps with 1 images
- 1- public class MathF{ public static void main(String[] args) 3 {char[] grade%=new char[4]; grade[1]='B'; 5 grade[3]='C'; 6 Integer d1= new Integer(6); Integer d2= new Integer(10); 8 if(d1!= d2){ System.out.println("grades do not match "); System.out.println("Result: "+Math.sqrt(d1+d2)); 11 } 12 else 13- { System.out.println("Marks are same"); 14 for (int i-0;i<4;i++) 15 System.out.println(grade[i]); } 16 }} Answer:class TenNums {private: int *p; public: TenNums() { p = new int[10]; for (int i = 0; i < 10; i++) p[i] = i; } void display() { for (int i = 0; i < 10; i++) cout << p[i] << " "; }};int main() { TenNums a; a.display(); TenNums b = a; b.display(); return 0;} Continuing from Question 4, let's say I added the following overloaded operator method to the class. Which statement will invoke this method? TenNums TenNums::operator+(const TenNums& b) { TenNums o; for (int i = 0; i < 10; i++) o.p[i] = p[i] + b.p [i]; return o;} Group of answer choices TenNums a; TenNums b = a; TenNums c = a + b; TenNums c = a.add(b);C# Write a program named TestScoreList that accepts eight int values representing student test scores. Display each of the values along with a message that indicates how far it is from the average. An example of how the results should be output is as follows: Test # 0: 89 From average: 6Test # 1: 78 From average: -5 using System;using static System.Console;class TestScoreList{static void Main(){// Write your main here}}
- Java Input. class Output { public static void main(String args[]) { int a = 1; int b = 2; int c; int d; c = ++b; d = a++; c++; b++; ++a; System.out.println(a + " " + b + " " + c); } } Output.8) Now use the Rectangle class to complete the following tasks: - Create another object of the Rectangle class named box2 with a width of 100 and height of 50. Note that we are not specifying the x and y position for this Rectangle object. Hint: look at the different constructors) Display the properties of box2 (same as step 7 above). - Call the proper method to move box1 to a new location with x of 20, and y of 20. Call the proper method to change box2's dimension to have a width of 50 and a height of 30. Display the properties of box1 and box2. - Call the proper method to find the smallest intersection of box1 and box2 and store it in reference variable box3. - Calculate and display the area of box3. Hint: call proper methods to get the values of width and height of box3 before calculating the area. Display the properties of box3. 9) Sample output of the program is as follow: Output - 1213 Module2 (run) x run: box1: java.awt. Rectangle [x=10, y=10,width=40,height=30] box2: java.awt.…TASK 3. Console Input and Output. Review Scanner class and its methods, Implement the following code, make sure it runs without errors. 1 package 1lessons; 3 import java.util.Scanner; 4 5 public class ReportSum3 { public static void main(String args[]) { Scanner sc = new Scanner(System. in); 60 7 8 // Prompt the user to enter the first integer System.out.println("Enter the value for 'a' and press Enter: "); int a = sc.nextInt(); // Prompt the user to enter the second integer System.out.println("Enter the value for 'b' and press Enter: "); int b = sc.nextInt(); 10 11 12 13 14 15 16 17 18 19 20 21 22 } //Close the Scanner. It's a good practice to release the resource that was acquired sc.close(); // Display the result System.out.printf( "Provided Integers: %4d and %4d, the total is %5d\n", a, b, (a + b)); } To simplify the task, we came out with the idea to use Methods. Implement a method to add two integers.
- FIX THE CODE PROVIDED BELOW Part 2 - Syntax Errors and Troubleshooting The code below has many syntax (and other) errors. Tasks:Compile the code and fix the errors one at a time. // Lab1a.java // This short class has several bugs for practice. // Authors: Carol Zander, Rob Nash, Clark Olson, you public class Lab1a { public static void main(String[] args) { compareNumbers(); calculateDist(); } publicstatic void compareNumbers() { int firstNum = 5; int secondNum; System.out.println( "Sum is: + firstNum + secondNum ); System.out.println( "Difference is: " + (firstNum - secondNum ); System.out.println( "Product is: " + firstNun * secondNum ); } public static void calculateDistance() { int velocity = 10; //miles-per-hour int time = 2, //hoursint distance = velocity * timeSystem.out.println( "Total distance is: " distanace); } } Part 3 - Print Statements and Simple Methods Use "print" and "println" statements, but use method calls to reduce the number of repeated "print"and "println"…Q-2) Given the following code: class Calculation { int z, public void addition(int x, int y) { z = x + y; System.out.println("The sum of the given numbers:"+z); } public void Subtraction(int x, int y) { z = x-y; System.out.println("The difference between the given numbers:"+z); public class My_Calculation extends Calculation { public void multiplication(int x, int y) { z = x*y; System.out.println("The product of the given c) Give the output when this program is run: numbers:"+z); } public static void main(String args[]) { int a = 20, b = 10; } My Calculation demo = new My_Calculation(); demo.addition(a, b); demo.Subtraction(a, b); demo.multiplication(a, b); Complete the missing lines in a and b a) Name the superclass the subclass b) Suppose we wish to save the program in a text file My_Calculation. The extension should be d) Which objects (variables and methods) are inherited from the superclass? e) If you instantiate demo as Calculation demo = new My_Calculation(); in the main…In C++ class rectangleType { public: void setLengthWidth(double x, double y); //Sets the length = x; width = y; void print() const; //Output length and width double area(); //Calculate and return the area of the rectangle (length*width) double perimeter(); //Calculate and return the perimeter (length of outside boundary of the rectangle) private: double length; double width; }; Print out the area of the rectangle.