1. Question:What are the differences between public, private, protected, static, transient, final and volatile? 

    Answer
    Public: Public declared items can be accessed everywhere.
    
    Protected: Protected limits access to inherited and parent classes (and to the class that defines the item).
    
    Private: Private limits visibility only to the class that defines the item.
    
    Static: A static variable exists only in a local function scope, but it does not lose its value when program execution leaves this scope.
    
    Final: Final keyword prevents child classes from overriding a method by prefixing the definition with final. It means if we define a method with final then it prevent us to override
    the method.
    
    transient: A transient variable is a variable that may not be serialized.
    
    volatile: A variable that might be concurrently modified by multiple threads should be declared volatile. Variables declared to be volatile will not be optimized by the compiler because their value can change at any time






    1. Report
  2. Question:What are the abstract class and interface? 

    Answer
    Ans: Abstract class: Abstract classes are the class where one or more methods are abstract but not necessarily all method has to be abstract. Abstract methods are the methods, which are declare in its class but not define. The definition of those methods must be in its extending class.
    Interface: Interfaces are one type of class where all the methods are abstract. That means all the methods only declared but no defined. All the methods must be defined by its implemented class.







    1. Report
  3. Question:Define exceptions? 

    Answer
    Ans: An exception is an abnormal condition that arises in a code sequence at run time. Basically there are four important keywords which form the main pillars of exception handling: try, catch, throw and finally.







    1. Report
  4. Question:What is regular expression? 

    Answer
    Ans: The symbolic representation of data is called regular expression. 
    The syntax of regular expression is:
    Variable_name.method_name(/searching_word/modifiers,”parsed_value”);







    1. Report
  5. Question:How many ways you can write into a file? 

    Answer
    Ans: r+,W, w+, A, a+, X,x+






    1. Report
Copyright © 2025. Powered by Intellect Software Ltd