StringBuilder is slower as compare to StringBuffer
What is the value stored in x
in the following lines of Java code?
int x, y, z;
x = 0;
y = 1;
x = y = z = 8;
Which of the following method set the out stream to OutputStream?
class test{
public static void main (String[] args) {
System.out.println((7&8)+" "+(7|8));
}
}
public class outputs
{
public static void main(String args[])
{
int a=10;
int b=20;
int c=15;
int sum=0;
sum= (a%b%c)%10;
System.out.println(sum);
}
}
class test{
public static void main (String[] args) {
int a=7;
int b=15;
a+=(~b);
if(false)
{
System.out.println(~a);
}
else
{
System.out.println(b);
}
}
}
JVM(Java Virtual Machine) include class library files. True or False?
Predict the output of the following Java code.
class Abekus {
public static void main(String[] args)
{
try {
System.out.println(5/0);
}
catch(Exception e) {
System.out.println("Abekus");
}
catch(ArithmeticException e) {
System.out.println("Hello");
}
}
}
In the following Java code, which code fragment should be inserted at line 3 so that the output will be: "123abc 123abc"?
StringBuilder sb1 = new StringBuilder("123");
2. String s1 = "123";
3. sb1.append("abc"); s1 = s1.concat("abc");
4. System.out.println(sb1 + " " + s1);
What is the output of the following program?
class Volume
{
int width;
int height;
int length;
int volume;
void vol(int height, int length, int width)
{
volume = width*height*length;
}
}
class A
{
public static void main(String args[])
{
Volume v = new Volume();
v.height = 1;
v.length = 2;
v.width = 3;
v.vol(1,2,5);
System.out.println(v.volume);
}
}