Class-and-object
Question 1 |
What is the output of the following JAVA program ?
Class Test {
public static void main(String[] args) {
Test obj = new Test();
obj.start();
}
void start() {
String stra = ”do”;
String strb = method(stra);
System.out.print(“: ”+stra + strb);
}
String method(String stra) {
stra = stra + ”good”;
System.out.print(stra);
return“ good”;
}
}
Class Test {
public static void main(String[] args) {
Test obj = new Test();
obj.start();
}
void start() {
String stra = ”do”;
String strb = method(stra);
System.out.print(“: ”+stra + strb);
}
String method(String stra) {
stra = stra + ”good”;
System.out.print(stra);
return“ good”;
}
}
dogood : dogoodgood | |
dogood : gooddogood | |
dogood : dodogood | |
dogood : dogood |
Question 2 |
The memory occupied by an object type of data in VB is
1 byte | |
2 byte | |
4 byte | |
8 byte |
Question 2 Explanation:
![](https://solutionsadda.in/wp-content/uploads/2021/06/VB.jpeg)
![](https://solutionsadda.in/wp-content/uploads/2019/03/Screenshot_202.png)