LANAGE
// Demonstrating some String methods.
class StringDemo2 {
public static void main(String args[]) {
String strOb1 = "First String";
String strOb2 = "Second String";
String strOb3 = strOb1;
System.out.println("Length of strOb1: " +
strOb1.length());
System.out.println("Char at index 3 in strOb1: " +
strOb1.charAt(3));
if(strOb1.equals(strOb2))
System.out.println("strOb1 == strOb2");
else
System.out.println("strOb1 != strOb2");
if(strOb1.equals(strOb3))
System.out.println("strOb1 == strOb3");
else
System.out.println("strOb1 != strOb3");
}
}
What is the output of the above program?
Length of strOb1: 11
Char at index 3 in strOb1: s
strOb1 != strOb2
strOb1 == strOb3
Length of strOb1: 12
Char at index 3 in strOb1: s
strOb1 != strOb2
strOb1 == strOb3
Length of strOb1: 13
Char at index 3 in strOb1: s
strOb1 != strOb2
strOb1 == strOb3
None of the above
Demonstrate String arrays.
class StringDemo3 {
public static void main(String args[]) {
String str[] = { "one", "two", "three" };
for(int i=0; i str[0]: one
str[1]: two
str[2]: three
str[1]: one
str[2]: two
str[3]: three
str[0]: two
str[1]: three
str[2]: four
None of the above
// Here, Box is extended to include color.
class ColorBox extends Box {
int color; // color of box
ColorBox(double w, double h, double d, int c) {
width = w;
height = h;
depth = d;
color = c;
}
}
In the above program which oops property is used?
Polymarphisam
Inheritance
overloading
None of the above
// Using super to overcome name hiding.
class A {
int i;
}
// Create a subclass by extending class A.
class B extends A {
int i; // this i hides the i in A
B(int a, int b) {
super.i = a; // i in A
i = b; // i in B
}
void show() {
System.out.println("i in superclass: " + super.i);
System.out.println("i in subclass: " + i);
}
}
class UseSuper {
public static void main(String args[]) {
B subOb = new B(1, 2);
subOb.show();
}
}
what is the ouput of the above program ?THE
i in superclass: 1
i in subclass: 2
i in superclass: 2
i in subclass: 1
i in superclass: 3
i in subclass: 4
None of the above
Users’ browser settings will override the settings you make in your style sheets by default. It is easy for users to change the fonts, background colors, and size of the text. Users can also choose to turn off functionality such as Java, JavaScript, and image display.
False
True