write the functions inside as well as outside the class. So in C++, they are called member functions and not methods.

Similar documents
Sri Vidya College of Engineering & Technology

15CS45 : OBJECT ORIENTED CONCEPTS

CS 231 Data Structures and Algorithms, Fall 2016

Index COPYRIGHTED MATERIAL

JAVA MOCK TEST JAVA MOCK TEST II

STRUCTURING OF PROGRAM

Index. Course Outline. Grading Policy. Lab Time Distribution. Important Instructions

Introduction to Programming Using Java (98-388)

CS321 Languages and Compiler Design I. Winter 2012 Lecture 2

Java Basics. Object Orientated Programming in Java. Benjamin Kenwright

2 rd class Department of Programming. OOP with Java Programming

JAVASCRIPT AND JQUERY: AN INTRODUCTION (WEB PROGRAMMING, X452.1)

Contents. Figures. Tables. Examples. Foreword. Preface. 1 Basics of Java Programming 1. xix. xxi. xxiii. xxvii. xxix

1 Shyam sir JAVA Notes

1 Epic Test Review 2 Epic Test Review 3 Epic Test Review 4. Epic Test Review 5 Epic Test Review 6 Epic Test Review 7 Epic Test Review 8

Introduction to Object-Oriented Programming

STUDY NOTES UNIT 1 - INTRODUCTION TO OBJECT ORIENTED PROGRAMMING

20 Most Important Java Programming Interview Questions. Powered by

An overview of Java, Data types and variables

Outline. Object Oriented Programming. Course goals. Staff. Course resources. Assignments. Course organization Introduction Java overview Autumn 2003

DOWNLOAD PDF CORE JAVA APTITUDE QUESTIONS AND ANSWERS

Getting started with Java

Computer Programming C++ (wg) CCOs

Java Class Design. Eugeny Berkunsky, Computer Science dept., National University of Shipbuilding

What are the characteristics of Object Oriented programming language?

Syllabus & Curriculum for Certificate Course in Java. CALL: , for Queries

JAVA: A Primer. By: Amrita Rajagopal

Java Language Basics: Introduction To Java, Basic Features, Java Virtual Machine Concepts, Primitive Data Type And Variables, Java Operators,

Lecture 2. COMP1406/1006 (the Java course) Fall M. Jason Hinek Carleton University

