Home / MCQ Bank / Computer
Computer Constructors And Methods

What will be the output of the following Java program? class box { int width; int height; int length; } class mainclass { public static void main(String args[]) { box obj1 = new box(); box obj2 = new box(); obj1.height = 1; obj1.length = 2; obj1.width = 1; obj2 = obj1; System.out.println(obj2.height); } }

Select the best option to verify your answer:
Show Correct Answer
Correct Answer: Option A • 1

Related Computer Questions

What will be the output of the following C code if the system time is 4:27 PM? #include<stdio.h> #include<time.h> int main() { struct tm *ptr; time_t t; char str[100]; t = time(NULL); ptr = localtime(&t); strftime(str,100,"%H %p %M minutes",ptr); puts(str); return 0; } In method overriding, which keyword is used in the child class to indicate that a method is intended to override a superclass method? Which of the following will show popup-box? Which of the following structure declaration doesn't require pass-by-reference? What will be the output of the following C++ code? #include <iostream> #include <vector> using namespace std; int main() { vector<int> v; for (int i = 1; i <= 5; i++) v.push_back(i); vector<int> :: const_iterator i; i = v.begin(); *i = 3; for (i = v.begin(); i != v.end(); ++i) cout << *i << " "; cout<<endl; return 0; }