What will be the output of the following Java code?
public class Test {
public void main(String[] args) {
int x = 6*6-2;
System.out.println(x);
}
}
public class Demo123{
public static void main(String args[]){
String s1= new String("hello");
String s2= new String("Abekus");
System.out.println(s2==s1==Abekus);
}
}
//Predict the output
import java.util.Scanner;
public class MyClass
{
public static void main(String args[])
{
StringBuffer str = new StringBuffer("ArrayforArray");
str.setCharAt(7, '0');
System.out.println(" " + str);
}
}
public class pro2{
public static void main(String args[]){
int result=0;
String str="asd456xsd858az45";
String [] arr=str.split("\\D");
for(String str2 :arr){
if(!str2.isEmpty() && result < Integer.parseInt(str2)){
result=Integer.parseInt(str2);
}
}
System.out.println(result);
result=0;
}
}
What will be the output of the following code?
class A
{
public void first (int a,float b)
{
System.out.println(" int float method");
}
public void first(float a,int b);
{
System.out.println("float int method");
}
public static void main(String[]args)
{
A a=new A();
a.first(10,10);
}
}
What will be the output of the program?
class Test
{
static int s;
public static void main(String [] args)
{
Test p = new Test();
p.start();
System.out.println(s);
}
void start()
{
int x = 7;
twice(x);
System.out.print(x + " ");
}
void twice(int x)
{
x = x*2;
s = x;
}
}
Predict the output of the following Java code.
class AbekusParent {
protected void m() {System.out.println("Abekus Parent");}
}
class AbekusChild extends AbekusParent {
@Override
void m() {System.out.println("Abekus Child");}
}
public class Main {
public static void main(String args[]) {
AbekusChild A = new AbekusChild();
A.m();
}
}
Predict the output of the following Java code:
import java.util.*;
import java.util.concurrent.LinkedBlockingQueue;
public class Abekus {
public static void main(String[] args)
throws IllegalStateException {
Queue<Integer> que
= new LinkedBlockingQueue<Integer>(4);
System.out.println(que.offer(5));
System.out.println(que.offer(34));
}
}
What will be the output of the following code?
class A
{
int a;
int b;
void add(int x)
{
a = x + 1;
}
void add(int x , int y)
{
a = x + 2;
}
}
class main
{
public static void main(String args[])
{
A a = new A();
int x = 0;
a.add(class A
{
int a;
int b;
void add(int x)
{
a = x + 1;
}
void add(int x , int y)
{
a = x + 2;
}
}
class main
{
public static void main(String args[])
{
A a = new A();
int x = 0;
a.add(4, 7);
System.out.println(a.x);
}
}6, 7);
System.out.println(a.x);
}
}