What concept in Java makes it "write once, run anywhere"? The concept in Java that makes it "write once, run anywhere" is the Java Virtual Machine (JVM). Java programs are compiled into bytecode, which is platform-independent. The JVM interprets this bytecode and runs it on any device or operating system that has a compatible JVM implementation. Can we run a Java program without a main method? No, we can't run java program without a main method because the main method is the entry point of java program if main method is not present in the program then it will throw compilation error indication no main method is found Difference between JRE and JDK - **JRE (Java Runtime Environment):** It is a package of tools necessary to run Java programs. It includes the JVM, core libraries, and other components required to run applications written in Java. - **JDK (Java Development Kit):** It is a superset of the JRE, containing everything in the JRE plus tools for developing Java applications, such as the compiler (`javac`), debuggers, and other development tools. What is a wrapper class? A wrapper class in Java provides a way to use primitive data types (int, char, etc.) as objects. Each primitive data type has a corresponding wrapper class: - int -> Integer - char -> Character - boolean -> Boolean - etc. Wrapper classes are used for converting primitives to objects and vice versa, which is especially useful in situations where objects are required, such as in collections. What will happen if we do not write `static` with the main method? If the `main` method is not declared `static`, the JVM will not be able to call it at the start of the program. This is because the `main` method is the entry point of the program and is called without creating an instance of the class. Declaring `main` as `static` allows the JVM to call it directly using the class name. Can we have multiple main methods in Java? Yes, you can write multiple main methods in Java. But, only one main method with a parameter as String[] args will be executed by the JVM. The main method is the entry point of a Java program. It is the method that is called when the program is executed. The main method must be declared public static void main(String[] args). If you have multiple main methods in your program, only the one with the correct signature will be executed. The other main methods will be ignored What is method overloading? Method overloading in Java is a feature that allows a class to have more than one method with the same name, but different parameter lists (different type, number, or both). The appropriate method is selected based on the method signature at compile-time. Can we have multiple catch blocks with a single try block? Yes, you can have multiple catch blocks with a single try block in Java. Each catch block can handle a different type of exception. The first catch block with a matching exception type is executed. ```java try { // code that may throw an exception } catch (IOException e) { // handle IOException } catch (SQLException e) { // handle SQLException } catch (Exception e) { // handle any other exceptions } ``` Difference between array and ArrayList - **Array:** - Fixed size: Once created, the size cannot be changed. - Can hold primitive types and objects. - Not part of the Java Collections Framework. - **ArrayList:** - Dynamic size: Can grow and shrink as needed. - Can only hold objects (wrapper classes for primitives). - Part of the Java Collections Framework and provides more functionality, like dynamic resizing and methods for manipulation. Why is Map not considered a Collection? In Java, the `Map` interface is not a part of the `Collection` hierarchy. While `Collection` is a root interface for collections like `List`, `Set`, and `Queue`, `Map` is designed to store key-value pairs and thus does not fit into the `Collection` interface's structure, which is more suited for single elements. The `Map` interface has a different structure and methods tailored for key-value associations rather than individual elements.
1.Jdk is a software where as jvm is virtual mechine which is compile the code, inside jdk software there is jvm 2. Yes we can use more than 1 main method but jvm only execute that main method which has String arg[]
@@nationfirst640 Right. That's what I said too. The original comment says ".....JVM is virtual mechine which is compile the code..." and I corrected it, because that's wrong.
@@nationfirst640 I don't want to disappoint you. "Yes. I am the best developer in this entire universe. You are all subordinates to me. You should listen whatever I said to you."
Nowadays they expect spring, spring boot,hibernate and microservices knowledge from a fresher. They are not even shortlisting resumes of those who only knows core java.
If we have to store homogeneous objects or fixed size we can prefer array and opposite of that if we want to store heterogenous object with dynamic content we can use arraylist.
Subclass exception type should be defined first that means in first catch block we have to define Arithmetic exception and in the next catch block we have to define superclass exception type that we can say like try{ Exception causing statements } catch(ArithmeticExc.. e) { Sopl("handled"); } catch(Exception e) { Sopl("Exception handled"); } Once the exception handled control doesn't go back to try block to check remaining statements. Statements after exception handling mechanisms will then get executed.
Array doesn't based on Some standard data structures,so predefine method support not present in case of arrays like Arraylist have .....Array is type safe and faster then Arraylist...
We can hire you .....but along with java you atleast must have 30 years of programming experience in dart, php, python, javascript, typescript with no expectations......you must have a really high knowledge in AWS, firebase Along with it you must have advance knowledge about mysql, all the nosql's available in the market, cloud databases, and relational databases You must have a deep knowledge and atleast around 400 projects with frameworks like react, flutter, django, flask, express You must know how to handle a large Team with a members of only you(as we are short on staff), when we provide you 30 projects together If you think you are capable on working under these conditions....we are happy to hire you with a monthly salary of 5000 Feel free to contact us
If any relation between exception then child class exception should write in upper and parent class should write lower otherwise it will give COMPILE ERROR...
10:00 case1 - --------- If the Superclass is mentioned in the 1st catch block and ArithmeticException is defined in the 2nd catch block Result - CE : exception ArithmeticException has already been caught catch(ArithmeticException ae) ============================================== case2 - ----------- If the Superclass is mentioned in the 2nd catch block and ArithmeticException is defined in the 1st catch block Result: No CE Error Just the statements mentioned in the ArithmeticException of the 1st catch block will be matched and executed
One interview I did, by the end I had literally created an app for the company. I didn't get the job but I found out that they took the app and made millions of dollars from it. 😄
yes you are but they don't onboarding freshers cause of recession it may take upto 4 months to onboard freshers if you are selected to wipro elite. all the best
His eye contact is not that great...i used to be like him...but later i improved my eye contact...but his communication skills and knowledge is good 👌🏻
we must pass a try and catch exception in our code. For example, a = 10; b = 5; c = 5; result = a/(b-c); The result is not possible since nothing can be divided by zero. So we need to write a catch statement calling the ArithmeticException so it can just skip the result when the denominator gets 0.
Jsp and servlet is no more used in the industry almost dead, its time of AI,jdk.11,spring boot, kafka,Angular and microservices etc. lockdown questions are very basic and even ppl got seleted
In stand alone applications main method is required, but in web or enterprise application which is not required because the whole execution will depend on web server we use
correct...it's just for educational purposes....i have seen a similar SQL interview where Vishal was the interviewer and the candidate was someone else