What is the code to swap two numbers?
What is the code to swap two numbers?
What is the output for following code
int a=20,b=10;
if((a<b)&&(b++ == 11)){
a++;
System.out.println(a);
}
System.out.println(b);
What is the output for following code
int a=20,b=10;
if((a<b)&&(b++ == 11)){
a++;
System.out.println(a);
}
System.out.println(b);
What is the output for following code
public static void main(String[] args)
{
A a = new B();
B b = new B();
System.out.println(a.c + " " + a.getValue() +
" " + b.getValue() + " " + b.getSuperValue());
}
}
class A
{
protected char c = 'A';
char getValue()
{
return c;
}
}
class B extends A
{
protected char c = 'B';
char getSuperValue()
{
return super.c;
}
What is the output for following code
public static void main(String[] args)
{
A a = new B();
B b = new B();
System.out.println(a.c + " " + a.getValue() +
" " + b.getValue() + " " + b.getSuperValue());
}
}
class A
{
protected char c = 'A';
char getValue()
{
return c;
}
}
class B extends A
{
protected char c = 'B';
char getSuperValue()
{
return super.c;
}
What is the output for following code
int i=97;
switch(i){
case 'a' :System.out.println("Hello");
case ‘A’ :System.out.println("Bye");break;
}
What is the output for following code
int i=97;
switch(i){
case 'a' :System.out.println("Hello");
case ‘A’ :System.out.println("Bye");break;
}
What is the return type of a method that does not returns any value
What is the return type of a method that does not returns any value
What is the output for following code
class Equality {
Integer x;
Integer y;
boolean isequal() {
return(x == y);
}
}
class Output {
public static void main(String args[])
{
Equality obj = new Equality();
obj.x = 5;
obj.y = 5;
System.out.println(obj.isequal()); }
}
What is the output for following code
class Equality {
Integer x;
Integer y;
boolean isequal() {
return(x == y);
}
}
class Output {
public static void main(String args[])
{
Equality obj = new Equality();
obj.x = 5;
obj.y = 5;
System.out.println(obj.isequal()); }
}
What is the output for following code
public class Fibonacci {
public static void main(String[] args) {
int lo = 1;
int hi = 1;
System.out.println(lo);
while (hi < 50) {
System.out.print(“ -“ +hi);
hi = lo + hi;
lo = hi - lo;
}
}
}
.
What is the output for following code
public class Fibonacci {
public static void main(String[] args) {
int lo = 1;
int hi = 1;
System.out.println(lo);
while (hi < 50) {
System.out.print(“ -“ +hi);
hi = lo + hi;
lo = hi - lo;
}
}
}
.
Which of these keywords cannot used for a class which has been declared final?
Which of these keywords cannot used for a class which has been declared final?
Can a static block exist without a main() method ?
Can a static block exist without a main() method ?
What is the output for following code
class Box{
int width;
int height;
int length;
int volume;
protected void volume() {
volume = width*height*length;
System.out.println(volume);
}
}
public class sample1 {
public static void main(String args[])
{
Box obj = new Box();
obj.volume();
}
}
What is the output for following code
class Box{
int width;
int height;
int length;
int volume;
protected void volume() {
volume = width*height*length;
System.out.println(volume);
}
}
public class sample1 {
public static void main(String args[])
{
Box obj = new Box();
obj.volume();
}
}
What is the code at Line 1 to execute the code
int main()
{
int n = 6, i;
int fact = 1;
for(i=1;i<=n;i++)
//Line 1
printf("%d",fact);
return 0;
}
What is the code at Line 1 to execute the code
int main()
{
int n = 6, i;
int fact = 1;
for(i=1;i<=n;i++)
//Line 1
printf("%d",fact);
return 0;
}
Which of the following for loops will be an infinite loop?
Which of the following for loops will be an infinite loop?
What is the output for following code
int a=4,b=5,c=6;
if(a > b)
System.out.println(“1”);
else if(a < b)
System.out.println(“2”);
else if(b < 6)
System.out.println(“3”);
else
System.out.println(“4”);
What is the output for following code
int a=4,b=5,c=6;
if(a > b)
System.out.println(“1”);
else if(a < b)
System.out.println(“2”);
else if(b < 6)
System.out.println(“3”);
else
System.out.println(“4”);
What is the output for following code
class Alpha
{
public String type = "a ";
public Alpha() { System.out.print("alpha "); }
}
public class Beta extends Alpha
{
public Beta() { System.out.print("beta "); }
void go()
{
type = "b ";
System.out.print(this.type + super.type);
}
public static void main(String[] args)
{
new Beta().go();
}
}
What is the output for following code
class Alpha
{
public String type = "a ";
public Alpha() { System.out.print("alpha "); }
}
public class Beta extends Alpha
{
public Beta() { System.out.print("beta "); }
void go()
{
type = "b ";
System.out.print(this.type + super.type);
}
public static void main(String[] args)
{
new Beta().go();
}
}
What is the output for following code
int ++a=100;
System.out.println(++a);
What is the output for following code
int ++a=100;
System.out.println(++a);
Java static block is the group of statements that gets executed when the class is not loaded into memory by Java Class Loader .
Java static block is the group of statements that gets executed when the class is not loaded into memory by Java Class Loader .
What is the code at Line 1 and Line 2 to execute the code
int main() {
int n = 10,i;
if(n == 1)
printf("0");
else if(n == 2)
printf("1");
else {
int a = 0, b = 1, c;
for(i = 3; i <= n; i++) {
c = a + b;
____; // Line 1
____; // Line 2
}
printf("%d",c);
}
return 0;
}
What is the code at Line 1 and Line 2 to execute the code
int main() {
int n = 10,i;
if(n == 1)
printf("0");
else if(n == 2)
printf("1");
else {
int a = 0, b = 1, c;
for(i = 3; i <= n; i++) {
c = a + b;
____; // Line 1
____; // Line 2
}
printf("%d",c);
}
return 0;
}
what is the output for following code?
Public static void main(String args[]){
int i,j=1;
i = (j++>=2)?2:1;
switch(i){
case 0:System.out.println(0);break;
case 1:System.out.println(1);
case 2:System.out.println(2);break;
case 3:System.out.println(3);break;
}
}
what is the output for following code?
Public static void main(String args[]){
int i,j=1;
i = (j++>=2)?2:1;
switch(i){
case 0:System.out.println(0);break;
case 1:System.out.println(1);
case 2:System.out.println(2);break;
case 3:System.out.println(3);break;
}
}
What is the output for following code
public class Calculator
{
int num = 100;
public void calc(int num) { this.num = num * 10; }
public void printNum() { System.out.println(num); }
public static void main(String[] args)
{
Calculator obj = new Calculator();
obj.calc(2);
obj.printNum();
}
}
What is the output for following code
public class Calculator
{
int num = 100;
public void calc(int num) { this.num = num * 10; }
public void printNum() { System.out.println(num); }
public static void main(String[] args)
{
Calculator obj = new Calculator();
obj.calc(2);
obj.printNum();
}
}
IIB stands for :___________
IIB stands for :___________
What is the output for following code
int i=5;
do{
i++;
}while(i<3);
System.out.println(i--);
What is the output for following code
int i=5;
do{
i++;
}while(i<3);
System.out.println(i--);
What is the code at Line 1 and Line 2 and Line 3 to execute the code
public static void main(String []args){
int i,n=17,count=0;
for( /// insert code Line 1){
if( n%i == 0){
// insert code Line 2
}
}
if( //insert code Line 3 )
System.out.println("prime");
else
System.out.println("not a prime");
}
What is the code at Line 1 and Line 2 and Line 3 to execute the code
public static void main(String []args){
int i,n=17,count=0;
for( /// insert code Line 1){
if( n%i == 0){
// insert code Line 2
}
}
if( //insert code Line 3 )
System.out.println("prime");
else
System.out.println("not a prime");
}
Java does not support ___________
Java does not support ___________
What is the output for following code
private int data = 5;
public int getData()
{
return this.data;
}
public int getData(int value)
{
return (data+1);
}
public int getData(int... value)
{
return (data+2);
}
public static void main(String[] args)
{
Test temp = new Test();
System.out.println(temp.getData(9, 11, 14));
}
What is the output for following code
private int data = 5;
public int getData()
{
return this.data;
}
public int getData(int value)
{
return (data+1);
}
public int getData(int... value)
{
return (data+2);
}
public static void main(String[] args)
{
Test temp = new Test();
System.out.println(temp.getData(9, 11, 14));
}
Loose coupling in java programs can be done by
Loose coupling in java programs can be done by
Can we call sub class constructor from super class constructor?
Can we call sub class constructor from super class constructor?
What is the output for following code
public static void main(String []args){
int i=0,j=0;
while(true){
i++;
if(j<=5)
continue; //Line 1
j++;
System.out.println(i +" " + j);
}
}
What is the output for following code
public static void main(String []args){
int i=0,j=0;
while(true){
i++;
if(j<=5)
continue; //Line 1
j++;
System.out.println(i +" " + j);
}
}
Which of these methods of Object class can clone an object?
Which of these methods of Object class can clone an object?
What is the output for following code
public class testmeth{
static int i = 1;
public static void main(String args[]){
System.out.println(i+” , “);
m(i);
System.out.println(i);
}
public void m(int i){
i += 2;
}
}
What is the output for following code
public class testmeth{
static int i = 1;
public static void main(String args[]){
System.out.println(i+” , “);
m(i);
System.out.println(i);
}
public void m(int i){
i += 2;
}
}
what is the output for following code
class T {
int t = 20;
T() {
t = 40;
}
}
class Main {
public static void main(String args[]) {
T t1 = new T();
System.out.println(t1.t);
}
what is the output for following code
class T {
int t = 20;
T() {
t = 40;
}
}
class Main {
public static void main(String args[]) {
T t1 = new T();
System.out.println(t1.t);
}
What is the output for following code
class Test1 {
int x = 10;
public static void main(String[] args)
{
System.out.println(x);
}
static
{
System.out.print(x + " ");
}
}
What is the output for following code
class Test1 {
int x = 10;
public static void main(String[] args)
{
System.out.println(x);
}
static
{
System.out.print(x + " ");
}
}
What is the output of the following code
int a=10,b;
b=a++ + ++a + a++ + ++a;
System.out.println(“a is :”+ a +” -- b is:”+b);
What is the output of the following code
int a=10,b;
b=a++ + ++a + a++ + ++a;
System.out.println(“a is :”+ a +” -- b is:”+b);
Platform independent code file created Source file is understandable by ____________
Platform independent code file created Source file is understandable by ____________
What is the output for following code
public static void main(String []args){
switch(2)
{
case 1:System.out.println("Hi");
break;
case 1+1:System.out.println("Hello");
break;
default: System.out.println("Bye");
break;
}
}
What is the output for following code
public static void main(String []args){
switch(2)
{
case 1:System.out.println("Hi");
break;
case 1+1:System.out.println("Hello");
break;
default: System.out.println("Bye");
break;
}
}
Which of these statement is incorrect?
Which of these statement is incorrect?
What is the output for following code
int x=4,y=3;
if (!(x < 3 || y > 2))
System.out.println("first case");
else
System.out.println("second case");
What is the output for following code
int x=4,y=3;
if (!(x < 3 || y > 2))
System.out.println("first case");
else
System.out.println("second case");
Which is a valid keyword in java?
Which is a valid keyword in java?
Java allow, Same program to be executed on multiple Operating System?
Java allow, Same program to be executed on multiple Operating System?
What is the output for following code
int i=0,j=1;
switch((i++ == j)?1:2)
{
case 1:System.out.println(1);break;
case 2:System.out.println(2);break;
}
What is the output for following code
int i=0,j=1;
switch((i++ == j)?1:2)
{
case 1:System.out.println(1);break;
case 2:System.out.println(2);break;
}
What is the value of a[1] after the executed the code
int a[]= { 0 , 2, 4, 1,3}
for(int i=0;i<a.length;i++)
a[i]=a[ (a[i] +3 ) %a.length];
What is the value of a[1] after the executed the code
int a[]= { 0 , 2, 4, 1,3}
for(int i=0;i<a.length;i++)
a[i]=a[ (a[i] +3 ) %a.length];
What is the output for following code
public static void main(String []args){
System.out.println("Hello World");
for(;true;) //Line 1
System.out.println("hello"); //Line 2
System.out.println("Bye"); //Line 3
}
What is the output for following code
public static void main(String []args){
System.out.println("Hello World");
for(;true;) //Line 1
System.out.println("hello"); //Line 2
System.out.println("Bye"); //Line 3
}
What is the code at Line 1 and Line 2 to execute the code
int i,j,n=5;
for( //Line 1 ){
for(j = i ;j >= 0 ; j-- )
System.out.print(" ");
for( //Line 2 )
System.out.print("*");
System.out.println();
}
What is the code at Line 1 and Line 2 to execute the code
int i,j,n=5;
for( //Line 1 ){
for(j = i ;j >= 0 ; j-- )
System.out.print(" ");
for( //Line 2 )
System.out.print("*");
System.out.println();
}
What is the code at Line 1 and Line 2 after execute the code
public static void main(String []args){
System.out.println("Hello World");
int i=121,sum=0,n,r;
n=i;
while( //insert code Line 1){
r=n%10;
// insert code Line 2 here
n=n/10;
}
System.out.println(sum);
}
What is the code at Line 1 and Line 2 after execute the code
public static void main(String []args){
System.out.println("Hello World");
int i=121,sum=0,n,r;
n=i;
while( //insert code Line 1){
r=n%10;
// insert code Line 2 here
n=n/10;
}
System.out.println(sum);
}
What is the output for following code
public static void main(String []args){
System.out.println("Hello World");
for(int i=5;i>=0;i--){
for(int j=0;j<=i;j++)
System.out.print("*");
System.out.println();
}
}
What is the output for following code
public static void main(String []args){
System.out.println("Hello World");
for(int i=5;i>=0;i--){
for(int j=0;j<=i;j++)
System.out.print("*");
System.out.println();
}
}
What is the numerical range of a char?
What is the numerical range of a char?
What is the output for following code
public static void main(String args[]) {
int num1,num2,num3;
num1 = 100;
num2 = ++num1;
num3 = num2++ + ++num1;
System.out.println("num1 = " + num1);
System.out.println("num2 = " + num2);
System.out.println("num3 = " + num3);
}
What is the output for following code
public static void main(String args[]) {
int num1,num2,num3;
num1 = 100;
num2 = ++num1;
num3 = num2++ + ++num1;
System.out.println("num1 = " + num1);
System.out.println("num2 = " + num2);
System.out.println("num3 = " + num3);
}
what is the code at Line 1 and Line 2 to get output like this
1
2 1
3 2 1
4 3 2 1
5 4 3 2 1
int i,j,n=5;
for( i = n ; i >= 0 ; i--){
for( //Line 1 )
System.out.print(" ");
for( //Line 2 )
System.out.print(j);
System.out.println();
}
what is the code at Line 1 and Line 2 to get output like this
1
2 1
3 2 1
4 3 2 1
5 4 3 2 1
int i,j,n=5;
for( i = n ; i >= 0 ; i--){
for( //Line 1 )
System.out.print(" ");
for( //Line 2 )
System.out.print(j);
System.out.println();
}
What is the output for following code
Public static void main (String args[]){
System.out.print(“”==””);
System.out.print(“ “);
System.out.print(“A”==”A”);
System.out.print(“ “);
System.out.print(“a===A”);
}
What is the output for following code
Public static void main (String args[]){
System.out.print(“”==””);
System.out.print(“ “);
System.out.print(“A”==”A”);
System.out.print(“ “);
System.out.print(“a===A”);
}
What is the following code
public class SIB2 {
static {
System.out.println("SIB");
}
{
System.out.println("IIB");
}
public SIB2() {
System.out.println("Constructor");
}
public static void main(String[] args) {
SIB2 sib1 = new SIB2();
}
What is the following code
public class SIB2 {
static {
System.out.println("SIB");
}
{
System.out.println("IIB");
}
public SIB2() {
System.out.println("Constructor");
}
public static void main(String[] args) {
SIB2 sib1 = new SIB2();
}
What is the output for following code
public class Test
{
static int x = 2;
Test(int i) { x = i; }
public static void main(String[] args) {
Test t = new Test(5);
System.out.println("x = " + t.x);
}
}
What is the output for following code
public class Test
{
static int x = 2;
Test(int i) { x = i; }
public static void main(String[] args) {
Test t = new Test(5);
System.out.println("x = " + t.x);
}
}
public class MainMethod
{
public static int main(String[] args)
{
return 1;
}
}
public class MainMethod
{
public static int main(String[] args)
{
return 1;
}
}
What is the code for Line 1 to get output like this
*
***
*****
*******
*********
int i,j,n=5;
for( i=1 ; i<=n ; i++){
for( j=I ; j<=n ; j++)
System.out.print(" ");
for(//Line 1)
System.out.print("*");
System.out.println();
}
What is the code for Line 1 to get output like this
*
***
*****
*******
*********
int i,j,n=5;
for( i=1 ; i<=n ; i++){
for( j=I ; j<=n ; j++)
System.out.print(" ");
for(//Line 1)
System.out.print("*");
System.out.println();
}
JVM is a _______________.
JVM is a _______________.
What is the output for following code
public class Main
{
public static void gfg(String s)
{
Ssytem.out.println("String");
}
public static void gfg(Object o)
{
Sysatem.out.println("Object");
}
public static void main(String args[]){
gfg(2.5);
}
}
What is the output for following code
public class Main
{
public static void gfg(String s)
{
Ssytem.out.println("String");
}
public static void gfg(Object o)
{
Sysatem.out.println("Object");
}
public static void main(String args[]){
gfg(2.5);
}
}
When Overloading does not occur?
When Overloading does not occur?
What is the output for following code
public class sample{
static int a;
static {
a = 4;
System.out.println ("a = " + a);
}
sample(){
a = 10;
System.out.println ("a = " + a);
}
public static void func() {
a = a + 1;
System.out.println ("a = " + a);
}
public static void main(String []args){
sample obj = new sample();
obj.func();
}
}
What is the output for following code
public class sample{
static int a;
static {
a = 4;
System.out.println ("a = " + a);
}
sample(){
a = 10;
System.out.println ("a = " + a);
}
public static void func() {
a = a + 1;
System.out.println ("a = " + a);
}
public static void main(String []args){
sample obj = new sample();
obj.func();
}
}
Java Object oriented programming is/are
Java Object oriented programming is/are
What is the output for following code
public static void main(String []args){
for(int i=0;i<10;i++)
{
if( i == 5)
continue;
System.out.println(i);
}
}
What is the output for following code
public static void main(String []args){
for(int i=0;i<10;i++)
{
if( i == 5)
continue;
System.out.println(i);
}
}
What is the output for following code
Public static void main(String args[]{
int i=5,j=3;
if( (i=3) == j) //Line 1
System.out.println(j);
else
System.out.println(++j);
}
What is the output for following code
Public static void main(String args[]{
int i=5,j=3;
if( (i=3) == j) //Line 1
System.out.println(j);
else
System.out.println(++j);
}
What is the output for following code
public static void main(String []args){
switch('a'){
case 1:System.out.println("Hi");
break;
case 97:System.out.println("Hello");
break;
case 'a':System.out.println("Bye");
break;
default : break;
}
}
What is the output for following code
public static void main(String []args){
switch('a'){
case 1:System.out.println("Hi");
break;
case 97:System.out.println("Hello");
break;
case 'a':System.out.println("Bye");
break;
default : break;
}
}
Which of the following converts human readable file into platform independent code file in java?
Which of the following converts human readable file into platform independent code file in java?
What is the output for following code
final class Complex {
private double re, im;
public Complex(double re, double im) {
this.re = re;
this.im = im;
}
Complex(Complex c) {
System.out.println("Copy constructor called");
re = c.re;
im = c.im;
}
public String toString() {
return "(" + re + " + " + im + "i)";
}
}
class Main {
public static void main(String[] args) {
Complex c1 = new Complex(10, 15);
Complex c2 = new Complex(c1);
Complex c3 = c1;
System.out.println(c2); }
}
What is the output for following code
final class Complex {
private double re, im;
public Complex(double re, double im) {
this.re = re;
this.im = im;
}
Complex(Complex c) {
System.out.println("Copy constructor called");
re = c.re;
im = c.im;
}
public String toString() {
return "(" + re + " + " + im + "i)";
}
}
class Main {
public static void main(String[] args) {
Complex c1 = new Complex(10, 15);
Complex c2 = new Complex(c1);
Complex c3 = c1;
System.out.println(c2); }
}
Which option, inserted at Line 1 , produce the output 12?
Public static void main(String args[]){
int x=0;
//insert code here //Line 1
do{
}while(x++ < y);
}
Which option, inserted at Line 1 , produce the output 12?
Public static void main(String args[]){
int x=0;
//insert code here //Line 1
do{
}while(x++ < y);
}
Which of the following is the correct expression that evaluates to true if the number x is between 1 and 100 or the number is negative?
Which of the following is the correct expression that evaluates to true if the number x is between 1 and 100 or the number is negative?
What is the out put for following code
public static void main(String []args){
int i=-23;
if(i)
System.out.println("Hi");
else
System.out.println("Hello" );
What is the out put for following code
public static void main(String []args){
int i=-23;
if(i)
System.out.println("Hi");
else
System.out.println("Hello" );
What is the output for following code
int i=97;
if('a' == i) //Line 1
System.out.println("Hello");
else
System.out.println("Bye");
What is the output for following code
int i=97;
if('a' == i) //Line 1
System.out.println("Hello");
else
System.out.println("Bye");
What is the output for following code
public class StaticVariableExample
{
static int a =10,b=10;
public static void main (String args[]){
StaticVariableExample s1 = new StaticVariableExample ();
System.out.println ("s1.a value:"+s1.a);
s1.b=20; //Line 1
System.out.println ("s1.a value:"+s1.b);
}
}
What is the output for following code
public class StaticVariableExample
{
static int a =10,b=10;
public static void main (String args[]){
StaticVariableExample s1 = new StaticVariableExample ();
System.out.println ("s1.a value:"+s1.a);
s1.b=20; //Line 1
System.out.println ("s1.a value:"+s1.b);
}
}
What is the out put for following code
public static void main(String []args){
int i,j=0,k=0;
for(i=0;i<=5;i++)
for(j=0;j<=5;j++)
k=++i + k;
System.out.println(i +" " + j + " " + k);
}
What is the out put for following code
public static void main(String []args){
int i,j=0,k=0;
for(i=0;i<=5;i++)
for(j=0;j<=5;j++)
k=++i + k;
System.out.println(i +" " + j + " " + k);
}
Which one of these lists contains only Java programming language keywords?
Which one of these lists contains only Java programming language keywords?
-
-
-
-
-
What is the output for following code
Class ConsMain{
private int x=10;
private ConsMain(){
x = 5;
}
public static void main(String[] args){
ConsMain obj = new ConsMain();
System.out.println("Value of x = " + obj.x);
}
}
What is the output for following code
Class ConsMain{
private int x=10;
private ConsMain(){
x = 5;
}
public static void main(String[] args){
ConsMain obj = new ConsMain();
System.out.println("Value of x = " + obj.x);
}
}