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; } }
{
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; } }
Anonymous Quiz
25%
1,3
25%
3,1
15%
1,1
15%
1,0
20%
None of the above
Which of the following is not true?
Anonymous Quiz
12%
An interface can extend another interface.
28%
A class which is implementing an interface must implement all the methods of the interface.
40%
An interface can implement another interface.
16%
An interface is a solution for multiple inheritance in java
4%
None of the above
public class Program
{
public static void main(String[] args) { int x=3,y=5,z=10; System.out.println(++z+y-y+z+x++); } }
{
public static void main(String[] args) { int x=3,y=5,z=10; System.out.println(++z+y-y+z+x++); } }
Anonymous Quiz
26%
24
17%
23
22%
20
35%
25
Which of the following is true?
Anonymous Quiz
4%
A finally block is executed before the catch block but after the try block.
21%
A finally block is executed, only after the catch block is executed.
58%
A finally block is executed whether an exception is thrown or not.
8%
A finally block is executed, only if an exception occurs.
8%
None of the above
public class Program
{
public static void main(String[] args) {
Program p=new Program();
p.start();
}
void start(){
long[] a={3,4,5};
long[] b=method(a);
System.out.println(a[0]+a[1]+a[2]);
System.out.println(b[0]+b[1]+b[2]);
}
long[] method(long[] c){
c[1]=7;
return c;
}
}
A) 12
15
B) 15
12
C) 12
12
D) 15
15
{
public static void main(String[] args) {
Program p=new Program();
p.start();
}
void start(){
long[] a={3,4,5};
long[] b=method(a);
System.out.println(a[0]+a[1]+a[2]);
System.out.println(b[0]+b[1]+b[2]);
}
long[] method(long[] c){
c[1]=7;
return c;
}
}
A) 12
15
B) 15
12
C) 12
12
D) 15
15
public class Program
{
public static void main(String[] args) {
int index=0;
boolean flag=true;
boolean reg1=false,reg2;
reg2=(flag |((index++)==0));
reg2=(reg1|(index+=2)>0);
System .out.println(index );
}
}
A) 0
B) 1
C) 2
D) 3
{
public static void main(String[] args) {
int index=0;
boolean flag=true;
boolean reg1=false,reg2;
reg2=(flag |((index++)==0));
reg2=(reg1|(index+=2)>0);
System .out.println(index );
}
}
A) 0
B) 1
C) 2
D) 3
class Train{
int speed=10;
public void getSpeed(){
System.out.println(speed);
}
public void setSpeed(int speed ){
this.speed=40;
speed=this.speed;
}
}
class BulletTrain extends Train {
int speed =20;
public void getSpeed(){
System.out.println(super.speed);
}
}
public class Program
{
public static void main(String[] args) {
Train train=new BulletTrain();
train.setSpeed(50);
train.getSpeed();
}
}
int speed=10;
public void getSpeed(){
System.out.println(speed);
}
public void setSpeed(int speed ){
this.speed=40;
speed=this.speed;
}
}
class BulletTrain extends Train {
int speed =20;
public void getSpeed(){
System.out.println(super.speed);
}
}
public class Program
{
public static void main(String[] args) {
Train train=new BulletTrain();
train.setSpeed(50);
train.getSpeed();
}
}
import java.util.*;
public class Program
{
public static void main(String[] args) {
HashSet<Integer> h=new HashSet<>();
h.add(null);
h.add(null);
h.add(100);
h.add(300);
h.add(400);
h.add(null);
h.add(100);
h.add(300);
Object[] o=h.toArray();
System.out.println(Arrays.toString(o));
}
}
public class Program
{
public static void main(String[] args) {
HashSet<Integer> h=new HashSet<>();
h.add(null);
h.add(null);
h.add(100);
h.add(300);
h.add(400);
h.add(null);
h.add(100);
h.add(300);
Object[] o=h.toArray();
System.out.println(Arrays.toString(o));
}
}
Options for above program
Anonymous Quiz
25%
[null,400,100,300]
25%
[null,null,100,300,400,null,100,300]
40%
Compilation Problem
10%
None of these
public class Program
{
public static void main(String[] args) {
try{
int sum=5;
for(int i=-1;i<5;++i){
sum=sum/i;
}
}catch(ArithmeticException e){
System.out.println("0");
}
System.out.println(sum);
}
}
{
public static void main(String[] args) {
try{
int sum=5;
for(int i=-1;i<5;++i){
sum=sum/i;
}
}catch(ArithmeticException e){
System.out.println("0");
}
System.out.println(sum);
}
}
Which method will contain the block of code to be executed when thread starts?
Anonymous Quiz
37%
Main
26%
Start
7%
Execute
30%
Run
public class Program
{
static double overloadedMethod(int i,double d){
return d *= i;
}
static double overloadedMethod(double d,int i){
return i += d;;
}
public static void main(String[] args) {
System.out.println(overloadedMethod(100,100));
}
}
{
static double overloadedMethod(int i,double d){
return d *= i;
}
static double overloadedMethod(double d,int i){
return i += d;;
}
public static void main(String[] args) {
System.out.println(overloadedMethod(100,100));
}
}
Options For above program
Anonymous Quiz
32%
Compilation Error
24%
Runtime Error
28%
10000
12%
10000.0
4%
200
For listing the objects within an ArrayList, which of the following options are available.
1) An Iterator
2) A ListIterator 3) An Enumeration
1) An Iterator
2) A ListIterator 3) An Enumeration
Anonymous Quiz
8%
1
31%
1 and 2
54%
1 and 2 and 3
8%
1 and 3
class Parent{
public int index=1;
}
public class Program extends Parent
{
public Program(int index){
index=index;
}
public static void main(String[] args) {
Program p=new Program(10);
System.out.println(p.index);
}
}
public int index=1;
}
public class Program extends Parent
{
public Program(int index){
index=index;
}
public static void main(String[] args) {
Program p=new Program(10);
System.out.println(p.index);
}
}