




























































































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
QUESTION BANK 2MARKS ONLY FOR FINAL EXAMS
Typology: Exams
1 / 166
This page cannot be seen from the preview
Don't miss anything!
Compiler and Interpreter C++ uses compiler only. C++ is compiled and run using the compiler which converts source code into machine code so, C++ is platform dependent. Java uses compiler and interpreter both. Java source code is converted into bytecode at compilation time. The interpreter executes this bytecode at runtime and produces output. Java is interpreted that is why it is platform independent. Call by Value and Call by reference C++ supports both call by value and call by reference. Java supports call by value only. There is no call by reference in java. Structure and Union C++ supports structures and unions. Java doesn't support structures and unions. Thread Support C++ doesn't have built-in support for threads. It relies on third-party libraries for thread support. Java has built-in thread support. Documentation comment C++ doesn't support documentation comment. Java supports documentation comment (/** ... */) to create documentation for java source code. Virtual Keyword C++ supports virtual keyword so that we can decide whether or not override a function. Java has no virtual keyword. We can override all non-static methods by default. In other words, non- static methods are virtual by default. unsigned right shift >>> C++ doesn't support >>> operator. Java supports unsigned right shift
operator that fills zero at the top for the negative numbers. For positive numbers, it works same like >> operator. Inheritance Tree C++ creates a new inheritance tree always. Java uses a single inheritance tree always because all classes are the child of Object class in java. The object class is the root of the inheritance tree in java. Hardware C++ is nearer to hardware. Java is not so interactive with hardware. Object-oriented C++ is an object-oriented language. However, in C Java is also an object- oriented language. However,
o High Performance: Java is faster than other traditional interpreted programming languages because Java bytecode is "close" to native code. It is still a little bit slower than a compiled language (e.g., C++). o Multithreaded: We can write Java programs that deal with many tasks at once by defining multiple threads. The main advantage of multi-threading is that it doesn't occupy memory for each thread. It shares a common memory area. Threads are important for multi-media, Web applications, etc. o Distributed: Java is distributed because it facilitates users to create distributed applications in Java. RMI and EJB are used for creating distributed applications. This feature of Java makes us able to access files by calling the methods from any machine on the internet. o Dynamic: Java is a dynamic language. It supports dynamic loading of classes. It means classes are loaded on demand. It also supports functions from its native languages, i.e., C and C++.
JRE stands for Java Runtime Environment. It is the implementation of JVM. The Java Runtime Environment is a set of software tools which are used for developing Java applications. It is used to provide the runtime environment. It is the implementation of JVM. It physically exists. It contains a set of libraries + other files that JVM uses at runtime. JDK JDK is an acronym for Java Development Kit. It is a software development environment which is used to develop Java applications and applets. It physically exists. It contains JRE + development tools. JDK is an implementation of any one of the below given Java Platforms released by Oracle Corporation: o Standard Edition Java Platform o Enterprise Edition Java Platform o Micro Edition Java Platform More Details.
Yes, Java allows to save our java file by .java only, we need to compile it by javac .java and run by java classname Let's take a simple example:
o Public The classes, methods, or variables which are defined as public, can be accessed by any class or method. o Protected Protected can be accessed by the class of the same package, or by the sub- class of this class, or within the same class. o Default Default are accessible within the package only. By default, all the classes, methods, and variables are of default scope. o Private The private class, methods, or variables defined as private can be accessed within the class only.
Explanation: In the above class, you are not creating any constructor, so compiler provides you a default constructor. Here 0 and null values are provided by default constructor. More Details.
The constructor name must be same as the class name. The method name may or may not be same as class name.
More Details.