Computer Components. Software{ User Programs. Operating System. Hardware

Object Oriented Programming with Java. Unit-1

Introduction to Visual Basic and Visual C++ Introduction to Java. JDK Editions. Overview. Lesson 13. Overview

CONTENTS. PART 1 Structured Programming 1. 1 Getting started 3. 2 Basic programming elements 17

Chapter 5 Names, Bindings, Type Checking, and Scopes

CS5000: Foundations of Programming. Mingon Kang, PhD Computer Science, Kennesaw State University

Introduction to Java

5/23/2015. Core Java Syllabus. VikRam ShaRma

CPSC 3740 Programming Languages University of Lethbridge. Data Types

Outline. Java Models for variables Types and type checking, type safety Interpretation vs. compilation. Reasoning about code. CSCI 2600 Spring

Lecture 7: Data Abstractions

Java Intro 3. Java Intro 3. Class Libraries and the Java API. Outline

Intro to Computer Science II

Java language. Part 1. Java fundamentals. Yevhen Berkunskyi, NUoS

Weiss Chapter 1 terminology (parenthesized numbers are page numbers)

OBJECT ORIENTED PROGRAMMING TYm. Allotted : 3 Hours Full Marks: 70

Expressions and Data Types CSC 121 Fall 2015 Howard Rosenthal

CS 265. Computer Architecture. Wei Lu, Ph.D., P.Eng.

Core Java Contents. Duration: 25 Hours (1 Month)

Data Abstraction. Hwansoo Han

Compiling Techniques

Assoc. Prof. Dr. Marenglen Biba. (C) 2010 Pearson Education, Inc. All rights reserved.

Object Oriented Programming. C++ 6 th Sem, A Div Ms. Mouna M. Naravani

Presented By : Gaurav Juneja

3. Java - Language Constructs I

5/3/2006. Today! HelloWorld in BlueJ. HelloWorld in BlueJ, Cont. HelloWorld in BlueJ, Cont. HelloWorld in BlueJ, Cont. HelloWorld in BlueJ, Cont.

3. Convert 2E from hexadecimal to decimal. 4. Convert from binary to hexadecimal

Reviewing for the Midterm Covers chapters 1 to 5, 7 to 9. Instructor: Scott Kristjanson CMPT 125/125 SFU Burnaby, Fall 2013

Chapter 1: Object-Oriented Programming Using C++

Programming overview

Computer Components. Software{ User Programs. Operating System. Hardware

Expressions and Data Types CSC 121 Spring 2015 Howard Rosenthal

Object Oriented Programming

CS112 Lecture: Variables, Expressions, Computation, Constants, Numeric Input-Output

CS/B.TECH/CSE(New)/SEM-5/CS-504D/ OBJECT ORIENTED PROGRAMMING. Time Allotted : 3 Hours Full Marks : 70 GROUP A. (Multiple Choice Type Question)

Agenda CS121/IS223. Reminder. Object Declaration, Creation, Assignment. What is Going On? Variables in Java

Chapter 2: Using Data

Programming. Syntax and Semantics

Java Programming. Atul Prakash

CS 6456 OBJCET ORIENTED PROGRAMMING IV SEMESTER/EEE

Program Fundamentals

The Sun s Java Certification and its Possible Role in the Joint Teaching Material

Atelier Java - J1. Marwan Burelle. EPITA Première Année Cycle Ingénieur.

F1 A Java program. Ch 1 in PPIJ. Introduction to the course. The computer and its workings The algorithm concept

Page 1. Structure of von Nuemann machine. Instruction Set - the type of Instructions

Character Stream : It provides a convenient means for handling input and output of characters.

Lecture C1 Data Representation. Computing and Art : Nature, Power, and Limits CC 3.12: Fall 2007

PESIT Bangalore South Campus

CSC Java Programming, Fall Java Data Types and Control Constructs

OBJECT ORIENTED PROGRAMMING USING C++ CSCI Object Oriented Analysis and Design By Manali Torpe

JAVA. 1. Introduction to JAVA


CS121/IS223. Object Reference Variables. Dr Olly Gotel

Absolute C++ Walter Savitch

PROGRAMMING FUNDAMENTALS

Core Java Syllabus. Overview

Hexadecimal Numbers. Journal: If you were to extend our numbering system to more digits, what digits would you use? Why those?

Crash Course in Java. Why Java? Java notes for C++ programmers. Network Programming in Java is very different than in C/C++

Introduce C# as Object Oriented programming language. Explain, tokens,

CSC207H: Software Design. Java + OOP. CSC207 Winter 2018

Interview Questions of C++

Chapter 02: Using Data

Defining Classes and Methods

CGS 2405 Advanced Programming with C++ Course Justification

CompuScholar, Inc. Alignment to Nevada "Computer Science" Course Standards

Introduction Basic elements of Java

Atelier Java - J2. Marwan Burelle. EPITA Première Année Cycle Ingénieur.

Java Basic Programming Constructs

Question. 1 Features of Java.

Hierarchical inheritance: Contains one base class and multiple derived classes of the same base class.

12/22/11. Java How to Program, 9/e. Help you get started with Eclipse and NetBeans integrated development environments.

Transcription:

1. Q. Why pointers are eliminated from java? 1)Pointers lead to confusion for a programmer. 2)Pointers may crash a program easily, for example, when we add two pointers, the program crashers immediately. 3)Pointers break security. Using pointers, harmful programs like Virus and other hacking programs can be developed. Because of the above reasons, pointers have been eliminated from java. 2. Q. What is the difference between a function and a method? A method is a function that is written in a class. We do not have functions in java; instead we have methods. This means whenever a function is written in java, it should be written inside the class only. But if we take C++, we can write the functions inside as well as outside the class. So in C++, they are called member functions and not methods. 3. Q. What is an API document? An API document is a.html file that contains description of all the features of a softwar, a product, or a technology. API document is helpful for the user to understand how to use the software or technology. 4. Q. What is the difference between #include and import statement? #include directive makes the compiler go to the C/C++ standard library and copy the code from the header files into the program. As a result, the program size increases, thus wasting memory and processor s time. import statement makes the JVM go to the Java standard library, execute the code there, and substitute the result into the program. Here, no code is copied and hence no waste of memory or processor s time. so import is an efficient mechanism than #include. 5. Q. What is the difference between print() and println() method? Both methods are used to display the results on the monitor. print() method displays the result and then retains the cursor in the same line, next to the end of the result. println() displays the result and then throws the cursor to the next line. 6. Q. What happens if String args[] is not written in main() method? When main() method is written without String args[] as: Public static void main()

The code will compile but JVM cannot run the code because it cannot recognize the main() as the method from where it should start execution of the Java program. Remember JVM always looks for main( ) method with string type array as parameter. 7. Q. What is the difference between float and double? Float can represent up to 7 digits accurately after decimal point, where as double can represent up to 15 digits accurately after decimal point. 8. Q. What is a Unicode system? Unicode system is an encoding standard that provides a unique number for every character, no matter what the platform, program, or language is. Unicode uses 2 bytes to represent a single character. 9. Q. How are positive and negative numbers represented internally? Positive numbers are represented in binary using 1 s complement notation and negative numbers are represented by using 2 s complement notation. 10. Q. What are control statements Control statements are the statements which alter the flow of execution and provide better control to the programmer on the flow of execution. They are useful to write better and complex programs. 11. Q. Out of do While and while which loop is efficient? In a do..while loop, the statements are executed without testing the condition, the first time. From the second time only the condition is observed. This means that the programmer does not have control right from the beginning of its execution. In a while loop, the condition is tested first and then only the statements are executed. This means it provides better control right from the beginning. Hence, while loop is move efficient than do.. while loop. 12. Q. What is a collection? A collection represents a group of elements like integer values or objects. Examples for collectionsare arrays and java.util_classes (stack, LinkedList, ;Vector, etc).

