JAVA
2.7K subscribers
73 photos
111 files
76 links
Download Telegram
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();
}
}
Options for above program
Anonymous Quiz
14%
50
33%
40
29%
30
14%
20
10%
10
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) {
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);
}
}
Options for above program
Anonymous Quiz
29%
05
21%
5
25%
Compilation Problem
25%
Runtime Problem
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));
}
}
For listing the objects within an ArrayList, which of the following options are available.
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);
}
}
Options for above program
Anonymous Quiz
16%
0
48%
10
28%
1
8%
Compile time problem
public class Program
{
int val;
public Program(int _val){
val=_val;
}
public static void main(String[] args) {
Program p=new Program();
Program p=new Program(10);
}
}
import java.util.ArrayList;
public class Program
{
public static void main(String[] args) {
ArrayList a=new ArrayList();
a.add("C");
a.add("E");
a.add("B");
a.add("D");
a.add("A");
a.add("Z");
a.add("M");
a.remove(1);
a.remove(3);
a.add(2,a.get(3));
a.add(a.size()+" ");
a.remove(3);
System.out.println(a);
}
}
import java.util.ArrayList;
public class Program
{
public static void main(String[] args) {
String s1="Hello World";
String s2=new String("Hello World");
String s3=s2.intern();
System.out.println((s1==s2)+" "+(s2==s3)+" "+(s1==s3));
}
}
import java.util.ArrayList;
public class Program
{
public static void main(String[] args) {
int i=0;
char[] chArray=new char[20];
chArray={'a','b','c'};
System.out.println(chArray[i = +2]});
}
}
Options For above program
Anonymous Quiz
11%
a
25%
b
25%
c
39%
Compilation Error