d. If a is false and b is false then the output is "ELSE" Answer?

Similar documents
1)Write a program on inheritance and check weather the given object is instance of a class or not?

1.Which four options describe the correct default values for array elements of the types indicated?

Tutorial 8 Date: 15/04/2014

Lara Technologies Special-Six Test

CS 200 Command-Line Arguments & Exceptions Jim Williams, PhD

Birkbeck (University of London) Software and Programming 1 In-class Test Mar 2018

Operators Questions

Introduction to Computer Science Unit 2. Exercises

2. How many runtime error messages associated with exception? a) 2 b) 4 c) 5 d) infinite

C212 Early Evaluation Exam Mon Feb Name: Please provide brief (common sense) justifications with your answers below.

1. What details should never be found in the top level of a top-down design?

Chapter 3. Selections

1. Short circuit AND (&&) = if first condition is false then the second is never evaluated

SECTION-1 Q.1.Which two code fragments are most likely to cause a StackOverflowError? (Choose two.)

Sequence structure. The computer executes java statements one after the other in the order in which they are written. Total = total +grade;

CIS October 16, 2018

1. Find the output of following java program. class MainClass { public static void main (String arg[])

Questions and Answers. Q.3) asses is not part of Java's collection framework?explanation:

Spring University of New Mexico CS152 Midterm Exam. Print Your Name

I pledge by honor that I will not discuss this exam with anyone until my instructor reviews the exam in the class.

CIS265 - Spring Exam 2 First Name Last Name CSU#

Computer Programming, I. Laboratory Manual. Final Exam Solution

public class Test { static int age; public static void main (String args []) { age = age + 1; System.out.println("The age is " + age); }

Solution to Test of Computer Science 203x Level Score: / 100 Time: 100 Minutes

Java Identifiers, Data Types & Variables

Module 4 - 异常和断言 一 选择题 :

LARA TECHNOLOGIES EXAM_SPECIALSIX SECTION-1

CIS October 19, 2017

Vendor: Oracle. Exam Code: 1Z Exam Name: Java SE 8 Programmer. Version: Demo

CIS March 1, 2018

Some Practice Midterm Problems

Introduction to Java

CHETTINAD COLLEGE OF ENGINEERING & TECHNOLOGY JAVA

JAVA Programming Language Homework II Student ID: Name:

CONDITIONAL EXECUTION

AP COMPUTER SCIENCE JAVA CONCEPTS IV: RESERVED WORDS

University of Palestine. Mid Exam Total Grade: 100

Java Programming Language Mr.Rungrote Phonkam

AP COMPUTER SCIENCE A

Class, Variable, Constructor, Object, Method Questions

For more details on SUN Certifications, visit

WOSO Source Code (Java)

PROGRAMMING FUNDAMENTALS

CSC 1051 Algorithms and Data Structures I. Final Examination May 12, Name

AP CS Unit 8: Inheritance Exercises

public class B { private int f = 0; public static void main(string[] args) { B b1 = new B(); B b2 = new B(); Object b3 = b1;

CIS 120 Programming Languages and Techniques. Midterm II. November 12, 2010

Fundamentals of Object Oriented Programming

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)

Program Fundamentals

Object-Oriented Programming

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

1. Java is a... language. A. moderate typed B. strogly typed C. weakly typed D. none of these. Answer: B

CSE 143 SAMPLE MIDTERM

COE318 Lecture Notes Week 10 (Nov 7, 2011)

Java provides a rich set of operators to manipulate variables. We can divide all the Java operators into the following groups:

Birkbeck (University of London) Software and Programming 1 In-class Test Mar Answer ALL Questions

CSCD 326 Data Structures I Stacks

Array. Array Declaration:

Following is the general form of a typical decision making structure found in most of the programming languages:

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

Sun Certified Programmer for Java 2 Platform 1.4. Version 3.0

ITI Introduction to Computing II

CSE 8B Final Exam Fall 2015

RZQ 12/19/2008 Page 1 of 11

JAVA OPERATORS GENERAL

CS Week 5. Jim Williams, PhD

CIS 120 Programming Languages and Techniques. Midterm II. November 12, Answer key

Day 2 : Intermediate Concepts 1 Examples

CSC System Development with Java. Exception Handling. Department of Statistics and Computer Science. Budditha Hettige

Oracle 1Z Java SE 8 Programmer I. Download Full Version :

CS 307 Midterm 2 Spring 2011

NATIONAL UNIVERSITY OF SINGAPORE

Chapter 1: Introduction to Computers, Programs, and Java

6 COMPUTER PROGRAMMING

The Java language has a wide variety of modifiers, including the following:

09/08/2017 CS2530 INTERMEDIATE COMPUTING 9/8/2017 FALL 2017 MICHAEL J. HOLMES UNIVERSITY OF NORTHERN IOWA TODAY S TOPIC: Exceptions and enumerations.

Brief Summary of Java

Methods. Methods. Wolfgang Schreiner Research Institute for Symbolic Computation (RISC) Johannes Kepler University, Linz, Austria

CS180. Exam 1 Review

CSC Java Programming, Fall Java Data Types and Control Constructs

Introduction. Exceptions: An OO Way for Handling Errors. Common Runtime Errors. Error Handling. Without Error Handling Example 1

Outline. Parts 1 to 3 introduce and sketch out the ideas of OOP. Part 5 deals with these ideas in closer detail.

b. Suppose you enter input from the console, when you run the program. What is the output?

Interfaces, collections and comparisons

2018/2/5 话费券企业客户接入文档 语雀

Introduction to Programming Using Java (98-388)

Software Practice 1 - Basic Grammar Basic Syntax Data Type Loop Control Making Decision

S.E. Sem. III [CMPN] Object Oriented Programming Methodology

Self-test Java Programming

Computer Programming, I. Laboratory Manual. Experiment #3. Selections

More types, Methods, Conditionals. ARCS Lab.

Selenium Class 9 - Java Operators

Student s Number: This exam consists of 30 multiple choice questions. Mark your answer to each question in the space provided on this page.

Java provides a rich set of operators to manipulate variables. We can divide all the Java operators into the following groups:

CSE 142 Sample Final Exam #1 (based on Spring 2005's final; thanks to Stuart Reges)

Object-Oriented Programming. Topic 2: Fundamental Programming Structures in Java

CMSC 331 Second Midterm Exam

CS 152 Computer Programming Fundamentals The if-else Statement

Midterm Exam CS 251, Intermediate Programming March 6, 2015

Transcription:

Intermediate Level 1) Predict the output for the below code: public void foo( boolean a, boolean b) if( a ) System.out.println("A"); if(a && b) System.out.println( "A && B"); if (!b ) System.out.println( "notb") ; System.out.println( "ELSE" ) ; a. If a is true and b is true then the output is "A && B" b. If a is true and b is false then the output is "notb" c. If a is false and b is true then the output is "ELSE" d. If a is false and b is false then the output is "ELSE" Answer? 2) What is the output of this program? class Test public static void main(string args[]) int x, y = 1; x = 10; if (x!= 10 && x / 0 == 0) System.out.println(y); System.out.println(++y);

