Knowee
Questions
Features
Study Tools

Select the correct answerWhat will be the output of the following Java code?class rectangle { int width; int length; int area; void area(int width, int length) { this.width = width; this.length = length; }  } class Output { public static void main(String args[]) { area obj = new area(); obj.area(5 , 6); System.out.println(obj.length + " " + obj.width); } }Options6 55 630 00 30

Question

Select the correct answerWhat will be the output of the following Java code?class rectangle { int width; int length; int area; void area(int width, int length) { this.width = width; this.length = length; }  } class Output { public static void main(String args[]) { area obj = new area(); obj.area(5 , 6); System.out.println(obj.length + " " + obj.width); } }Options6 55 630 00 30

...expand
🧐 Not the exact question you are looking for?Go ask a question

Solution

The code will not compile. The reason is that you are trying to create an object of class 'area' which does not exist. You should create an object of class 'rectangle'. So, none of the options are correct.

Similar Questions

Select the correct answerAssuming that the required imports are done, what will be the output of the following Java code?class rectangle {    int width;    int length;    int area;    void area() {        area = width*length;        System.out.println(area);    }}    class Output {    public static void main(String args[]) {         rectangle obj = new rectangle();        obj.width=5;        obj.length=6;        obj.area();    }}Options1301136

Select the correct answerWhat will be the output of the following Java program? class shape {  int breadth;  int height;  int area;  void area()  {   area = 1/2 * breadth * height;  }   void area(int x)  {   area = x;  }  }  class triangle  {  public static void  main(String args[])  {   shape obj = new shape();   obj.breadth = 4;   obj.height = 4;   obj.area(4);    System.out.println(obj.area);   }  }Options04816

Select the correct answerWhat will be the output of the following Java code?  class Area {    public static void main(String args[])     {          double radii, pi, area;       radii = 6.6;       pi = 3.14;       area = pi * radii * radii;       System.out.println(area);    }   }Options136136.7784136.77136.7760000

Area of a RectangleCreate a Java program that calculates the area of a rectangle using variables to store the length and width.Print out the result.Constraints:NAExample:Input:5.04.0Output:20.0

elect the correct answerWhat will be the output of the following Java code?class rhombus    {        int d1;        int d2;        int area;    public void area()        {            area = (d1*d2)/2;            System.out.println(area);        }    }    class Output    {        public static void main(String args[])        {            rhombus obj = new rhombus();            obj.d1=8;            obj.d2=2;            obj.area();        }    }OptionsRun time error168Compilation error

1/3

Upgrade your grade with Knowee

Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.