What will be the output of this java program ?
final class Complex {
private final double re;
private final double im;
public Complex(double re, double im) {
this.re = re;
this.im = im;
}
public String toString() {
return "(" + re + " + " + im + "i)";
}
}
class Main {
public static void main(String args[])
{
Complex c = new Complex(10, 15);
System.out.println("Complex number is " + c);
}
}
What will be the output of below java code snippet?
double a = 0.02;
double b = 0.03;
double c = b - a;
System.out.println(c);
BigDecimal _a = new BigDecimal("0.02");
BigDecimal _b = new BigDecimal("0.03");
BigDecimal _c = _b.subtract(_a);
System.out.println(_c);
import java.awt.*;
class Ticker extends Component
{
public static void main (String [] args)
{
Ticker t = new Ticker();
/* Missing Statements ? */
}
}
Which of the following statements could legally be inserted into missing section of this java code?
1. boolean test = (Component instanceof t);
2. boolean test = (t instanceof Ticker);
3. boolean test = t.instanceof(Ticker);
4. boolean test = (t instanceof Component);
What is the output of this java program?
class A
{
final public int calculate(int a, int b) { return 1; }
}
class B extends A
{
public int calculate(int a, int b) { return 2; }
}
public class output
{
public static void main(String args[])
{
B object = new B();
System.out.print("b is " + b.calculate(0, 1));
}
}
What is the output of this java program?
class c
{
public void main( String[] args )
{
System.out.println( "Hello" + args[0] );
}
}
What is the output of this java program?
class access
{
public int x;
private int y;
void cal(int a, int b)
{
x = a + 1;
y = b;
}
}
class access_specifier
{
public static void main(String args[ ])
{
access obj = new access();
obj.cal(2, 3);
System.out.println(obj.x + " " + obj.y);
}
}
In java, which of these is the correct way of calling a parent class constructor having no parameters from a subclass?
In java, which of these methods of Object class is used to clone an object?
Which of these methods of Object class is used to obtain class of an object at run time in java?
Which of these is not abstract in java?
In java, if a class inheriting an abstract class does not define all of its methods then the class will be _________ .
Which of these is not a correct statement about java?
In java, class member declared protected becomes _________ member of subclass.
Which of these is correct way of inheriting class A by class B in java ?
Which two classes use the Shape class correctly?
A. public class Circle implements Shape
{
private int radius;
}
B. public abstract class Circle extends Shape
{
private int radius;
}
C. public class Circle extends Shape
{
private int radius;
public void draw();
}
D. public abstract class Circle implements Shape
{
private int radius;
public void draw();
}
E. public class Circle extends Shape
{
private int radius;
public void draw()
{
/* code here */
}
}
F. public abstract class Circle implements Shape
{
private int radius;
public void draw()
{
/* code here */
}
}
Which of these packages contain classes and interfaces used for input & output operations of a program?
Which of the following is true about inheritance in Java?
1) Private methods are final.
2) Protected members are accessible within a package and inherited classes outside the package.
3) Protected methods are final.
4) We cannot override private methods.
Which of the following is true about inheritance in Java?
1) In Java all classes inherit from the Object class directly or indirectly. The Object class is root of all classes.
2) Multiple inheritance is not allowed in Java.
3) Unlike C++, there is nothing like type of inheritance in Java where we can specify whether the inheritance is protected, public or private.
Which statement is true about java?
Which component is responsible to optimise byte code to machine code?
What would happen if constructor has a return type in java?
Abstract class cannot have a constructor in java.
In java, which of these operators can be used to check whether an object is an instance of a specified type?
In java, which of these access specifiers can be used for a class so that its members can be accessed by a different class in the same package?
In java, which of these access specifiers can be used for a class so that its members can be accessed by a different class in the different package?