In the below java code, which call to sum() method is appropriate?
class Output
{
public static int sum(int ...x)
{
return 0;
}
public static void main(String args[ ])
{
sum(10);
sum(10,20);
sum(10,20,30);
sum(10,20,30,40);
}
}
Which of these is correct about passing an argument by call-by-value process?
What is the output of the following java code?
class San
{
public void m1 (int i,float f)
{
System.out.println(" int float method");
}
public void m1(float f,int i);
{
System.out.println("float int method");
}
public static void main(String[]args)
{
San s=new San();
s.m1(20,20);
}
}
What is the output of this java program?
class overload
{
int x;
double y;
void add(int a , int b)
{
x = a + b;
}
void add(double c , double d)
{
y = c + d;
}
overload()
{
this.x = 0;
this.y = 0;
}
}
class Overload_methods
{
public static void main(String args[])
{
overload obj = new overload();
int a = 2;
double b = 3.2;
obj.add(a, a);
obj.add(b, b);
System.out.println(obj.x + " " + obj.y);
}
}
Which of these methods is given parameters via command line arguments?
How many arguments can be passed to main()?
What is recursion in Java?
Which of these data types is used by operating system to manage the recursion in Java?
Which of these will happen if recursive method does not have a base case?
What is the output of this java program?
class recursion
{
int func (int n)
{
int result;
if (n == 1)
return 1;
result = func (n - 1);
return result;
}
}
class Output
{
public static void main(String args[])
{
recursion obj = new recursion() ;
System.out.print(obj.func(5));
}
}
What is the output of this java program?
class recursion
{
int fact(int n)
{
int result;
if (n == 1)
return 1;
result = fact(n - 1) * n;
return result;
}
}
class Output
{
public static void main(String args[])
{
recursion obj = new recursion() ;
System.out.print(obj.fact(6));
}
}
What is the value of “d” after this line of java code is executed?
double d = Math.round ( 2.5 + Math.random() );
What is the output of this java program?
class Output
{
public static void main(String args[])
{
double x = 2.0;
double y = 3.0;
double z = Math.pow( x, y );
System.out.print(z);
}
}
In java, which one of these methods return the smallest whole number greater than or equal to variable X?
What will be the output of this java program?
public class Delta
{
static boolean foo(char c)
{
System.out.print(c);
return true;
}
public static void main( String[] argv )
{
int i = 0;
for (foo('A'); foo('B') && (i < 2); foo('C'))
{
i++;
foo('D');
}
}
}