Question:
What is the output of the following JAVA program ?
class simple
{
public static void main(String[ ] args)
{
simple obj = new simple( );
obj.start( );
}
void start( )
{
long [ ] P= {3, 4, 5};
long [ ] Q= method (P);
System.out.print (P[0] + P[1] + P[2]+”:”);
System.out.print (Q[0] + Q[1] + Q[2]);
}
long [ ] method (long [ ] R)
{
R [1]=7;
return R;
}
} //end of class

Choices:
- 12 : 15
- 15 : 12
- 12 : 12
- 15 : 15


Question:
What is the output of the following JAVA program ?

Class Test {
    public static void main(String[] args) {
        Test obj = new Test();
        obj.start();
    }
    void start() {
        String stra = ”do”;
            String strb = method(stra);
        System.out.print(“: ”+stra + strb);
    }
    String method(String stra) {
        stra = stra + ”good”;
        System.out.print(stra);
        return“ good”;
    }
}

``````Java

Choices:
- dogood : dogoodgood
- dogood : gooddogood
- dogood : dodogood
- dogood : dogood


Question: Java uses threads to enable the entire environment to be ______.

Choices:
- Symmetric
- Asymmetric
- Synchronous
- Asynchronous


Question:
Predict the output of the following program.

class Test
{
    public static void main(String[] args)
    {
        String str = \"geeks\";
        str.toUpperCase();
        str += \"forgeeks\";
        String string = str.substring(2,13);
        string = string + str.charAt(4);;
        System.out.println(string);
    }
}

``````Java

Choices:
- eksforgeekss
- eksforgeeks
- EKSforgeekss
- EKSforgeeks


Question:
Given the array of integers ‘array’ shown below :
13, 7, 27, 2, 18, 33, 9, 11, 22, 8.
What is the output of the following JAVA statements ?
int [ ] p = new int [10];
int [ ] q = new int [10];
for (int k = 0; k < 10; k ++)
p[k] = array [k];
q = p;
p[4] = 20;
System.out.println(array [4] + “ : ” + q[4]);

Choices:
- 20 : 20
- 18 : 18
- 18 : 20
- 20 : 18


Question:
Consider the following JAVA program :
public class First {
                 public static int CBSE (int x) {
                 if (x < 100) x = CBSE (x + 10);
                     return (x – 1);
                        }
      public static void main (String[] args){
      System.out.print(First.CBSE(60));
                         }
                           }
What does this program print ?

Choices:
- 59
- 95
- 69
- 99


Question:
The function f is defined as follows:

int f (int n) {
    if (n <= 1) return 1;
    else if (n % 2  ==  0) return f(n/2);
    else return f(3n - 1);
}

``````C

Assuming that arbitrarily large integers can be passed as a parameter to the function, consider the following statements.1. The function f terminates for finitely many different values of n ≥ 1. ii. The function f terminates for infinitely many different values of n ≥ 1. iii. The function f does not terminate for finitely many different values of n ≥ 1. iv. The function f does not terminate for infinitely many different values of n ≥ 1. Which one of the following options is true of the above?

Choices:
- (i) and (iii)
- (i) and (iv)
- (ii) and (iii)
- (ii) and (iv)


Question:
Study the following program:// precondition: x>=0
public void demo(int x)
{
    System.out.print(x % 10);
    if (x % 10 != 0) {
        demo(x / 10);
    }
    System.out.print(x % 10);
}
Which of the following is printed as a result of the call demo(1234)?

Choices:
- 1441
- 3443
- 12344321
- 4321001234


Question:
Consider the following Java code fragment:

1   public class While
2   {
3    public void loop()
4      {
5      int x = 0;
6       while(1)
7         {
8         System.out.println("x plus one is" +(x+1));
9        }
10     }
11  }

Choices:
- There is syntax error in line no. 1
- There is syntax errors in line nos. 1 & 6
- There is syntax error in line no. 8
- There is syntax error in line no. 6


Question:
What is the result of the following program?
program side-effect (input, output);
    var x, result: integer;
    function f (var x:integer):integer;
    begin
        x:x+1;f:=x;
    end;
begin
    x:=5;
    result:=f(x)*f(x);
    writeln(result);
end;

Choices:
- 5
- 25
- 36
- 42


Question:
class Test {
public static void swap(Integer i, Integer j) {
      Integer temp = new Integer(i);
      i = j;
      j = temp;
   }
   public static void main(String[] args) {
      Integer i = new Integer(10);
      Integer j = new Integer(20);
      swap(i, j);
      System.out.println(\"i = \" + i + \", j = \" + j);
   }
}

``````Java

Choices:
- i = 10, j = 20
- i = 20, j = 10
- i = 10, j = 10
- i = 20, j = 20


Question: In Java, when we implement an interface method, it must be declared as:

Choices:
- Private
- Protected
- Public
- Friend


Question:
Predict the output of following Java program

class Test {
  int i;
}
class Main {
  public static void main(String args[]) {
      Test t = new Test();
      System.out.println(t.i);
   }
}

``````Java

Choices:
- garbage value
- 0
- compiler error
- runtime error


Question:
Which of the following is/are true about packages in Java?

1) Every class is part of some package.
2) All classes in a file are part of the same package.
3) If no package is specified, the classes in the file
   go into a special unnamed package
4) If no package is specified, a new package is created with
   folder name of class and the class is put in this package.

Choices:
- Only 1, 2 and 3
- Only 1, 2 and 4
- Only 4
- Only 1 and 3


Question: Which of the following is FALSE about abstract classes in Java

Choices:
- If we derive an abstract class and do not implement all the abstract methods, then the derived class should also be marked as abstract using \'abstract\' keyword
- Abstract classes can have constructors
- A class can be made abstract without any abstract method
- A class can inherit from multiple abstract classes.


Question: Which of the following is/are advantages of packages?

Choices:
- Packages avoid name clashes
- Classes, even though they are visible outside their package, can have fields visible to packages only
- We can have hidden classes that are used by the packages, but not visible outside.
- All of the above


Question: Which of the following statement(s) is/are TRUE regarding Java Servlets? (a) A Java Servlet is a server-side component that runs on the web server and extends the capabilities of a server. (b) A Servlet can use the user interface classes like AWT or Swing.

Choices:
- Only (a) is TRUE.
- Only (b) is TRUE.
- Both (a) and (b) are TRUE.
- Neither (a) nor (b) is TRUE.


Question: Which one of the following is correct?

Choices:
- Java applets can not be written in any programming language
- An applet is not a small program
- An applet can be run on its own
- Applets are embedded in another applications


Question:
Is there any compiler error in the below Java program?

class Point {
    int m_x, m_y;
    public Point(int x, int y) {    m_x = x;    m_y = y;  }
    public static void main(String args[])
    {
      Point p = new Point();
    }
}

``````Java

Choices:
- Yes
- No


Question:
class Test
{
    static int a;

