Core Java MCQ

A sleek and modern illustration of Java programming elements, featuring code snippets, symbols, and a silhouette of a developer working on a laptop, all in vibrant colors to signify knowledge and technology.

Core Java Mastery Quiz

Test your knowledge of Core Java with this comprehensive quiz designed to challenge both beginners and experienced programmers. With 11 multiple-choice questions, this quiz covers a range of topics including access modifiers, object-oriented principles, and Java syntax.

Participate and see how well you know Java! Here are some features of our quiz:

  • Covering essential Java concepts
  • Instant feedback on your answers
  • Perfect for studying or brushing up on skills
11 Questions3 MinutesCreated by CodingLion237

Which of the following are Java reserved words?

  1. run
  2. import
  3. default
  4. implement
1 and 2
2 and 3
3 and 4
2 and 4
What is the most restrictive access modifier that will allow members of one class to have access to members of another class in the same package?
Public
Abstract
Protacted
Default

What will be the output of the program?

int x = 3; 
int y = 1; 
if (x = y) /* Line 3 */
{
    System.out.println("x =" + x); 
}
X =3
X = 1
Compilation Error
Code runs with no output
int x = l, y = 6; 
while (y--) 
{
    x++; 
} 
System.out.println("x = " + x +" y = " + y);
X=6 , y =0
X=7 , y=0
X=6 , y =-1
Compilation fails

What will be the output of the program?

String d = "bookkeeper";
d.substring(1,7);
d = "w" + d;
d.append("woo");  /* Line 4 */
System.out.println(d);
Wookkeewoo
Wbookkeeper
Wbookkeewoo
Compilation fails
public void test(int x) 
{ 
    int odd = 1; 
    if(odd) /* Line 4 */
    {
        System.out.println("odd"); 
    } 
    else 
    {
        System.out.println("even"); 
    } 
}
Compilation fails.
"odd" will always be output.
"even" will always be output.
"odd" will be output for odd values of x, and "even" for even values.
class Test 
{  
    private Demo d; 
    void start() 
    {  
        d = new Demo(); 
        this.takeDemo(d); /* Line 7 */
    } /* Line 8 */
    void takeDemo(Demo demo) 
    { 
        demo = null;  
        demo = new Demo(); 
    } 
}
When is the Demo object eligible for garbage collection?
After line 7
After line 8
After the start() method completes
When the instance running this code is made eligible for garbage collection.
interface DoMath 
{
    double getArea(int rad); 
}
interface MathPlus 
{
    double getVol(int b, int h); 
}
/* Missing Statements ? */
which two code fragments inserted at end of the program, will allow to compile?
  1. class AllMath extends DoMath { double getArea(int r); }
  2. interface AllMath implements MathPlus { double getVol(int x, int y); }
  3. interface AllMath extends DoMath { float getAvg(int h, int l); }
  4. class AllMath implements MathPlus { double getArea(int rad); }
  5. abstract class AllMath implements DoMath, MathPlus { public double getArea(int rad) { return rad * rad * 3.14; } }
1 only
2 only
3 and 5
1 and 4

What will be the output of the program?

class Test 
{
    public static void main(String [] args) 
    {
        int x=20;
        String sup = (x < 15) ? "small" : (x < 22)? "tiny" : "huge";
        System.out.println(sup);
    }
}
Small
Tiny
Huge
Compilation fails
public class Test 
{
    public static void main(String [] args) 
    {
        int I = 1;
        do while ( I < 1 )
        System.out.print("I is " + I);
        while ( I > 1 ) ;
    }
}
I is 1
I is 1 I is 1
No output is produced.
Compilation error
What is Your Name?
{"name":"Core Java MCQ", "url":"https://www.quiz-maker.com/QPREVIEW","txt":"Test your knowledge of Core Java with this comprehensive quiz designed to challenge both beginners and experienced programmers. With 11 multiple-choice questions, this quiz covers a range of topics including access modifiers, object-oriented principles, and Java syntax.Participate and see how well you know Java! Here are some features of our quiz:Covering essential Java conceptsInstant feedback on your answersPerfect for studying or brushing up on skills","img":"https:/images/course2.png"}
Powered by: Quiz Maker