what is the output of this question?
class Test1 {
public
static void main(String[] args)
{
int x = 20;
System.out.println(x);
}
static
{
int x = 10;
System.out.print(x + " ");
}
}
core java 2
Quiz
•
Professional Development
•
Professional Development
•
Hard
madhuri nimbalkar
Used 111+ times
FREE Resource
25 questions
Show all answers
1.
MULTIPLE SELECT QUESTION
2 mins • 1 pt
what is the output of this question?
class Test1 {
public
static void main(String[] args)
{
int x = 20;
System.out.println(x);
}
static
{
int x = 10;
System.out.print(x + " ");
}
}
10 20
20 10
10 10
20 20
2.
MULTIPLE SELECT QUESTION
2 mins • 1 pt
Predict the output of the following program.
class A{
int a=40;//non static
public static void main(String args[]){
System.out.println(a);
}
}
Compilation Error
40
0
None of the above
3.
MULTIPLE SELECT QUESTION
2 mins • 1 pt
what is the output of this question?
class Test1 {
static int x = 10;
public
static void main(String[] args)
{
Test1 t1 = new Test1();
Test1 t2 = new Test1();
t1.x = 20;
System.out.print(t1.x + " ");
System.out.println(t2.x);
}
}
10 10
20 20
10 20
20 10
4.
MULTIPLE SELECT QUESTION
2 mins • 1 pt
What is the output of this question?
class Test1 {
static int i = 1;
public static void main(String[] args)
{
for (int i = 1; i < 10; i++) {
i = i + 2;
System.out.print(i + " ");
}
}
}
3 6 9
3 6 9 …. 27
Error
none
5.
MULTIPLE SELECT QUESTION
2 mins • 1 pt
What is the output of this question?
class Test1 {
static int i = 1;
public static void main(String[] args)
{
int i = 1;
for (Test1.i = 1; Test1.i < 10; Test1.i++) {
i = i + 2;
System.out.print(i + " ");
}
}
}
1 3 9
1 2 3 … 9
3 5 7 9 11 13 15 17 19
None
6.
MULTIPLE SELECT QUESTION
45 sec • 1 pt
Which one of the following is a valid statement?
char[] c = new char();
char[] c = new char[5];
char[] c = new char(4);
char[] c = new char[];
7.
MULTIPLE SELECT QUESTION
2 mins • 1 pt
What will be the output?
public class Test
{
public static void main(String args[])
{
int[] x=new int[3];
System.out.print("x[0] is" + x[0]);
}}
The program has a compile error because the size of the array wasn't specified when declaring the array.
The program has a runtime error because the array elements are not initialized.
The program runs fine and displays x[0] is 0.
The program has a runtime error because the array element x[0] is not defined
20 questions
HACKATHON HUSTLE(ROUND 2)
Quiz
•
Professional Development
20 questions
Python Code
Quiz
•
8th Grade - Professio...
25 questions
class ,objects,variables & methods
Quiz
•
Professional Development
20 questions
HACKATHON HUSTLE(ROUND 1)
Quiz
•
Professional Development
20 questions
PostgreSQL & PostGIS Quiz
Quiz
•
Professional Development
30 questions
Java Quiz
Quiz
•
University - Professi...
20 questions
Prelims-Aptitude&C
Quiz
•
Professional Development
20 questions
BSAIT 1-2 QUIZ
Quiz
•
Professional Development
25 questions
Equations of Circles
Quiz
•
10th - 11th Grade
30 questions
Week 5 Memory Builder 1 (Multiplication and Division Facts)
Quiz
•
9th Grade
33 questions
Unit 3 Summative - Summer School: Immune System
Quiz
•
10th Grade
10 questions
Writing and Identifying Ratios Practice
Quiz
•
5th - 6th Grade
36 questions
Prime and Composite Numbers
Quiz
•
5th Grade
14 questions
Exterior and Interior angles of Polygons
Quiz
•
8th Grade
37 questions
Camp Re-cap Week 1 (no regression)
Quiz
•
9th - 12th Grade
46 questions
Biology Semester 1 Review
Quiz
•
10th Grade