a) 1 b) 2 c) Runtime error owing to division by zero in if condition. d) Unpredictable behavior of program. Answer? 3) what is the output of this program? class SelectionStatements public static void main(string args[]) int var1 = 5; int var2 = 6; if ((var2 = 1) == var1) System.out.print(var2); System.out.print(++var2); a) 1 b) 2 c) 3 d) 4 Answer? 4) write a program on inheritance where by creating an object and initialize data in it? Class Test final int res(int a, int b) return 0; Class Test1 extends Test final int res(int a, int b)

return 1; Class x Test1 tes=new Test1(); System.out.println(tes.res(0,1)); a) 0 b) 1 c) compile error d) exception Answer? 5).Program on calling a method from static block accessing the data. class Test Static Test t=new Test(); t.talk(); public static void main(string args[]) Test y=new Test(); y.name; y.age; String name= abc ; private int age=20; void talk() System.out.println(name+ +age);

a) abc 20 b) null null 0 abc 20 c) abc 20 d) compiler error abc 20 Answer? 6)write a program to accept the data from out side of class. class Test int x=5; Test(int x) this.x=x; static void access() System.out.print(x); class x Test obj=new Test(55); Test.access(); a) 55 b) 5 c) compile error d) run-time error Answer? 7. What will be the output of the program? public class X public static void main(string [] args)

try badmethod(); System.out.print("A"); catch (RuntimeException ex) /* Line 10 */ System.out.print("B"); catch (Exception ex1) System.out.print("C"); finally System.out.print("D"); System.out.print("E"); public static void badmethod() throw new RuntimeException(); a) BD b) BCD c) BDE d) BCDE Answer?

8.given program is used to handle the code by throwing a user defined exception public class Test public static void mymethod() throws Exception try throw new exception(); finally System.out.print( finally ); public static void main(string args[]) try mymethod(); catch(exception e) System.out.println( Exception ); System.out.print( finally ); a) finally b) exception c) finally exception d) compiler error Answer? 9.Find the output for this code?

Class Deccansoft public static void main(string args[]) ListIterator a =List.listIterator(); if(a.previousindex()!=-1) while(a.hasnext()) System.out.println(a.next()+ ); System.out.print( empty ); a) 0 b) 1 c) -1 d) empty Answer? 10. Find the output for this code? Class Deccansoft public static void main(string args[]) LinkedList list= new LinkedList(); List.add(new Integer(2)); list.add(new Integer(8)); list.add(new Integer(5)); list.add(new Integer(1)); Iterator i=list.iterator(); Collections.reverse(list); i.next(); i.remove(); while(i.hasnext()) System.out.println(i.next()+ );

a) 2 8 5 b) 2 1 8 c) 2 5 8 d) 8 5 1 Answer? 11) Which of the following statements are true? a) UTF characters are all 8-bits. b) UTF characters are all 16-bits. c) UTF characters are all 24-bits. d) Unicode characters are all 16-bits. Answer? 12) What is Serialization and deserialization? a) Serialization is the process of writing the state of an object to a byte stream. b) It is the process of restoring these objects. c) Combination of a and 'b' d) None of the above. Answer? 13) What is the Message is displayed in the applet made by this program? import java.awt.*; import java.applet.*; public class myapplet extends Applet public void paint(graphics g) g.drawstring("a Simple Applet", 20, 20); a) A Simple Applet

b) A Simple Applet 20 20 c) Compilation Error d) Runtime Error Answer? 14. The method when used in the method field, leaves entity body empty. a) POST b) GET c) Both of the mentioned d) None of the mentioned Answer? 15. Which of the following is present in both an HTTP request line and a status line? a) HTTP version number b) URL c) Method d) None of the mentioned Answer?