13. Q. Why goto statements are not available in Java? Goto statements lead to confusion for a programmer. Especially in a large program, if several goto statements are used, the programmer would be perplexed while understanding the flow from where to where the control is jumping. 14. Q. On which memory, arrays are created in Java? Arrays are created on dynamic memory by JVM. There is no question of static memory in Java; every thing( variables, array, object etc.) is created on dynamic memory only. 15. Q. Can you call the main( ) method of a class from another class? Yes, we can call the main( ) method of a class from another class using Classname.main(). At the time of calling the main() method, we should pass a string type array to it. 16. Q. Is String a class or data type? String is a class in java.lang package. But in Java, all classes are also considered as data types. So we can take String as a data type also. 17. Q. Can we call a class as a data type? Yes, a class is also called user-defined data type. This is because a use can create a class. 18. Q. What is object reference? Object reference is a unique hexadecimal number representing the memory address of the object. It is useful to access the members of the object. 19. Q. What is difference between == and equals( ) while comparing strings.which one is reliable? == operator compares the references of the sting objects. It does not compare the contents of the objects. equals ( ) method compares the contents. While comparing the strings, equals( ) method should be used as it yields the correct result.

20. Q. What is a string constant pool? Sring constant pool is a separate block of memory where the string objects are held by JVM. If a string object is created directly, using assignment operator as: String s1 = Hello,then it is stored in string constant pool. 21. Q. Explain the difference between the following two statements: 1. String s= Hello 2. String s = new String ( Hello ); In the first statement, assignment operator is used to assign the string literal to the String variable s. In this case, JVM first of all checks whether the same object is already available in the string constant pol. If it is available, then it creates another reference to it. If the same object is not available, then it creates another object with the content Hello and stores it into the string constant pool. 1. In the second statement, new operator is used to create the string object; in this case, JVM always creates a new object without looking in the string constant pool. 2. Q. What is the difference between String and StringBuffer classes? String class objects are immutable and hence their contents cannot be modified. StringBuffer class objects are mutable, so they can be modified. Moreover the methods that directly manipulate data of the object are not available in String class. Such methods are available in StringBuffer class. 3. Q. Are there any other classes whose objects are immutalbe? Yes, classes like Character, Byte, Integer, Float, Double, Long..called wrapper classes are created as immutable.classes like Class, BigInteger, Big Decimal are also immutable. 4. Q. What is object oriented approach? Object oriented programming approach is a programming methodology to design computer programs using classes and objects. 5. Q. What is the difference between a class and an object? A class is a model for creating objects and does not exist physically. An object is any thing that exists physically.both the classes and objects contain variables and methods. 6. Q. What is encapsulation? Encapsulation is a mechanism where the data(varialbes) and the code(methods) that act on the data will bind together. For ex,if we take a class, we write the variables and methods inside the class. Thus, class is binding them together. So class is an example for encapsultion.

7. Q. What is abstraction? Hiding the unnecessary data from the user and expose only needed data is of interest to the user. A good example for abstraction is a car. Any car will have some parts like engine, radiator, mechanical and electrical equipment etc. The user of the car (driver) should know how to drive the car and does not require any knowledge of these parts. For example driver is never bothered about how the engine is designed and the internal parts of the engine. This is why, the car manufacturers hide these parts from the driver in a separate panel, generally at the front. Example in java: 8. Class Bank{Private intaccno; Private String name; Private floatbalance; Private floatprofit; Private floatloan; Public voiddesplay_to _clerk(){ System.out.println( Accno= +accno); System.out.println( Name= +name); System.out.println( Balance= +balance); } }

9. Q. What is Inheritance? It creates new classes from existing classes, so that the new classes will acquire all the features of the existing classes is called inheritance. (or) Acquiring the all properties from base class to child class. 10. Q. What is Polymorphism? The word Polymorphism came from two Greek words poly meaning many and morphs meaning forms. Thus, polymorphism represents the ability to assume several different forms. In programming, we can use a single variable to refer to objects of different types and thus, using that variable we can call the methods of the different objects. Thus a method call can perform different tasks depending on the type of the object. 11. Q. What is the difference between object oriented programming launguages and object based programming languages? Object oriented programming languages follow all the features of Object Oriented Programming System(OOPS). Smalltalk, Simula-67,C++, Java are examples for OOPS languages. Object based programming languages follow all the features of OOPS except Inheritance. For example, JavaScript and VBScript will come under object based programming languages.