Site icon DataFlair

Quiz on Java Syntax

quiz on java syntax

Get Job-ready: Java Course with 45+ Real-time Projects! - Learn Java

Think you’ve got the basics of Java code structure down? Take this fun quiz to challenge yourself and see how well you can write proper Java programs! Whether you’re a coding whiz or a complete beginner, this quiz is a super way to test your knowledge of Java syntax rules.

We’ll throw all sorts of questions your way to see if you can spot the correctly written code snippets, identify mistakes, and understand how to build a well-structured Java program. Don’t worry, there are no tricks here, just a chance to learn and practice the building blocks of Java! Let’s test your knowledge.

Time limit: 0

Quiz Summary

0 of 15 Questions completed

Questions:

Information

You have already completed the quiz before. Hence you can not start it again.

Quiz is loading…

You must sign in or sign up to start the quiz.

You must first complete the following:

Results

Quiz complete. Results are being recorded.

Results

0 of 15 Questions answered correctly

Your time:

Time has elapsed

You have reached 0 of 0 point(s), (0)

Earned Point(s): 0 of 0, (0)
0 Essay(s) Pending (Possible Point(s): 0)

Categories

  1. Not categorized 0%
  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10
  11. 11
  12. 12
  13. 13
  14. 14
  15. 15
  1. Current
  2. Review / Skip
  3. Answered
  4. Correct
  5. Incorrect
  1. Question 1 of 15
    1. Question

    Which of the following is correct syntax for a class name?

    Correct
    Incorrect
  2. Question 2 of 15
    2. Question

    What is the output of the program?

     public class sample{

         public static void main(String args [] )

         {

         final int a = 2;

         a = 5;

         system .out.println(a);

        }

        }

    Correct
    Incorrect
  3. Question 3 of 15
    3. Question

     Public class demo {

    Public static void main(String args [] )

    {

    String Firstname = “Data”;

    String Lastname = “Flair”;

    system.out.println(*********);

    }

    }

    Correct
    Incorrect
  4. Question 4 of 15
    4. Question

    While creating an object the syntax should include ?

    Correct
    Incorrect
  5. Question 5 of 15
    5. Question

    How to declare a Scanner class named sc?

    import java.util.*;  

    class UserInputDemo1  

    {  

    public static void main(String[] args)  

    {  

    _______________________________ 

    System.out.print(“Enter a string: “);  

    String str= sc.nextLine();             

    System.out.print(“Entered string is: “+str);             

    }  

    }  

    Correct
    Incorrect
  6. Question 6 of 15
    6. Question

    Whenever a method is invoked the parameters and other variables are stored in which area of memory location?

    Correct
    Incorrect
  7. Question 7 of 15
    7. Question

    Access Modifiers which cannot be used  for constructors are ?

    Correct
    Incorrect
  8. Question 8 of 15
    8. Question

    Which method is used for Garbage collection?

    Correct
    Incorrect
  9. Question 9 of 15
    9. Question

    How to declare and call a method?

    Correct
    Incorrect
  10. Question 10 of 15
    10. Question

    What will be the output of the program?

    public class Example {  

        public static void main(String[] args) {  

            StringBuffer name = new StringBuffer(“DetaFoair”);  

            s1.setCharAt(1,’a’);  

            s1.setCharAt(6,’l’);  

            System.out.println(name);  

         }  

     }  

    Correct
    Incorrect
  11. Question 11 of 15
    11. Question

    What is the name of the concept which uses a pre-compiled code for further executions ?

    Correct
    Incorrect
  12. Question 12 of 15
    12. Question

    What will be the output of the program?

     public class Student {

        private String name;

        private String college;

     

        public Student(String name, String college) {

            super();

            this.name = name;

            this.college = college;

        }

     

        public String getName() {

            return name;

        }

     

        public void setName(String name) {

            this.name = name;

        }

        public String getCollege() {

            return college;

        }

     

        public void setCollege(String college) {

            this.college = college;

        }

        public static void main(String[] args) {

     

            Student student = new Student(“karthick”, “Skasc”);

            Student student2 = new Student(“Jerome”, “Nasc”);

            Student student3 = new Student(“Kamrizdeen”, “Kcas”);

        }

    }

    Correct
    Incorrect
  13. Question 13 of 15
    13. Question

     What is the main advantage in using Methods in Java ?

    Correct
    Incorrect
  14. Question 14 of 15
    14. Question

    Which Object is used for creation only with no reference ?

    Correct
    Incorrect
  15. Question 15 of 15
    15. Question

    The given program is an example of which class?

    . final class A  

    {  

    void printmsg()   

    {  

    System.out.print(“Base class method is executed.”);  

    }  

    }     

    class B extends A  

    {   

    void printmsg()   

    {  

    System.out.print(“Derived class method is executed.”);  

    }  

    }  

    public class ClassExample  

    {  

    public static void main(String[] arg)   

    {  

    B obj = new B();  

    obj.printmsg();  

    }  

    }  

    Correct
    Incorrect

Summary:

So how did you fare on the Java syntax quiz? This short assessment covered essential concepts like class naming conventions. Remember, a strong foundation in syntax is crucial for building robust and well-structured Java applications.

If you aced the quiz, congratulations! If you encounter some challenges, don’t worry! This serves as a valuable learning opportunity. Utilize the provided resources, such as the links to tutorials and online communities, to delve deeper into specific syntax topics and solidify your understanding. Keep practising and exploring, and you’ll be well on your way to mastering Java syntax!

Exit mobile version