Get Job-ready: Java Course with 45+ Real-time Projects! - Learn Java
Mastering Java keywords is fundamental to writing robust and efficient code. These reserved words hold special meanings within the Java language, dictating control flow, data types, and object-oriented programming constructs.
This interactive quiz will test your understanding of core Java keywords, helping you solidify your grasp of essential Java syntax and programming fundamentals. Take the quiz and see how well you can identify the correct keywords for various programming scenarios!
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
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
- Not categorized 0%
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- Current
- Review / Skip
- Answered
- Correct
- Incorrect
-
Question 1 of 15
1. Question
Which form of an association is highly dependent on another entity?
CorrectIncorrect -
Question 2 of 15
2. Question
class company {
public void method(String a )
{
return a;
}
}
class Worker {
public void method( String b )
{
return b;
}
}
class Main {
public static void main ( String args [ ] )
{
Company c = new Company();
Worker w = new Worker();
String name = c.method(“DataFlair”);
String text = w.method(“Raj”);
System.out.println(name+text);
}
}
What is the output of the program ?
CorrectIncorrect -
Question 3 of 15
3. Question
class Product {
public void store ( String name )
{
String item = this.name;
}
}
class Price {
public void store ( double value )
{
double val = this.value;
}
}
class Store {
public static void main ( String args [ ] )
{
Product p1 = new Product(“Rice”);
Product p2 = new Product(‘Wheat”);
Product p3 = new Product(“Dhal”);
Price m1 = new Price(“80”);
Price m2 = new Price(“70”);
Price m3 = new Price(“50”);
System.out.println(“Product is “ + p1 + “Price is “ + m1 );
System.out.println(“Product is “ + p2 + “Price is “ + m2 );
System.out.println(“Product is “ + p3 + “Price is “ + m3 );
}
}
What is the output of the program ?
CorrectIncorrect -
Question 4 of 15
4. Question
Which of the following is an unidirectional way of association ?
CorrectIncorrect -
Question 5 of 15
5. Question
class Demo {
public int function ( String a )
{
String text = this.a;
}
}
class Sample {
public void function( String b )
{
String message = this.b;
}
}
class Main {
public static void main ( String args [ ] )
{
Demo d = new Demo(“DataFlair”);
Sample s = new Sample(“Webservices”);
System.out.println( d + s );
}
}
What is the output of the program ?
CorrectIncorrect -
Question 6 of 15
6. Question
class Students {
String name;
long rollno;
void display ( String a , long b )
{
name = this.a;
rollno = this.b;
}
}
class Department {
String dep;
void display ( String c )
{
dep = this.c;
}
}
class college {
public static void main ( String args [ ] )
{
Student s1 = new Student(“David” , 14 );
Student s2 = new Student(“Rohit” , 55);
Student s3 = new Student(“Shikar”, 40 );
List <String,int> list = new List();
l.add(s1);
l.add(s2);
l.add(s3);
System.out.println(l.size());
}
}
What is the output of the program ?
CorrectIncorrect -
Question 7 of 15
7. Question
What will happen if one entity is deleted in a composition association ?
CorrectIncorrect -
Question 8 of 15
8. Question
class Student {
String name;
Student( String a )
{
name = this.a;
}
}
class Subject {
String sub;
Subject ( String b )
{
sub = this.b;
}
}
class Main {
public static void main ( String args [ ] )
{
Student obj1 = new Student(“Ravi”);
Subject s1 = new Subject(“Maths”);
Subject s2 = new Subject(“Science”);
System.out.println( obj1 + “learns “ + s1 + “and also “ + s2 );
}
}
What is the output of the program ?
CorrectIncorrect -
Question 9 of 15
9. Question
class BasicSalary {
private double salary;
public void getSalary( double amount )
{
return amount;
}
public void setSalary( double amount)
{
salary = this.amount;
}
}
class Allowances {
private double pay ;
public void getPay( double allow )
{
return allow;
}
public void setPay ( double allow )
{
pay = this.allow;
}
}
class NetPay {
public static void main ( String args [ ] )
{
BasicSalary b = new Basic Salary(10000);
Allowances a = new Allowances(2000);
System.out.println(‘Net pay is “ + ( b + a ) );
}
}
What is the output of the program ?
CorrectIncorrect -
Question 10 of 15
10. Question
What is the type of relation that composition associations have ?
CorrectIncorrect -
Question 11 of 15
11. Question
class Employee {
String empname;
Employee( String empname )
{
return empname;
}
}
class Salary {
float salary;
Salary ( String salary )
{
return salary;
}
}
class Company {
public static void main ( String args [ ] )
{
Employee e1 = new Employee(“Kumar”);
Employee e2 = new Employee(“Thakur”);
Employee e3 = new Employee(“Singh”);
Salary s1 = new Salary(15000);
Salary s2 = new Salary(13000);
Salary s3 = new Salary(10000);
HashTable<Float , String > list = new HashTable();
list.add(e1,s1);
list.add(e2.s2);
list.add(e3,s3);
System.out.println(list);
}
}
What will be the output of the program ?
CorrectIncorrect -
Question 12 of 15
12. Question
class Sample {
public void display()
{
System.out.println(“Sample class is needed”);
}
}
class Concept {
Private Sample sample;
Concept(Sample sample)
{
this.sample = sample:
}
public void display()
{
sample.display();
System.out.println(“Concept is explained”);
}
}
class Main {
public static void main ( String args [ ] )
{
Sample s = new Sample();
Concept c = new Concept();
c.display();
}
}
What is the output of the program ?
CorrectIncorrect -
Question 13 of 15
13. Question
Which technique is highly employed while using associations ?
CorrectIncorrect -
Question 14 of 15
14. Question
class Associations {
public void print(String a )
{
return a;
}
}
class Aggregation {
public void print(String b)
{
return b;
}
}
class Composition {
public void print( String c )
{
return c;
}
}
class Main {
public static void main ( String args [ ] )
{
Associations a1 = new Associations(“Connection between two class objects”);
Aggregations a2 = new Aggregations(“Is-A relationship association”);
Composition a3 = new Composition (“Has-A relationship association”);
a2.print();
}
}
What is the output of the program ?
CorrectIncorrect -
Question 15 of 15
15. Question
class Vegetables {
public void veg ( String vegetable )
{
return vegetable;
}
}
class Fruits {
public void fru ( String fruit )
{
return fruit;
}
}
class Consumable {
public static void main ( String args [ ] )
{
Vegetables v1 = new Vegetables(“Tomato”);
Vegetable v2 = new Vegetables(“Beetroot”);
Vegetable v3 = new Vegetables(“Potato”):
Fruits f1 = new Fruits(“Apple”);
Fruits f2 = new Fruits(“Orange”);
List<String> list = new List();
list.add(v1);
list.add(v2);
list.add(v3);
list.add(f1);
list.add(f2);
if(list.size==5)
{
System.out.println(“Both Vegetables and fruits are added”);
} else {
System.out.println(“Only one is added”);
}
}
What is the output of the program ?
CorrectIncorrect
Summary:
Congratulations on completing the Java Keywords Quiz! By attempting this quiz, you’ve actively reviewed essential keywords that form the backbone of Java programming. Examine both your correct and incorrect answers to identify areas for improvement. Remember, effective learning is an ongoing process.
Explore additional resources beyond the quiz, such as tutorials, documentation, and practice problems. The more you delve into Java keywords and their applications, the more confident you’ll become in crafting effective Java programs.