    static
    {
        a = 4;
        System.out.println (\"inside static block\\n\");
        System.out.println (\"a = \" + a);
    }

    Test()
    {
        System.out.println (\"\\ninside constructor\\n\");
        a = 10;
    }

    public static void func()
    {
        a = a + 1;
        System.out.println (\"a = \" + a);
    }

    public static void main(String[] args)
    {

        Test obj = new Test();
        obj.func();

    }
}

``````JAVA

Choices:
-
inside static block
a = 4
inside constructor
a = 11
- Compiler Error
- Run Time Error
-
inside static block
a = 4
inside constructor
a = 5
-
inside static block
a = 10
inside constructor
a = 11


Question:
final class Complex {
    private  double re,  im;
    public Complex(double re, double im) {
        this.re = re;
        this.im = im;
    }
    Complex(Complex c)
    {
      System.out.println(\"Copy constructor called\");
      re = c.re;
      im = c.im;
    }
    public String toString() {
        return \"(\" + re + \" + \" + im + \"i)\";
    }
}
class Main {
    public static void main(String[] args) {
        Complex c1 = new Complex(10, 15);
        Complex c2 = new Complex(c1);
        Complex c3 = c1;
        System.out.println(c2);
    }
}

``````Java

Choices:
-
Copy constructor called
(10.0 + 15.0i)
-
Copy constructor called
(0.0 + 0.0i)
- (10.0 + 15.0i)
- (0.0 + 0.0i)


Question:
Output of following Java program

class Point {
  int m_x, m_y;

  public Point(int x, int y) { m_x = x; m_y = y; }
  public Point() { this(10, 10); }
  public int getX() { return m_x; }
  public int getY() { return m_y; }

  public static void main(String args[]) {
    Point p = new Point();
    System.out.println(p.getX());
  }
}

``````Java

Choices:
- 10
- 0
- compiler error


Question:
class Test extends Exception { }

class Main {
   public static void main(String args[]) {
      try {
         throw new Test();
      }
      catch(Test t) {
         System.out.println(\"Got the Test Exception\");
      }
      finally {
         System.out.println(\"Inside finally block \");
      }
  }
}

``````Java

Choices:
-
Got the Test Exception
Inside finally block
- Got the Test Exception
- Inside finally block
- Compiler Error


Question:
Output of following Java program?

class Main {
   public static void main(String args[]) {
      int x = 0;
      int y = 10;
      int z = y/x;
  }
}

``````Java

Choices:
- Compiler Error
- Compiles and runs fine
- Compiles fine but throws ArithmeticException exception


Question:
class Test
{
    public static void main(String[] args)
    {
        try
        {
            int a[]= {1, 2, 3, 4};
            for (int i = 1; i <= 4; i++)
            {
                System.out.println (\"a[\" + i + \"]=\" + a[i] + \"\\n\");
            }
        }

        catch (Exception e)
        {
            System.out.println (\"error = \" + e);
        }

        catch (ArrayIndexOutOfBoundsException e)
        {
            System.out.println (\"ArrayIndexOutOfBoundsException\");
        }
    }
}

``````JAVA

Choices:
- Compiler error
- Run time error
- ArrayIndexOutOfBoundsException
- Error Code is printed
- Array is printed


Question:
class Test
{
    public static void main (String[] args)
    {
        try
        {
            int a = 0;
            System.out.println (\"a = \" + a);
            int b = 20 / a;
            System.out.println (\"b = \" + b);
        }

        catch(ArithmeticException e)
        {
            System.out.println (\"Divide by zero error\");
        }

        finally
        {
            System.out.println (\"inside the finally block\");
        }
    }
}

``````JAVA

Choices:
- Compile error
- Divide by zero error
-
a = 0
Divide by zero error
inside the finally block
- a = 0
- inside the finally block


Question:
Which of the following statement(s) with regard to an abstract class in JAVA is/are TRUE ?
I. An abstract class is one that is not used to create objects.
II. An abstract class is designed only to act as a base class to be inherited by other classes.

Choices:
- Only I
- Only II
- Neither I nor II
- Both I and II


Question: We can make a class abstract by

Choices:
- Declaring it abstract using the virtual keyword
- Making at least one member function as virtual function
- Making at least one member function as pure virtual function
- Making all member function const


Question: Which of the following is used to make an Abstract class?

Choices:
- Making atleast one member function as pure virtual function
- Making atleast one member function as virtual function
- Declaring as Abstract class using virtual keyword
- Declaring as Abstract class using  static keyword


Question: Type IV JDBC driver is a driver

Choices:
- which is written in C++
- which requires an intermediate layer
- which communicates through Java sockets
- which translates JDBC function calls into API not native to DBMS


Question:
Predict the output of following Java program

// Note static keyword after import.
import static java.lang.System.*;

class StaticImportDemo
{
   public static void main(String args[])
   {
        out.println(\"GeeksforGeeks\");
   }
}

``````Java

Choices:
- Compiler Error
- Runtime Error
- GeeksforGeeks
- None of the above


Question:
Predict the output?

// file name: Main.java
public class Main {
    public static void main(String args[]) {
       int arr[] = {10, 20, 30, 40, 50};
       for(int i=0; i < arr.length; i++)
       {
             System.out.print(\" \" + arr[i]);
       }
    }
}

``````Java

Choices:
- 10 20 30 40 50
- Compiler Error
- 10 20 30 40


Question: Which one of the following is correct?

Choices:
- Java applets can not be written in any programming language
- An applet is not a small program
- An applet can be run on its own
- Applets are embedded in another applications


Question:
class Test {
   public static void main(String args[]) {
     int arr[] = new int[2];
     System.out.println(arr[0]);
     System.out.println(arr[1]);
   }
}

``````Java

Choices:
-
0
0
-
garbage value
garbage value
- Compiler Error
- Exception


Question: Which cricket team has won most ICC Cricket World Cup titles?

Choices:
- India
- England
- West Indies
- Australia


Question: Which of the following Indian player have got first “Man of the Tournament” Award in the ICC Cricket World Cup?

Choices:
- M.S. Dhoni
- Mohinder Amarnath
- Yuvraj Singh
- Sachin Tendulkar


Question: Which Java keyword is used to implement method overriding?

Choices:
- override
- extends
- super
- @Override


Question: What is the primary purpose of the super keyword in Java?

Choices:
- To call the superclass constructor.
- To create a new object.
- To access a private method in the superclass.
- To define a constant value.


Question: What is the purpose of the static block in Java?

Choices:
- To define constants
- To create instances of a class
- To execute code when the class is loaded
- To declare variables


Question: What is the primary purpose of the finally block in a try-catch-finally statement in Java?

Choices:
- To handle exceptions
- To define the try block
- To execute code that must run regardless of whether an exception is thrown
- To create a new instance of an object


Question: Which of the following Java concepts allows a class to have multiple methods with the same name but different parameters?

Choices:
- Polymorphism
- Inheritance
- Encapsulation
- Overloading


Question: What is the underlying data structure used to implement a TreeMap in Java?

Choices:
- Array
- Linked List
- Hash Map
- RB Tree


Question: What is the default natural ordering for a treemap in Java?

Choices:
- Alphabetic Order
- Insertion Order
- Comparable Natural Order
- Numerical Order


Question: How do you insert an element into a treemap in Java?

Choices:
- Using set()
- Using put()
- Using insert()
- None of these


Question: Can a treemap in Java contain null keys?

Choices:
- Yes
- No
- Only in certain cases
- It depends on the implementation


Question: How is TreeMap different from a Map?

Choices:
- It does not consist of key-value pair
- It stores the items in sorted format
- It has less functionalities than map
- None of the above


Question: How is a TreeMap implemented?

Choices:
- Using the java.util.TreeMap class in Java. It extends the AbstractMap class and does not imlements any interface.
- Using the java.util.TreeMap class in Java. It extends the AbstractMap class and implements the NavigableMap interface.
- Using the java.util.TreeMap class in Java. It does not extend any class.
- None of these


Question: What is the output of ,import java.util.*;class HelloWorld {    public static void main(String[] args) {      TreeMap<Integer, String> m = new TreeMap<Integer, String>();      m.put(10, "gfg");      m.put(16, "IDE");      m.put(25, "courses");      System.out.println( m );      for( Map.Entry<Integer, String>e:m.entrySet() )        System.out.println( e.getKey() + " " + e.getValue() );    }}

Choices:
- {10=gfg, 16=IDE, 25=courses}
- 10 gfg16 IDE25 courses
- {10=gfg, 16=IDE, 25=courses}10 gfg16 IDE25 courses
- None of these


Question: What is the output of the course,import java.util.*;class HelloWorld {    public static void main(String[] args) {      TreeMap<Integer, String> m = new TreeMap<Integer, String>();      m.put(10, "gfg");      m.put(16, "IDE");      m.put(25, "courses");      m.remove(15);        System.out.println( m.size() );    }}

Choices:
- 2
- 3
- Error
- None of these


Question: What is the output of,import java.util.*;class HelloWorld {    public static void main(String[] args) {      TreeMap<Integer, String> m = new TreeMap<Integer, String>();      m.put(10, "gfg");      m.put(16, "IDE");      m.put(25, "courses");      System.out.println( m.higherKey(10) );      System.out.println( m.lowerKey(10) );    }}

Choices:
- 1610
- 1625
- 16null
- None of the above


Question: What is the output of the code,import java.util.*;class HelloWorld {    public static void main(String[] args) {      TreeMap<Integer, String> m = new TreeMap<Integer, String>();      m.put(10, "gfg");      m.put(16, "IDE");      m.put(25, "courses");      System.out.println( m.floorEntry(10).getValue() );      System.out.println( m.ceilingEntry(10).getValue() );    }}

Choices:
- gfggfg
- gfgnull
- Error
- None of these


Question: List is inherited from which interface in Java?

Choices:
- Formattable
- Serializable
- Collection
- None of these


Question: Which class/classes among the given are among the main classes which implements the list interface?

Choices:
- ArrayList
- Vector
- Linked List
- None of these


Question: What is special about the list's iterator compared to the collection's iterator.

Choices:
- It can be constructed easily
- It can access all the data in the list
- It can traverse backward in the list.
- None of these


Question: What is the syntax to create an array list of integers -

Choices:
- Arraylist<Integer> al = new Arraylist<Integer>();
- Arraylist<Integer> al = new list[] ();
- Arraylist<Integer> al = new List<Integer>();
- None of these


Question: Advantage of ArrayList over normal array is/are,

Choices:
- Rich Library Functions
- Dynamic size
- Can access all the data at constant time
- All of the above


Question: How does ArrayList handle data when it is full?

Choices:
- Creates a new array of double size and copies old data to this array.
- Adds space in the pre existing array.
- Cannot allocate memory more than the memory allocated to it.
- None of the above


Question: How many teams are participating in the ICC World Cup 2019?

Choices:
- 10
- 12
- 9
- 8


Question: Which JDBC interface is responsible for establishing a connection to a database?

Choices:
- java.sql.Statement
- java.sql.ResultSet
- java.sql.DriverManager
- java.sql.Connection


Question: What is the purpose of the JDBC DriverManager class?

Choices:
- To manage database connections
- To represent a result set
- To define database schemas
- To execute SQL queries


Question: Which of the following statements is used to execute SQL queries in JDBC?

Choices:
- java.sql.Statement
- java.sql.ResultSet
- java.sql.DriverManager
- java.sql.Connection


Question: Which of the following is not a primitive data type in Java?

Choices:
- char
- String
- int
- float


Question: What is the default value of int variables in Java?

Choices:
- Depends on the compiler
- 0
- 0.0
- null


Question: What does the public static void main(String[] args) method do in Java?

Choices:
- Declares a new class
- Is the entry point of a Java program
- Defines a constructor
- Prints "Hello, World!" to the console


Question: Which keyword is used for inheritance in Java?

Choices:
- subclass
- extends
- inherits
- super


Question: What is the output of System.out.println(5 + "10")?

Choices:
- 510.0
- 15
- 510
- Error


Question: What is the Java keyword used to refer to the current object?

Choices:
- this
- self
- object
- me


Question: Which of the following is not a control flow statement in Java?

Choices:
- for
- swith
- goto
- if-else


Question: Which of the following statements creates an array in Java?

Choices:
- String[] arr = new String[];
- Array<String> arr = new Array<>();
- ArrayList<String> arr = new ArrayList<>();
- String arr[];


Question: What is the purpose of the toString() method in Java?

Choices:
- To convert a string to uppercase
- To convert an object to a string
- To convert a string to lowercase
- To compare two strings


Question: What does the == operator check for in Java?

Choices:
- Variable assignment
- Value equality
- Reference equality
- Object equality


Question: Which of the following is not a primitive data type in Java?

Choices:
- float
- int
- char
- string


Question: Average time to insert n+1 items in an ArrayList,

Choices:
- θ( n + 1 )
- θ( 1 )
- θ( n )
- θ( nlogn )


Question: What is the keyword used to implement multiple inheritance in Java?

Choices:
- extends
- implements
- interface
- extends/implements


Question: What is the default value of a local variable in Java?

Choices:
- 0
- null
- depends on the data type
- undefined


Question:
class Test
{
    public static void main (String[] args)
    {
        int arr1[] = {1, 2, 3};
        int arr2[] = {1, 2, 3};
        if (arr1.equals(arr2))
            System.out.println(\"Same\");
        else
            System.out.println(\"Not same\");
    }
}

``````Java

Choices:
- Same
- Not same


Question: What is the parent class of all Java classes?

Choices:
- Object
- Main
- Class
- Super


Question: Which of the following is used to handle exceptions in Java?

Choices:
- try
- catch
- throw
- All of the above


Question: Which collection in Java does not allow duplicate elements?

Choices:
- ArrayList
- LinkedList
- HashSet
- HashMap


Question: What is the purpose of the this keyword in Java?

Choices:
- To create a new object.
- To refer to the current instance of the class.
- To access superclass methods and properties.
- To create a new instance of a subclass.


Question: Which of the following is not a valid declaration of a String in Java?

Choices:
- String s = "Hello";
- String s = 'H';
- String s = new String("Hello");
- String s = "";


Question: Which country hosted the first Cricket World Cup?

Choices:
- West Indies
- Australia
- England
- India


Question: In JDBC, which method is used to close a connection to the database?

Choices:
- close()
- shutdown()
- closeConnection()
- disconnect()


Question: What is a ResultSet in JDBC?

Choices:
- A connection to the database
- The result of an SQL query
- A statement used to execute SQL commands
- An interface for managing database metadata


Question: In which year was the first Cricket World Cup held?

Choices:
- 1971
- 1983
- 1992
- 1975


Question: In Java, which keyword is used to create a new instance of a class?

Choices:
- new
- instance
- create
- object


Question: Among the given options which is/are the methods of ArrayList in Java?

Choices:
- Remove
- Add
- Contains
- LastIndexOF
- All of the above


Question: Which data structure uses a Last-In-First-Out (LIFO) order?

Choices:
- Queue
- Stack
- List
- Map


Question: What is the time complexity of remove() method of arrayList?

Choices:
- O(1)
- O(n)
- O( log n )
- None of the above


Question: What is no mode of autowiring?

Choices:
- Default setting which means no autowiring and you should use explicit bean reference for wiring.
- Autowiring by property name.
- Spring first tries to wire using autowire by constructor, if it does not work, Spring tries to autowire by byType.
- Similar to byType, but type applies to constructor arguments.


Question: What is Advice?

Choices:
- This is the way to instruct object to behave in certain manner
- This is used to inject values in objects.
- This is the actual action to be taken either before or after the method execution.
- This is not invoked during program execution by Spring AOP framework.


Question: How after-throwing advice works?

Choices:
- Run advice after a method execution only if method exits by throwing an exception.
- Run advice after a class loads only if class throws exception during load time.
- Run advice after http response is returned with error status.
- Run advice after http request is processed and an exception occurred.


Question: How to use ref keyword in beans.xml?

Choices:
- Using setter method only.
- Using constructor argument only.
- Using setter method and constructor argument both.
- None of the above.


Question: By default a bean is lazily loaded.

Choices:
- True
- False


Question: What BeanPostProcessor does?

Choices:
- It processes beans once a bean is initialized
- It defines callback methods that you can implement to provide your own instantiation logic, dependency-resolution logic etc.
- It processes beans once a bean is loaded.
- It processes beans once a bean exits.


Question: What is dependency injection?

Choices:
- Dependency injection is automatically implemented by the Inversion of Control (IoC) container.
- It is one of the Spring modules.
- It is a technique to get dependencies from any project.
- It is used to promote loose coupling in code.


Question: What types of dependency injection does Spring support?

Choices:
- Based on the constructor and setters
- Based on the constructor, setters, and getters
- Based on setters, getters, and properties
- Based on the constructor, setters, and properties


Question: Which of the following statements is correct regarding the Spring Framework?

Choices:
- The Spring Framework is a heavy-weight solution.
- The Spring Framework is a light-weight solution.
- Both A and B are true.
- None of the above


Question: AOP is part of Core Container in the Spring Framework?

Choices:
- True
- False


Question: The Expression Language is part of the Core Container in the Spring?

Choices:
- True
- False


Question:
Output of following Java Program?

class Base {
    public void show() {
       System.out.println(\"Base::show() called\");
    }
}

class Derived extends Base {
    public void show() {
       System.out.println(\"Derived::show() called\");
    }
}

public class Main {
    public static void main(String[] args) {
        Base b = new Derived();;
        b.show();
    }
}

``````Java

Choices:
- Derived::show() called
- Base::show() called


Question:
Which of the following is true about inheritance in Java.

1) In Java all classes inherit from the Object class directly or indirectly.  The Object class is root of all classes.

2) Multiple inheritance is not allowed in Java.

3) Unlike C++, there is nothing like type of inheritance in Java where we can specify whether the inheritance is protected, public or private.

Choices:
- 1, 2 and 3
- 1 and 2
- 2 and 3
- 1 and 3


Question:
final class Complex {

    private final double re;
    private final double im;

    public Complex(double re, double im) {
        this.re = re;
        this.im = im;
    }

    public String toString() {
        return \"(\" + re + \" + \" + im + \"i)\";
    }
}

class Main {
  public static void main(String args[])
  {
       Complex c = new Complex(10, 15);
       System.out.println(\"Complex number is \" + c);
  }
}

``````C

Choices:
- Complex number is (10.0 + 15.0i)
- Compiler Error
- Complex number is SOME_GARBAGE
-
Complex number is Complex@8e2fb5
Here 8e2fb5 is hash code of c


Question:
class Base {
    final public void show() {
       System.out.println(\"Base::show() called\");
    }
}

class Derived extends Base {
    public void show() {
       System.out.println(\"Derived::show() called\");
    }
}

class Main {
    public static void main(String[] args) {
        Base b = new Derived();;
        b.show();
    }
}

``````Java

Choices:
- Base::show() called
- Derived::show() called
- Compiler Error
- Runtime Error


Question:
class Base {
    public static void show() {
       System.out.println(\"Base::show() called\");
    }
}

class Derived extends Base {
    public static void show() {
       System.out.println(\"Derived::show() called\");
    }
}

class Main {
    public static void main(String[] args) {
        Base b = new Derived();
        b.show();
    }
}

``````\Java\

Choices:
- Base::show() called
- Derived::show() called
- Compiler Error


Question: We can make a class abstract by

Choices:
- Declaring it abstract using the virtual keyword
- Making at least one member function as virtual function
- Making at least one member function as pure virtual function
- Making all member function const


Question: Which of the following is used to make an Abstract class?

Choices:
- Making atleast one member function as pure virtual function
- Making atleast one member function as virtual function
- Declaring as Abstract class using virtual keyword
- Declaring as Abstract class using  static keyword


Question: Type IV JDBC driver is a driver

Choices:
- which is written in C++
- which requires an intermediate layer
- which communicates through Java sockets
- which translates JDBC function calls into API not native to DBMS


Question:
Predict the output of the following program.

abstract class demo
{
    public int a;
    demo()
    {
        a = 10;
    }

    abstract public void set();

    abstract final public void get();

}

class Test extends demo
{

    public void set(int a)
    {
        this.a = a;
    }

    final public void get()
    {
        System.out.println(\"a = \" + a);
    }

    public static void main(String[] args)
    {
        Test obj = new Test();
        obj.set(20);
        obj.get();
    }
}

``````Java

Choices:
- a = 10
- a = 20
- Compilation error


Question: Which of the following is FALSE about abstract classes in Java

Choices:
- If we derive an abstract class and do not implement all the abstract methods, then the derived class should also be marked as abstract using \'abstract\' keyword
- Abstract classes can have constructors
- A class can be made abstract without any abstract method
- A class can inherit from multiple abstract classes.


Question:
Output of following Java program?

class Test
{
    public static void main (String[] args)
    {
        int arr1[] = {1, 2, 3};
        int arr2[] = {1, 2, 3};
        if (arr1 == arr2)
            System.out.println(\"Same\");
        else
            System.out.println(\"Not same\");
    }
}

``````C

Choices:
- Same
- Not Same


Question: What is the output of the code,import java.util.*;class HelloWorld {   public static void main(String[] args) {     ArrayList<Integer> al = new ArrayList<Integer>();     al.add(10);     al.add(20);     al.add(30);     al.add(40);     al.add(50);     System.out.println(al.isEmpty());     al.clear();     System.out.println(al.isEmpty());   }}

Choices:
- falsefalse
- false true
- Error
- None of the above


Question: What is true about <props> collection configuration elements?

Choices:
- This helps in wiring a list of values, allowing duplicates
- This helps in wiring a list of values but without any duplicates.
- This can be used to inject a collection of name-value pairs where name and value can be of any type.
- This can be used to inject a collection of name-value pairs where the name and value are both Strings.


Question: What is singleton scope?

Choices:
- This scopes the bean definition to a single instance per Spring IoC container.
- This scopes the bean definition to a single instance per HTTP Request.
- This scopes the bean definition to a single instance per HTTP Session.
- This scopes the bean definition to a single instance per HTTP Application/ Global session.


Question: If a bean is scoped to HTTP session, scope is

Choices:
- global-session
- session
- prototype
- request


Question: What is the output of the code,import java.util.*;class HelloWorld {    public static void main(String[] args) {      LinkedHashMap<Integer, String> m = new LinkedHashMap<>();      m.put(10, "gfg");      m.put(16, "IDE");      m.put(25, "courses");      m.remove( 25 );      m.put( 20, "practice" );      System.out.println(m);    }}

Choices:
- Throws an error
- {10=gfg, 16=IDE, 20=practice}
- {10=gfg, 16=IDE, 25=courses, 20=practice}
- None of these


Question: Can we use the comparable interface for the primitive data types?

Choices:
- No
- Yes


Question: What is the name of method that is contained by the comparable interface ?

Choices:
- compareTo()
- compare()
- compareValues()
- None of the above


Question: What are the possible return values of the compareTo() method?

Choices:
- -1 0 1
- 0
- All Integer values
- None of the above


Question: What are the possible return values of the compareTo() method?

Choices:
- -1 0 1
- 0
- All Integer values
- None of the above


Question: What AOP stands for?

Choices:
- Aspect Oriented Programming
- Any Object Programming
- Asset Oriented Programming
- Asset Oriented Protocol


Question: Stream was added in which version of Java?

Choices:
- Java 6
- Java 8
- Java 11
- Java 9


Question: What does the code do,class HelloWorld {    public static void main(String[] args) {        List<Integer> l = Array.list( 5, 10, 12, 30, 8, 7 );        l.stream()        .filter( x -> x % 2 == 0 )        .filter( x > 10 )        .forEach( System.out::println );     }}

Choices:
- Prints all the numbers in the list l
- Prints all the even numbers in the list l
- Prints all the even numbers in the list l which are greater than 10
- None of these


Question: Do streams have their own storage?

Choices:
- Yes, streams have there own storage
- They create storage dynamically
- They create an abstraction over the given source
- None of the above


Question: Can parallel streams be created?

Choices:
- Yes, they use multiple resources of the system if needed and run parallelly
- No, they cannot be created
- They can be created but they do not run parallelly
- None of these


Question: What is the benefit(s) of using streams?

Choices:
- Makes the code readable
- Makes the code short
- Makes the code efficient
- None of these


Question: Methods provided by BaseStream are?

Choices:
- Parallel()
- Sequential()
- Unordered()
- None of these


Question: Sub-interface of BaseStream are?

Choices:
- IntStream
- DoubleStream
- LongStream
- Stream<T>
- All of the above


Question: Can the Arrays.sort() method takes both Comparable and Comparator takes as lambda expression?

Choices:
- No
- Yes


Question: What is the output of the code?class HelloWorld {    public static void main(String[] args) {       int arr[] = { 30, 20, 10  };       int temp = Arrays.stream(arr)                                .average();                                .getDouble();        System.out.println(temp);    }}

Choices:
- 20
- 60
- 20.0
- 60.0


Question: What is the output of the code,class GFG{    public static void main(String[] args) {       int arr[] = { 30, 20, 50 };       int sum = Arrays.stream(arr)                                .sum();               System.out.println(sum);    }}

Choices:
- 80
- 100
- 20
- 30


Question: What is the output of the code,import java.util.*;class HelloWorld {    public static void main(String[] args) {      HashMap<String, Integer> m = new HashMap<String, Integer>();      m.put("gfg", 10);      m.put("ide", 16);      m.put("courses", 25);      if( m.containsKey("ide"))        System.out.println("yes");     else        System.out.println("no");     m.remove("ide");     System.out.println(m.size());    }}

Choices:
- no3
- yes3
- yes2
- no2


Question: What is the output of,import java.util.*;class HelloWorld {    public static void main(String[] args) {      HashMap<String, Integer> m = new HashMap<String, Integer>();      m.put("gfg", 10);      m.put("ide", 16);      m.put("courses", 25);      System.out.print(m);      System.out.print(m.size());            for( Map.Entry< String, Integer >e: m.entrySet())        System.out.print(e.getKey() + " " + e.getValue());    }}

Choices:
- 3courses 25gfg 10ide 16
- Error
- {courses=25, gfg=10, ide=16}3courses 25gfg 10ide 16
- None of these


Question: How is LinkedHashMap declared in Java

Choices:
- public class LinkedHashMap<K,V>
- public class LinkedHashMap<K,V> implements Map<K,V>
- public class LinkedHashMap<K,V>  extends HashMap<K,V> implements Map<K,V>
- None of these


Question: What is the syntax of creating a Hashmap in Java?

Choices:
- HashMap<k, v> map = new HashMap<>();
- map<k, v> = new HashMap<>();
- HashMap<k, v> map = new HashMap();
- None of these


Question: What happens when a key-value pair already exists in the Map and we use put() to add the value associated with the same key?

Choices:
- It adds one more key-value pair of the same key.
- It adds 2 values for the same key
- It throws an error
- It replaces the pre-existing value.


Question: Which of the following statements is true about the LinkedHashMap class in Java?

Choices:
- It does not allow null keys or values.
- It is an implementation of the Map interface.
- It is an implementation of the HashMap interface.
- None of these


Question: Which of the following statements is true about the HashMap class in Java?

Choices:
- It maintains the insertion of the Map interface
- It is synchronized
- It is an implementation of the Map interface
- None of these


Question: What is the default initial capacity of a HashMap?

Choices:
- 64
- 32
- 16
- None of these


Question: What is the output of the code,class HelloWorld {    public static void main(String[] args) {       Stream.iterate(1, x->x+1 )       .filter( x->x.toString().contains("5"))       .limit(10)       .forEach(System.out::println);    }}

Choices:
- 5, 10, 15, 20, 25, 30, 35, 40, 45, 50
- 5, 15, 25, 35, 45, 50, 51, 52, 53, 54
- 1, 6, 11, 16, 21, 26, 31, 36, 41, 46
- None of these


Question: What is the time complexity of the get() method in a HashMap in the worst case?

Choices:
- O(1)
- O(n)
- O(n logn)
- O( log n )


Question:
What is the output of the following code?

const matrix = [[1, 2], [3, 4]];
for(let row of matrix) {
  console.log(row);
}

``````Javascript

Choices:
- A. [1, 2], [3, 4]
- B. 1, 2, 3, 4
- C. [1], [2], [3], [4]
- D. 1, 3, 2, 4


Question:
What is the output of the following code?

const matrix = [[1, 2], [3, 4]];
const transposed = matrix[0].map((col, i) => matrix.map(row => row[i]));
console.log(transposed);

``````Javascript

Choices:
- a) [[1, 2], [3, 4]]
- b) [[1, 3], [2, 4]]
- c) [[4, 3], [2, 1]]
- d) [[2, 4], [1, 3]]


Question:
What is the output of the following code?

const matrix = [[1, 2], [3, 4]];
console.log(matrix.length);

``````Javascript

Choices:
- A. 1
- B. 2
- C. 3
- D. 4


Question:
What is the output of the following code?

const matrix = [[1, 2], [3, 4]];
matrix.push([5, 6]);
console.log(matrix);

``````Javascript

Choices:
- A. [[1, 2], [3, 4]]
- B. [[1, 2], [3, 4], [5, 6]]
- C. [[1, 5], [3, 6]]
- D. [[1, 6], [3, 5]]


Question:
What is the output of the following code?

const matrix = [[1, 2], [3, 4]];
const product = matrix.map(row => row.reduce((acc, val) => acc * val)).reduce((acc, val) => acc * val);
console.log(product);

``````Javascript

Choices:
- a) 10
- b) 24
- c) 0
- d) 1


Question:
What is the output of the following code?

const matrix = [[1, 2], [3, 4], [5, 6]];
const flattened = matrix.flat();
console.log(flattened);

``````Javascript

Choices:
- a) [1, 2, 3, 4, 5, 6]
- b) [[1, 2], [3, 4], [5, 6]]
- c) [1, 3, 5, 2, 4, 6]
- d) [[1, 3, 5], [2, 4, 6]]


Question:
What is the output of the following code?

const matrix = [[1, 2, 3], [4, 5, 6], [7, 8, 9]];
const rowSum = matrix.map(row => row.reduce((acc, val) => acc + val));
console.log(rowSum);

``````Javascript

Choices:
- [6, 15, 24]
- [12, 15, 18]
- [3, 12, 21]
- [1, 2, 3, 4, 5, 6, 7, 8, 9]


Question: Which method is used to replace a specified substring with a new substring in a string?

Choices:
- a. replace()
- b. swap()
- c. substitute()
- d. switch()


Question: Which method is used to convert a string to a number in JavaScript?

Choices:
- a. toInt()
- b. parseInt()
- c. convertToNumber()
- d. castToNumber()


Question: Which method is used to return the length of a string in JavaScript?

Choices:
- a. length()
- b. size()
- c. count()
- d. getSize()


Question: Which method is used to split a string into an array of substrings based on a specified separator?

Choices:
- a. slice()
- b. split()
- c. divide()
- d. break()


Question: Which method is used to remove whitespace from both ends of a string in JavaScript?

Choices:
- a. trim()
- b. strip()
- c. clean()
- d. remove()


Question: Which method is used to convert a string to uppercase letters in JavaScript?

Choices:
- a. toLowerCase()
- b. upperCase()
- c. toUpperCase()
- d. upper()


Question: Which method is used to find the index of the first occurrence of a specific character or substring in a string?

Choices:
- a. indexOf()
- b. findIndex()
- c. search()
- d. locate()


Question:
What is the output of the following code?

const matrix = [[1, 2], [3, 4]];
const transpose = matrix[0].map((col, i) => matrix.map(row => row[i]));
console.log(transpose);

``````Javascript

Choices:
- A. [[1, 2], [3, 4]]
- B. [[1, 3], [2, 4]]
- C. [[1], [2], [3], [4]]
- D. [[1, 2, 3, 4]]


Question: Which method is used to repeat a string a specified number of times in JavaScript?

Choices:
- a. repeat()
- b. replicate()
- c. duplicate()
- d. copy()


Question: What is a matrix in JavaScript?

Choices:
- a) A data structure that contains a collection of elements arranged in rows and columns
- b) A type of function that takes in an array as input and returns a new array
- c) A built-in class that allows you to manipulate strings


Question: Which of the following is a valid way to declare a string variable in JavaScript?b. string name = 'John';

Choices:
- a. var name = 'John';
- b. const name = 'John';
- c. let name = 'John';
- d. All of the above


Question: Which method is used to concatenate two or more strings in JavaScript?

Choices:
- a. append()
- b. join()
- c. concat()
- d. add()


Question: How do you declare a matrix in JavaScript?

Choices:
- a) let matrix = [1, 2, 3, 4];
- b) let matrix = [[1, 2], [3, 4]];
- c) let matrix = {1: [1, 2], 2: [3, 4]};


Question: What is the purpose of an APK file in Android development?

Choices:
- It contains layout resources for the app.
- It is the source code of the entire app.
- It's a compressed package that contains the app's code and resources.
- It's an executable file for the app's emulator.


Question: What is the "activity_main.xml" file used for in Android Studio?

Choices:
- It's the entry point of the app's execution.
- It's where you define the app's main activity.
- It's a configuration file for app settings.
- It's where you design the user interface of the main activity.


Question: Which of the following is the correct sequence of steps to create a new Android app in Android Studio?

Choices:
- Write code > Test app > Design UI > Set up emulator
- Design UI > Set up emulator > Write code > Test app
- Set up emulator > Design UI > Write code > Test app
- Set up emulator > Write code > Design UI > Test app


Question: How do you launch the AVD Manager in Android Studio?

Choices:
- By clicking on the "Run" button in the toolbar.
- By selecting "AVD Manager" from the "Tools" menu.
- By right-clicking on the app's main layout file.
- By using the "adb" command in the terminal.


Question: What is the purpose of the "layout" folder in the Android project structure?

Choices:
- It contains the app's source code.
- It stores all the images and icons used in the app.
- It holds XML files that define the UI of your app's screens.
- It's where the app's main executable code is stored.


Question: Which file is used to declare the properties of your Android app, such as its name, icon, and permissions?

Choices:
- build.gradle
- AndroidManifest.xml
- settings.gradle
- app.properties


Question: Which plugin allows Android Studio to preview your app's layout on different screen sizes and orientations?

Choices:
- ConstraintLayout Inspector
- Layout Validation
- ScreenSize Preview
- Device Preview


Question: Which component of Android Studio is used to emulate different Android devices for testing?

Choices:
- AVD Manager
- SDK Manager
- Layout Editor
- Debugger


Question: Which Android component is responsible for managing the app's user interface?

Choices:
- Activity
- Service
- BroadcastReceiver
- ContentProvider


Question: Why is Android considered an open-source platform?

Choices:
- It is only available for developers to view, not modify.
- The source code is available for everyone to view and modify.
- The platform is only accessible for commercial companies.
- Google tightly controls the source code access.


Question: What is the purpose of the Android operating system?

Choices:
- To provide a platform for developing iOS applications.
- To create hardware devices such as smartphones and tablets.
- To develop web applications using Java programming.
- To provide a framework for building mobile applications.


Question: Which tool is used to debug Android applications?

Choices:
- Android Debug Bridge (ADB)
- Logcat
- Android Profiler
- All of the above


Question: What is Gradle in the context of Android development?

Choices:
- A build system used for building Android apps
- An IDE for Android development
- A programming language for Android apps
- A user interface component


Question: What is the purpose of the Android Virtual Device (AVD)?

Choices:
- To compile Android app code
- To simulate an Android device for testing apps
- To create an APK file
- To deploy an app to a physical device


Question: Which file is used to define the layout of an Activity in Android?

Choices:
- manifest.xml
- activity_main.xml
- strings.xml
- styles.xml


Question: What is the purpose of the R.java file in Android development?

Choices:
- To store resources like layouts, strings, and images
- To define the application's main activity
- To handle network requests
- To store database queries


Question: What is the purpose of the build.gradle file in an Android project?

Choices:
- To configure project-wide settings and dependencies
- To define the layout of the app's user interface
- To store data used by the app
- To handle user input and interactions


Question: Which file extension is used for Android app package files?

Choices:
- .exe
- .apk
- .jar
- .app


Question: What is the official integrated development environment (IDE) for Android development?

Choices:
- Eclipse
- Android Studio
- Xcode
- Visual Studio


Question: Which programming language is commonly used for Android app development?

Choices:
- Java
- Python
- Kotlin
- Both Java and Kotlin


Question: What is Android?

Choices:
- A programming language
- An operating system
- A software development kit
- A hardware device


Question: What is the purpose of the Android operating system?

Choices:
- To provide a platform for developing iOS applications.
- To create hardware devices such as smartphones and tablets.
- To develop web applications using Java programming.
- To provide a framework for building mobile applications.


Question: What is the primary purpose of abstraction in OOP?

Choices:
- Combining multiple classes into one
- Restricting access to certain components of an object
- Defining multiple methods with the same name in a class
- Simplifying complex systems by modeling classes based on their essential characteristics


Question: Which keyword is used to achieve method overloading in Python?

Choices:
- overload
- method
- override
- Python does not support method overloading


Question: What is polymorphism in OOP?

Choices:
- Combining multiple classes into one
- Restricting access to certain components of an object
- Defining multiple methods with the same name in a class
- Providing a single interface for different types


Question: What is the difference between a class variable and an instance variable?

Choices:
- Class variables are specific to instances, while instance variables are shared among all instances.
- Class variables are defined outside the class, while instance variables are defined inside the class.
- Class variables are shared among all instances, while instance variables are specific to each instance.
- Class variables are used for method overloading, while instance variables are used for method overriding.


Question: What is encapsulation in OOP?

Choices:
- The process of converting a class into a module
- Combining multiple classes into a single class
- Restricting access to certain components of an object and hiding the implementation details
- Creating a new instance of a class


Question: What is an instance variable in a class?

Choices:
- A variable shared among all instances of a class
- A variable defined outside the class
- A variable specific to an instance of a class
- A variable used for method overloading


Question: What is the term for the process of creating a new class based on an existing class?

Choices:
- Encapsulation
- Abstraction
- Inheritance
- Polymorphism


Question: How can you prevent a method in a base class from being overridden in a derived class in Python?

Choices:
- Use the @final decorator
- Use the __prevent_override__ keyword
- Declare the method as private
- Declare the method as static


Question: Can a class in Python inherit from multiple classes?

Choices:
- No, Python does not support multiple inheritances
- Yes, Python supports multiple inheritances
- Only if the superclasses have the same methods
- Only if the superclass is abstract


Question: What is the main advantage of using inheritance in Python?

Choices:
- Reducing code duplication
- Creating private methods
- Achieving encapsulation
- Enhancing code readability


Question: What is an abstract class in Python, and how is it different from a regular class?

Choices:
- An abstract class cannot have methods
- An abstract class cannot be instantiated, and it can have abstract methods
- An abstract class can only inherit from other abstract classes
- An abstract class can have private attributes


Question: What is the purpose of the following code snippet?class Base:   def __init__(self, value):       self.value = valueclass Derived(Base):   def __init__(self, value, extra):       super().__init__(value)       self.extra = extraobj = Derived(10, "extra_data")print(obj.value, obj.extra)

Choices:
- Demonstrates multiple inheritance
- Demonstrates method overloading
- Demonstrates method overriding
- Demonstrates single inheritance


Question: What is the purpose of method overriding in Python inheritance?

Choices:
- To hide the implementation of a method
- To prevent access to a method
- To provide a different implementation for a method in the derived class
- To create a new method in the derived class


Question: How does encapsulation relate to inheritance in object-oriented programming?

Choices:
- Encapsulation is an alternative to inheritance
- Encapsulation and inheritance are unrelated concepts
- Encapsulation is a way to achieve inheritance
- Encapsulation and inheritance are synonymous


Question: What is the term for creating a new class that inherits from a single base class and adds or modifies functionality?

Choices:
- Class abstraction
- Class extension
- Class instantiation
- Class encapsulation


Question: What is the output of the following code snippet?class A:   def __init__(self):       print("A")class B(A):   def __init__(self):       super().__init__()       print("B")obj = B()

Choices:
- A B
- B A
- A
- B


Question: Inheritance in OOP allows a class to:

Choices:
- Combine multiple classes into one
- Define multiple methods with the same name
- Inherit properties and behaviors from a superclass
- Restrict access to certain components of an object


Question: How does the Pearson correlation coefficient differ from the Spearman rank correlation coefficient?

Choices:
- Pearson is for categorical data; Spearman is for numerical data
- Pearson assumes linear relationships; Spearman assesses monotonic relationships
- Pearson is non-parametric; Spearman is parametric
- Pearson handles outliers better than Spearman


Question: In data analysis, what does the term "skewness" measure?

Choices:
- The symmetry of a distribution
- The spread of data
- The correlation between two variables
- The presence of outliers


Question: In reinforcement learning, what is the role of the exploration-exploitation trade-off?

Choices:
- Balancing the use of supervised and unsupervised learning
- Balancing the trade-off between precision and recall
- Balancing the trade-off between exploring new actions and exploiting known actions
- All of the above


Question: How does the choice of a loss function impact the training of a machine learning model?

Choices:
- The loss function has no impact on training
- The loss function determines the optimization objective
- The loss function defines the model's architecture
- The choice of loss function only impacts model evaluation


Question: How does heteroscedasticity impact the results of linear regression?

Choices:
- It inflates standard errors and can lead to incorrect inferences
- It improves the precision of coefficient estimates
- It has no impact on the regression results
- It reduces bias in the model


Question: In linear regression, what does a negative coefficient for an independent variable imply?

Choices:
- Positive relationship with the dependent variable
- No relationship with the dependent variable
- Negative relationship with the dependent variable
- Inverse relationship with the dependent variable


Question: How does the regularization parameter in Lasso regression differ from Ridge regression?

Choices:
- Lasso has a separate regularization parameter for each coefficient
- Lasso uses the same regularization parameter for all coefficients
- Ridge has a separate regularization parameter for each coefficient
- Ridge uses the same regularization parameter for all coefficients


Question: In quantile regression, what does the choice of quantile represent?

Choices:
- Intercept of the regression line
- Slope of the regression line
- Level of the conditional distribution
- Coefficient of determination (R-squared)


Question: In Ridge regression, what happens to the regularization term as the hyperparameter (alpha) increases?

Choices:
- It decreases
- It increases
- It remains constant
- It becomes irrelevant


Question: How does the term "Binning" contribute to feature engineering in data analysis?

Choices:
- Converting numerical features into categorical bins
- Removing outliers from a dataset
- Transforming features into a lower-dimensional space
- Filling missing values in a dataset


Question: In data analysis, what does the term "Lift" signify in the context of a predictive model?

Choices:
- The ratio of true positives to false positives
- The improvement in predictive performance compared to a random model
- The increase in model complexity
- The impact of outliers on model predictions


Question: In data analysis, what is the purpose of the term "Kurtosis"?

Choices:
- Describing the spread of data
- Measuring the symmetry of a distribution
- Identifying outliers
- Assessing the peakedness of a distribution


Question: How does the term "bootstrapping" contribute to statistical analysis?

Choices:
- By creating resampled datasets with replacement
- By fitting multiple models to the same dataset
- By testing the significance of correlations
- By estimating the correlation matrix of a dataset


Question: Explain the concept of "resampling" in data analysis.

Choices:
- Aggregating data based on specified criteria
- Replacing missing values with interpolated values
- Repeatedly drawing samples from a dataset for statistical analysis
- Removing outliers from a dataset


Question: How does the term "principal component analysis" (PCA) contribute to dimensionality reduction in data analysis?

Choices:
- By clustering similar data points together
- By transforming features into a lower-dimensional space
- By creating new features based on existing ones
- By evaluating feature importance


Question: In time series analysis, what does the autocorrelation function (ACF) measure?

Choices:
- The correlation between two different time series
- The correlation between lagged values of the same time series
- The average correlation in a dataset
- The correlation between multiple independent variables


Question: What is the purpose of the term "ANOVA" (Analysis of Variance) in statistical analysis?

Choices:
- Comparing means of multiple groups to detect significant differences
- Assessing the correlation between two continuous variables
- Evaluating the relationship between a dependent variable and independent variables
- Identifying outliers in a dataset


Question: How does method resolution order (MRO) work in Python multiple inheritance?

Choices:
- It follows a random order
- It follows the order in which classes are defined
- It follows the order specified in the __mro__ attribute
- It follows the order of base class names in alphabetical order


Question: In Python, what is a class?

Choices:
- A function
- A module
- A code block
- A blueprint for creating objects


Question: How does Python support polymorphism through function arguments?

Choices:
- By enforcing strict type checking
- By using default arguments.
- By using variable-length argument lists and unpacking
- By limiting the number of arguments


Question: What does the following Python code do?x = 1while x < 6:   print(x, end=" ")   x += 1   if x == 4:       continue

Choices:
- Prints numbers in the range [1, 6] with a skip for 4.
- Prints numbers in the range [1, 6] without a skip.
- Raises a SyntaxError.
- Enters into an infinite loop.


Question: How can you access a class-level attribute in Python?

Choices:
- Using the self keyword
- Using the attribute keyword
- By declaring it as a parameter
- Directly using the class name


Question: Consider the following Python class:class Book:   def __init__(self, title):       self.title = title   def __str__(self):       return self.titleHow can you get the string representation of a Book instance?

Choices:
- str(Book)
- Book.__str__()
- book = Book("Python"); book.__str__()
- book = Book("Python"); str(book)


Question: Consider the following Python code:class MyClass:   passobj = MyClass()What is the data type of obj?

Choices:
- object
- MyClass
- class
- instance


Question: In Python, what is the purpose of a metaclass?

Choices:
- To create class instances
- To define class-level attributes
- To define the behavior of classes
- Metaclasses are not supported in Python


Question: How do you implement lazy evaluation in Python using generators?

Choices:
- Use the lazy_eval decorator
- Implement the lazy_eval function
- Use a generator expression
- Define a lazy class


Question: What is the purpose of the dataclasses module in Python?

Choices:
- Implement mathematical operations
- Define data containers with minimal boilerplate
- Perform database operations
- Serialize and deserialize data


Question: How can you create a custom metaclass in Python that enforces a coding style?

Choices:
- Define a metaclass with code style checks
- Use the pylint module
- Implement a decorator for code style
- Enforce code style in the version control system


Question: How can you create a custom exception class in Python?

Choices:
- class CustomException(Exception):
- CustomException = Exception
- def CustomException(Exception):
- class Exception.CustomException:


Question: How do you create a named tuple in Python using the collections module?

Choices:
- collections.namedtuple("MyTuple", ["field1", "field2"])
- namedtuple("MyTuple", ["field1", "field2"])
- collections.create_named_tuple("MyTuple", ["field1", "field2"])
- create_named_tuple("MyTuple", ["field1", "field2"])


Question: How can you achieve polymorphism through instance methods in Python?

Choices:
- By using function overloading.
- By using function overriding.
- By using method overloading.
- Polymorphism cannot be achieved through instance methods.


Question: What is the purpose of a language model in NLP?

Choices:
- Generating human-like text
- Translating text between languages
- Identifying named entities
- Extracting features from text


Question: In Python, what is the purpose of the property decorator in the context of polymorphism?

Choices:
- To create a property that cannot be overridden.
- To enforce strict type checking.
- To achieve polymorphism in functions.
- To create a read-only attribute.


Question: In Python, what is the purpose of the __iter__ method in a class?

Choices:
- To create a new instance of a class
- To access the attributes of an instance
- To define a static method
- To make instances of a class iterable in a loop


Question: How can you achieve polymorphism through function overloading in Python?

Choices:
- By defining multiple functions with the same name but different parameters.
- By using special methods like __len__ and __str__.
- By enforcing strict type checking.
- Polymorphism cannot be achieved through function overloading.


Question: What will be the output of the following code:class Rectangle:   def __init__(self, length, width):       self.length = length       self.width = width   def calculate_area(self):       return self.length * self.width# What will be the output of the following code?rectangle = Rectangle(7, 9)result = rectangle.calculate_area()print(result)

Choices:
- 45
- 56
- 63
- 72


Question: What is the key difference between compile-time polymorphism and runtime polymorphism in Python?

Choices:
- Compile-time polymorphism is achieved through function overloading, while runtime polymorphism is achieved through function overriding.
- Compile-time polymorphism is achieved through function overriding, while runtime polymorphism is achieved through function overloading.
- Compile-time polymorphism is the same as runtime polymorphism in Python.
- Compile-time polymorphism and runtime polymorphism are not applicable in Python.


Question: What is the role of the super() function in method overriding in Python?

Choices:
- It calls the constructor of the derived class.
- It calls the constructor of the base class.
- It is used to create a new instance of a class.
- It is not used in method overriding.


Question: How can you achieve polymorphism through class attributes in Python?

Choices:
- By using function overloading.
- By using function overriding.
- By using method overloading.
- Polymorphism cannot be achieved through class attributes.


Question: What will be the output of the following code:class Square:   def __init__(self, side):       self.side = side   def calculate_area(self):       return self.side ** 2# What will be the output of the following code?square = Square(4)result = square.calculate_area()print(result)

Choices:
- 8
- 12
- 16
- 20


Question: When using polynomial regression, what does increasing the degree of the polynomial imply?

Choices:
- Decreased model flexibility
- Increased model complexity
- Reduced risk of overfitting
- Limited capability to capture nonlinearity


Question: How does the learning rate impact the convergence of the gradient descent algorithm in linear regression?

Choices:
- Higher learning rates lead to faster convergence
- Lower learning rates lead to faster convergence
- Learning rate has no impact on convergence
- Learning rate affects only the model's accuracy


Question: How does the presence of outliers impact the coefficient estimates in linear regression?

Choices:
- It inflates standard errors and can lead to biased estimates
- It improves the precision of coefficient estimates
- It has no impact on coefficient estimates
- It reduces bias in the model


Question: What is the purpose of cross-validation in the context of linear regression?

Choices:
- To assess model performance on new data
- To improve model interpretability
- To test the assumption of homoscedasticity
- To check for multicollinearity


Question: How is the mean squared error (MSE) calculated in the context of linear regression?

Choices:
- Sum of squared residuals divided by the number of observations
- Sum of residuals divided by the number of observations
- Sum of squared residuals multiplied by the number of observations
- Sum of residuals multiplied by the number of observations


Question: What is the key assumption about the residuals in linear regression?

Choices:
- They must follow a normal distribution
- They must be perfectly linear
- They must have a constant variance
- They must have a mean of zero


Question: What is the primary advantage of using quantile regression over standard linear regression?

Choices:
- Improved accuracy
- Robustness to outliers
- Faster convergence
- Simplicity of interpretation


Question: How does Python handle polymorphism in built-in functions like len() and str()?

Choices:
- By enforcing strict type checking
- By using function overloading
- By using function overriding
- By using special methods like __len__ and __str__


Question: What is the primary goal of Object-Oriented Programming (OOP)?

Choices:
- Code reusability and modularity
- Efficient memory utilization
- Procedural abstraction
- Dynamic typing


Question: How can you create a custom exception class in Python?

Choices:
- By inheriting from the Exception class
- By using the @exception decorator
- Custom exceptions are not allowed in Python
- By creating a class with any name


Question: Explain the purpose of the __call__ method in a class and provide an example use case.

Choices:
- __call__ is used to create a new instance of a class.
- __call__ defines a static method in a class.
- __call__ allows instances of the class to be called as functions.
- __call__ is not a valid method in Python.


Question: What does the following Python code do?num = 10while num > 0:   if num % 2 == 0:       print(num, end=" ")   num -= 1

Choices:
- Prints even numbers in reverse order from 10 to 1.
- Prints odd numbers in the range [1, 10].
- Prints even numbers in the range [1, 10].
- Raises a SyntaxError.


Question: What is the output of the following Python code?count = 0while count < 3:   print("Hello")   count += 1else:   print("Else block")

Choices:
- Prints "Hello" three times and then prints "Else block."
- Prints "Hello" four times.
- Prints "Else block" three times.
- Raises a .SyntaxError


Question: What is the purpose of the locals() function in a while loop?

Choices:
- To access local variables of the loop.
- To define new local variables.
- To exit the loop.
- It is not a valid function in a while loop.


Question: How can you ensure a loop executes at least once?

Choices:
- Use a for loop.
- Use a while loop with a break statement.
- Set the loop condition to True.
- Use a continue statement.


Question: Which of the following statements is used to increment a variable within a while loop?

Choices:
- inc()
- increment


Question: How can you avoid an infinite loop?

Choices:
- By using a for loop instead.
- By setting the loop condition to True.
- By providing a valid exit condition.
- Infinite loops cannot be avoided.


Question: How many times will a while loop with the condition True run?

Choices:
- Zero times
- Infinite times
- Once
- Until it encounters an error


Question: How does a while loop differ from a for loop?

Choices:
- While loops can iterate over a sequence, for loops cannot.
- While loops always have an exit condition, for loops do not.
- While loops have entry-controlled flow, for loops have exit-controlled flow.
- There is no difference between them.


Question: What is the basic syntax of a while loop in Python?

Choices:
- while (condition):
- for condition:
- while loop condition do:
- loop while condition:


Question: What does the agg_filter parameter in Matplotlib do?

Choices:
- Filter aggregated data
- Adjust aggregation parameters
- Apply a filter to aggregated images
- Aggregate filter settings


Question: How do you customize the color of bars in a bar plot in Matplotlib?

Choices:
- bar_color parameter in bar()
- color parameter in bar()
- set_color() method
- customize_color() method


Question: What is the correct way to add a title to a Matplotlib plot?

Choices:
- add_title("My Plot")
- set_title("My Plot")
- title("My Plot")
- plot_title("My Plot")


Question: Consider the following Python code:class A:   def __init__(self, x):       self.x = xclass B(A):   def __init__(self, x, y):       super().__init__(x)       self.y = yWhat is the relationship between the A and B classes?

Choices:
- Composition
- Inheritance
- Encapsulation
- Polymorphism


Question: How do you plot a simple line graph using Matplotlib in Python?

Choices:
- plot(x_values, y_values)
- lineplot(x_values, y_values)
- draw_line(x_values, y_values)
- create_line_graph(x_values, y_values)


Question: In Python, what is the primary purpose of using property setters?

Choices:
- To create new attributes dynamically
- To enforce strict type checking for attributes
- To provide controlled access to private attributes
- To define static methods for attribute manipulation


Question: In Python, what is the purpose of the staticmethod decorator?

Choices:
- To create a static method
- To make a method private
- To enforce strict type checking
- To create a method with dynamic behavior


Question: How can you access a private attribute named __price within the same class?

Choices:
- self.__price
- _price
- __price
- self._price


Question: In Python, what is the significance of the __ (double underscore) prefix in attribute names?

Choices:
- It indicates a read-only attribute.
- It is used for name mangling.
- It makes the attribute public.
- It is a convention for private attributes.


Question: How does encapsulation contribute to code maintainability in Python?

Choices:
- By making all attributes public
- By limiting access to implementation details
- By avoiding the use of classes and objects
- By creating complex class hierarchies


Question: Consider the following Python code:class BankAccount:   def __init__(self, balance):       self.__balance = balance   @property   def balance(self):       return self.__balance   @balance.setter   def balance(self, new_balance):       if new_balance >= 0:           self.__balance = new_balance       else:           print("Invalid balance")What is the purpose of the @balance.setter decorator in this code?

Choices:
- It defines a new method named setter for the balance property.
- It makes the balance property private.
- It provides a way to set the value of the balance property.
- It enforces strict type checking for the balance property.


Question: What is the purpose of the __init__ method in a class?

Choices:
- To initialize class attributes
- To create a private attribute
- To define a static method
- To access the attributes of an instance


Question: How can you access a private attribute named __score within the same package?

Choices:
- self.__score
- _score
- __score
- self._score


Question: What is the purpose of the __slots__ attribute in Python?

Choices:
- To define the superclass of a class
- To restrict the creation of new attributes in a class
- To specify the attributes allowed in a class
- __slots__ is not a valid attribute in Python


Question: Consider the following Python code:class Rectangle:   def __init__(self, length, width):       self.__length = length       self.__width = width   @property   def area(self):       return self.__length * self.__widthWhat does the @property decorator do in this code?

Choices:
- It makes the area method private.
- It creates a read-only attribute named area.
- It enforces strict type checking for the area method.
- It allows direct modification of the area attribute.


Question: What is the purpose of the __str__ and __repr__ methods in a Python class?

Choices:
- __str__ is used for creating string representations of instances, while __repr__ is used for debugging.
- __str__ is used for debugging, while __repr__ is used for creating string representations of instances.
- Both __str__ and __repr__ serve the same purpose.
- __str__ and __repr__ are not valid methods in Python.


Question: How can you implement operator overloading for arithmetic operations (+, -, *, /) in a Python class?

Choices:
- By using the @overload decorator.
- By defining methods like __add__, __sub__, __mul__, and __truediv__ in the class.
- By using the operator module.
- Operator overloading for arithmetic operations is not allowed in Python.


Question: What is the purpose of the polar() function in Matplotlib?

Choices:
- Create a polar coordinate plot
- Set polar axis labels
- Adjust polar grid lines
- Plot a radar chart


Question: In Python's NLTK library, what function is used for tokenization?

Choices:
- tokenize()
- word_tokenize()
- text_to_tokens()
- split_tokens()


Question: What is the purpose of the 'a' mode in file opening?

Choices:
- Append
- Add
- Access
- Assign


Question: What is the difference between syntax and semantics in the context of NLP?

Choices:
- Syntax refers to word meaning, while semantics involves sentence structure
- Syntax deals with sentence structure, while semantics focuses on word meaning
- Syntax and semantics are interchangeable terms
- Both refer to the same aspect of language processing


Question: What will be the output of the following code?try:   result = 10 / 0except ZeroDivisionError:   result = "Infinity"print(result)

Choices:
- 10
- "Infinity"
- ZeroDivisionError
- None


Question: Which of the following statements is used to raise a custom exception in Python?

Choices:
- throw
- raise
- catch
- except


Question: What is the purpose of the finally block in exception handling?

Choices:
- To define a block of code that will be executed if an exception occurs
- To specify the code to be executed regardless of whether an exception occurs or not
- To catch and handle specific exceptions
- To raise a custom exception


Question: How can you handle exceptions in Python?

Choices:
- Using if-else statements
- Using try-except blocks
- Using switch-case statements
- Using for loops


Question: What is an exception in Python?

Choices:
- A syntax error
- A runtime error
- A logical error
- A compile-time error


Question: How does "Non-Negative Matrix Factorization" (NMF) contribute to dimensionality reduction in data analysis?

Choices:
- By transforming features into a lower-dimensional space
- By assigning equal importance to all features
- By evaluating the correlation between features
- By measuring the entropy of each feature


Question: What is the purpose of the term "Hierarchical Clustering" in clustering analysis?

Choices:
- Assessing the correlation between clusters
- Creating a hierarchy of clusters based on similarities
- Identifying outliers in clustered data
- Measuring the similarity within clusters


Question: What is the primary purpose of the term "Confusion Matrix" in classification problems?

Choices:
- Assessing multicollinearity in regression models
- Evaluating the distribution of residuals
- Summarizing the performance of a classification model
- Identifying outliers in a dataset


Question: In time series analysis, what does the term "Exponential Smoothing" refer to?

Choices:
- Identifying outliers in time series data
- Handling missing values in time series data
- Forecasting future values by giving more weight to recent observations
- Assessing the autocorrelation between time series and lagged values


Question: What is the purpose of the else block in exception handling?

Choices:
- To handle exceptions
- To specify code that will be executed if no exceptions are raised
- To define custom exceptions
- To skip the execution of the block if an exception occurs


Question: How does the term "Ensemble Learning" improve model performance in machine learning?

Choices:
- Reducing model complexity
- Combining predictions from multiple models
- Handling outliers by giving less weight to extreme values
- Ensuring that features contribute equally to a model


Question: What does the term "confidence interval" represent in statistical analysis?

Choices:
- The range of values within which a population parameter is estimated to lie
- The average of sample values
- The proportion of data falling within a specified range
- The standard error of the mean


Question: How can you write data to a file without overwriting its existing content in Python?

Choices:
- file.write_data()
- write_file()
- file.write_append()
- file.write('a')


Question: How do you read a file line by line in Python?

Choices:
- read_all_lines()
- file.read_line()
- readlines()
- read_line(file)


Question: What is the purpose of the 'with' statement in file handling?

Choices:
- It creates a new file
- It automatically closes the file
- It appends data to a file
- It reads the entire file at once


Question: How do you check if a file exists before opening it in Python?

Choices:
- check_file_existence()
- file_exists()
- os.path.exists()
- verify_file()


Question: How can you read the first five characters of a file in Python?

Choices:
- file.read(5)
- read(file, 5)
- read_first(file, 5)
- file.read_first(5)


Question: In the context of linear regression, what is the purpose of feature scaling?

Choices:
- To improve model interpretability
- To handle multicollinearity
- To speed up the training process
- To make coefficients comparable


Question: What is the purpose of the 'rb' mode in file opening?

Choices:
- Read binary
- Replace binary
- Read and backup
- Rename binary


Question: Which method is used to read the entire content of a file as a string?

Choices:
- read()
- read_all()
- read_full()
- readfile()


Question: What is the purpose of the term "Multicollinearity" in regression analysis?

Choices:
- Identifying outliers in a dataset
- Assessing the spread of data
- Evaluating the correlation between predictor variables
- Handling missing values in regression models


Question: How can you catch multiple exceptions in a single except block?

Choices:
- Using a comma-separated list of exceptions
- Using nested try-except blocks
- By defining a custom exception
- Using the catch keyword


Question: What is the purpose of the assert statement in Python exception handling?

Choices:
- To catch and handle exceptions
- To raise a custom exception
- To check if a given expression is true, otherwise raise an 'AssertionError'
- To ignore exceptions


Question: What does the finally block execute if an exception is raised and not caught?

Choices:
- It doesn't execute
- It executes before the exception is raised
- It executes after the exception is raised
- It executes only if the exception is caught


Question: What is the purpose of the else clause in a while loop?

Choices:
- It always runs after the loop completes.
- It is used to handle exceptions within the loop.
- It runs if the loop encounters an error.
- It runs if the loop completes without encountering a break statement.


Question: How does the while-else construct work in Python?

Choices:
- It is not a valid construct in Python.
- The else block always runs after the loop.
- The else block runs if the loop encounters an error.
- The else block runs if the loop completes without encountering a break statement.


Question: What is the purpose of the continue statement in a while loop?

Choices:
- Terminates the loop.
- Skips the remaining code in the loop and moves to the next iteration.
- Exits the loop prematurely.
- Breaks out of the loop entirely.


Question: What is the output of the following Python code?num = 2while num < 10:   print(num, end=" ")   num **= 2

Choices:
- Prints powers of 2 from 2 to 8.
- Prints the square of numbers from 2 to 10.
- Prints numbers in the range [2, 10) with a step of 2.
- Raises a SyntaxError.


Question: What does the following Python code do?count = 0while count < 5:   print("Count:", count)   count += 1   if count == 3:       continue   print("After Continue")

Choices:
- Prints "Count: 0" to "Count: 4" with "After Continue" after each line.
- Prints "Count: 0" to "Count: 2" with "After Continue" after each line.
- Prints "Count: 0" to "Count: 4" without "After Continue" after "Count: 3".
- Raises a SyntaxError.


Question: In a regular expression, what does [a-zA-Z] represent?

Choices:
- Matches any single character
- Matches any lowercase letter
- Matches any uppercase letter
- Matches any letter


Question: Which method is used to replace occurrences of a pattern in a string using regular expressions?

Choices:
- replace()
- re.sub()
- substitute()
- re.replace()


Question: What is the output of the following code?import repattern = r'\d{2,4}'result = re.findall(pattern, 'Year: 2022, Month: 11, Day: 01')print(result)

Choices:
- ['2022', '11', '01']
- ['20', '22', '11', '01']
- ['Year', 'Month', 'Day']


Question: What is the purpose of the re.search() function in Python?

Choices:
- Searches for a pattern at the end of a string
- Searches for a pattern anywhere in a string
- Searches for a pattern at the beginning of a string
- Searches for a pattern case-insensitively


Question: In a regular expression, what does the | symbol represent?

Choices:
- Logical AND
- Logical OR
- Zero or one occurrence
- Zero or more occurrences


Question: What does the \b in a regular expression pattern represent?

Choices:
- Beginning of a string
- End of a string
- Word boundary
- Any character


Question: What is the output of the following code?import repattern = r'\d+'result = re.findall(pattern, 'The price is $25 and $50')print(result)

Choices:
- ['25', '50']
- ['$25', '$50']
- ['The', 'is', 'and']


Question: Which character is used to represent zero or more occurrences of the preceding character in a regular expression?


Question: Which module is used in Python for regular expressions?

Choices:
- `regex`
- `rexp`
- `regexp`
- `re`


Question: What does the term "RegEx" stand for?

Choices:
- Regular Extensions
- Regex Expression
- Regular Expressions
- Regex Exclusions


Question: In Python, what is a mixin class, and how is it used in multiple inheritance?

Choices:
- A mixin class is a class that cannot be inherited
- A mixin class is a class designed to be combined with other classes
- A mixin class is a subclass with only abstract methods
- A mixin class is a class with no methods


Question: How does Python handle circular dependencies in multiple inheritance?

Choices:
- It leads to an infinite loop
- Python does not support circular dependencies
- It raises a runtime error
- Python resolves the dependencies using the method resolution order (MRO)


Question: How do you create an instance of the base class from within the derived class in Python?

Choices:
- By using the base() constructor
- By using the create_instance() method
- By using the __class__ attribute
- By using the super().__init__() method


Question: In Python, how do you call a method from the base class within a method of the derived class?

Choices:
- Using the call_base keyword
- Using the super() function
- By creating an instance of the base class
- By using the @base decorator


Question: What is the purpose of the __bases__ attribute in Python?

Choices:
- It stores the base classes of a class
- It stores the derived classes of a class
- It is used to access class attributes
- It is used to create a new instance of a class


Question: What is the purpose of the with statement in Python exception handling?

Choices:
- To create a new exception
- To simplify resource management using context managers
- To catch and handle exceptions
- To define a custom exception


Question: Which function is used to open a file in Python?

Choices:
- open_file()
- read_file()
- file_open()
- open()


Question: Which of the following is a pre-trained language model often used in NLP tasks?

Choices:
- Word2Vec
- GloVe
- BERT (Bidirectional Encoder Representations from Transformers)
- FastText


Question: What is file handling in Python?

Choices:
- Managing folders
- Reading and writing file
- Controlling system files
- Handling exceptions in files


Question: What is the purpose of the pass statement in Python?

Choices:
- To terminate a loop
- To create an empty function
- To define a function
- To check a condition


Question: Which of the following statements is true about list comprehension?

Choices:
- It can only be used for creating lists of integers
- It can include an optional if clause for filtering elements
- It can include an optional if clause for filtering elements
- It cannot be nested


Question: What will the following list comprehension output?squares = [x**2 for x in range(5)]

Choices:
- [0, 1, 4, 9, 16]
- [1, 4, 9, 16, 25]
- [0, 2, 4, 6, 8]
- [1, 3, 5, 7, 9]


Question: Which symbol is used for List Comprehension in Python?


Question: What is List Comprehension in Python?

Choices:
- A method to create lists
- A syntax for creating a list based on an existing iterable
- A built-in Python function
- A way to append elements to a list


Question: What is the significance of the break and else combination in a for loop?

Choices:
- It terminates the loop if a condition is met; otherwise, the else block is executed.
- It is a syntax error; break and else cannot be used together.
- It skips the current iteration if a condition is met.
- It restarts the loop from the beginning.


Question: How can you iterate over the keys and values of a dictionary using a for loop?

Choices:
- for key, value in dictionary:
- for key in dictionary.keys():
- for key in dictionary:
- for value in dictionary.values():


Question: What is the purpose of the pass statement in a for loop?

Choices:
- To terminate the loop
- To create an infinite loop
- To skip the current iteration and move to the next
- To do nothing and continue to the next iteration


Question: What is the difference between a for loop and a while loop?

Choices:
- A for loop is used for iteration, while a while loop is used for conditional statements.
- A for loop is more concise than a while loop.
- There is no difference; they are interchangeable.
- A while loop is used for iteration, while a for loop is used for conditional statements.


Question: What is the purpose of the continue keyword in a for loop?

Choices:
- To exit the loop
- To skip the remaining code and move to the next iteration
- To restart the loop from the beginning
- To print the current iteration and continue


Question: What is the output of the following list comprehension?vowels = ['a', 'e', 'i', 'o', 'u']upper_vowels = [vowel.upper() for vowel in vowels]

Choices:
- ['a', 'e', 'i', 'o', 'u']
- ['A', 'E', 'I', 'O', 'U']
- ['a', 'E', 'i', 'O', 'u']
- ['A', 'e', 'I', 'o', 'U']


Question: How can you iterate over the elements of a list in reverse order using a for loop?

Choices:
- Using the reversed function
- Using the reverse method
- Using a negative step in the range function
- Python doesn't support iterating in reverse order


Question: In a for loop, how can you access both the index and the value of each element in a list?

Choices:
- Using a while loop
- Using the enumerate function
- Using the index method
- Using the iter function


Question: How is the range function typically used in a for loop?

Choices:
- range(start, end)
- range(end)
- range(start, end, step)
- range(step)


Question: What is the purpose of a for loop in Python?

Choices:
- To define a function
- To iterate over a sequence or iterable
- To create a conditional statement
- To perform arithmetic operations


Question: Explain the concept of attention mechanism in the context of NLP.

Choices:
- It measures the importance of different parts of the input sequence for the output
- It reduces model complexity
- It handles imbalanced classes in text classification
- It optimizes the training speed of deep learning models


Question: In the context of neural network models for NLP, what is an epoch?

Choices:
- A type of layer
- A measure of model interpretability
- One complete pass through the entire training dataset
- A unit of word embedding


Question: Which pre-processing step is essential for handling case sensitivity in text analysis?

Choices:
- Tokenization
- Stop word removal
- Lemmatization
- Lowercasing


Question: What is the role of an embedding layer in neural network models for NLP?

Choices:
- Reducing overfitting
- Extracting features from text
- Representing words as dense vectors
- Enhancing interpretability


Question: Explain the concept of cross-validation in the context of NLP model evaluation.

Choices:
- Training a model on multiple datasets
- Evaluating a model on multiple subsets of the training data
- Applying a model to multiple tasks simultaneously
- Combining multiple models to improve performance


Question: Which algorithm is commonly used for text summarization in NLP?

Choices:
- K-Means Clustering
- Random Forest
- LDA (Latent Dirichlet Allocation)
- Textrank


Question: What will the following code output?for i in range(3):   print(i)

Choices:
- 0 1 2
- 1 2 3
- 0 1 2 3
- 1 2 3 4


Question: What will the following list comprehension output?matrix = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]flattened = [num for row in matrix for num in row]

Choices:
- [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
- [1, 2, 3, 4, 5, 6, 7, 8, 9]
- [(1, 2, 3), (4, 5, 6), (7, 8, 9)]
- [[1], [2], [3], [4], [5], [6], [7], [8], [9]]


Question: Which of the following is the correct syntax for a basic list comprehension in Python?

Choices:
- {x for x in iterable}
- [x in iterable]
- (x for x in iterable)
- [x for x in iterable]


Question: What is the purpose of the if clause in list comprehension?

Choices:
- Adds an element to the list
- Excludes an element from the list based on a condition
- Sorts the elements in the list
- Converts elements to uppercase


Question: How do you check if a value is present in a list in Python?

Choices:
- check(value, list)
- value in list
- contains(list, value)
- list.has(value)


Question: Which statement is used to exit a loop prematurely in Python?

Choices:
- break
- exit
- return
- continue


Question: What is the output of the following code snippet?x = 10if x > 5:   print("Greater than 5")elif x > 8:   print("Greater than 8")else:   print("Less than or equal to 5")

Choices:
- Greater than 5
- Greater than 8
- Less than or equal to 5
- No output


Question: In Python, what is the purpose of the else statement within an if-else block?

Choices:
- To define a function
- To check additional conditions
- To execute a block of code when the if condition is false
- To create a loop


Question: What is the purpose of the elif statement in Python?

Choices:
- To handle exceptions
- To create a loop
- To define a function
- To check additional conditions after the initial if statement


Question: How do you represent the logical AND operator in Python?

Choices:
- and
- AND


Question: What will be the output of the following code snippet?x = 5if x > 0:   print("Positive")else:   print("Negative")

Choices:
- Positive
- Negative
- Zero
- Error


Question: Which of the following operators is used for equality comparison in Python?


Question: What is the purpose of the if statement in Python?

Choices:
- To define a function
- To declare a variable
- To execute a block of code conditionally
- To create a loop


Question: Explain the term "Gini impurity" in the context of decision trees.

Choices:
- A measure of impurity or disorder in a set of data
- A measure of information gain in feature selection
- A criterion used to split nodes in a decision tree
- A method for pruning decision trees


Question: What is the role of the term "dropout" in neural networks?

Choices:
- Improving model interpretability
- Reducing the learning rate during training
- Introducing non-linearity to the model
- Preventing overfitting by randomly dropping neurons during training


Question: Explain the term "precision" in the context of binary classification.

Choices:
- The ratio of true positive predictions to the total positive predictions
- The ratio of true positive predictions to the sum of true positives and false negatives
- The ratio of true positive predictions to the sum of true positives and false positives
- The ratio of true positive predictions to the total predictions made by the model


Question: In time series analysis, what does the term "autocorrelation" measure?

Choices:
- The correlation between two independent time series
- The correlation between a time series and its lagged values
- The average correlation across multiple time series
- The correlation between different features within a time series


Question: What is the primary goal of principal component analysis (PCA)?

Choices:
- Reducing model complexity
- Visualizing data in a lower-dimensional space
- Handling imbalanced classes
- Improving model interpretability


Question: Explain the concept of "bagging" in ensemble learning.

Choices:
- Combining predictions from multiple models
- Creating diverse models by training each on a different subset of the data
- Reducing model complexity
- Fitting models sequentially to improve accuracy


Question: What is the purpose of the term "feature engineering" in machine learning?

Choices:
- Extracting valuable information from the target variable
- Creating new features or modifying existing ones to improve model performance
- Selecting the most important features for model training
- Normalizing feature values to have zero mean and unit variance


Question: What does the term "A/B testing" refer to in the context of data science?

Choices:
- Analyzing and cleaning datasets
- Testing the accuracy of machine learning models
- Comparing two versions of a product or webpage to determine which performs better
- Performing statistical hypothesis tests


Question: Question: What is the purpose of the term "confounding variable" in statistical analysis?

Choices:
- A variable that directly influences the dependent variable
- A variable that influences both the dependent and independent variables
- A variable with no impact on the analysis
- A variable that simplifies the analysis


Question: What is the key principle behind the k-nearest neighbors (KNN) algorithm?

Choices:
- Minimizing the sum of squared errors
- Maximizing the margin between classes
- Assigning a data point the most common label among its k-nearest neighbors
- Minimizing the cross-entropy loss


Question: What happens if you use list comprehension without assigning it to a variable?

Choices:
- It raises a syntax error.
- It creates a list but doesn't store it.
- It modifies the original list in-place.
- It returns a generator object.


Question: What will the following list comprehension output?matrix = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]filtered = [row[1] for row in matrix if row[1] % 2 == 0]

Choices:
- [2, 5, 8]
- [1, 4, 7]
- [2, 4, 6, 8]
- [1, 2, 3]


Question: What is the purpose of the classmethod decorator in Python, and how does it contribute to polymorphism?

Choices:
- It is used to create a class-level attribute.
- It is used to create a method that can be called on the class itself, contributing to polymorphism.
- It is used to enforce strict type checking.
- It is used to create a read-only attribute.


Question: Which of the following statements about outliers in linear regression is true?

Choices:
- Outliers do not impact the regression line
- Outliers can significantly influence the regression line
- Linear regression is immune to the presence of outliers
- Outliers only affect the slope of the regression line


Question: How does the Support Vector Machine (SVM) algorithm work in classification?

Choices:
- It finds the nearest neighbors for each data point
- It fits a linear hyperplane to separate classes
- It uses decision trees to make predictions
- It performs clustering based on data density


Question: What is the purpose of the term "cross-validation" in machine learning?

Choices:
- Reducing model complexity
- Assessing a model's performance on multiple subsets of data
- Combining predictions from multiple models
- Enhancing model interpretability


Question: How can you customize the Django admin interface?

Choices:
- Edit the admin.py file
- Use a custom template
- Override the AdminSite class
- All of the above


Question: What is Django's class-based views?

Choices:
- A way to define models using classes
- A method to create class-based templates
- An alternative to function-based views
- A database optimization technique


Question: Explain the purpose of Django's login and logout views.

Choices:
- login and logout views are used for defining URL patterns.
- login and logout views are functions provided by Django to handle user authentication.
- login and logout views handle middleware functions.
- login and logout views are used for handling file uploads.


Question: How can you handle file uploads in Django forms?

Choices:
- By using the upload_to attribute in the form definition
- By defining a new class in views.py for file uploads
- By using the FileField in the form and handling file processing in views
- By creating a separate files.py module


Question: Explain the purpose of Django's messages framework.

Choices:
- Messages handle user authentication.
- The messages framework is used for displaying user-friendly messages to the user after specific actions, such as form submissions.
- Messages handle URL routing.
- Messages define middleware functions.


Question: What is Django's QuerySet and how is it related to database queries?

Choices:
- A QuerySet is used for defining URL patterns.
- A QuerySet is a collection of SQL queries for the database.
- A QuerySet represents a collection of database queries, allowing you to retrieve, filter, and manipulate data.
- A QuerySet is used for handling form submissions.


Question: How can you implement a custom template tag in Django?

Choices:
- By defining a function in views.py
- By creating a Python module with the tag code and registering it in settings.py
- By defining a function in models.py
- By adding a special comment in the template file


Question: How does Django's static files handling differ from media files handling?

Choices:
- Static files are user-uploaded files, while media files are CSS and JavaScript files.
- Static files are served directly by the web server, while media files are served by Django.
- Static files include CSS and JavaScript, while media files include images and videos.
- Static files and media files are interchangeable terms in Django.


Question: Explain the purpose of Django's settings.py file.

Choices:
- It defines the project's global settings, such as database configuration and middleware.
- It contains HTML templates for rendering views.
- It is used to define URL patterns for the project.
- It handles user authentication settings.


Question: What is Linear Regression?

Choices:
- A classification algorithm
- A clustering algorithm
- A regression algorithm
- A reinforcement learning algorithm


Question: What is Django's middleware and how does it differ from a regular view?

Choices:
- Middleware is used for processing requests and responses globally; views handle specific URL patterns.
- Middleware and views both handle URL routing in Django.
- Middleware is used for defining database models; views handle processing requests and responses.
- Middleware and views are interchangeable terms in Django.