[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"detail-sidebar-cat-0-en-105":3,"doc-seo-391200-105":59,"doc-detail-391200-en":130},{"code":4,"msg":5,"data":6},0,"success",[7,13,18,23,28,33,38,43,48,51,55],{"id":8,"doc_module":4,"doc_module_name":9,"category_name":10,"show_sort_weight":11,"slug":12},1,"Document","Story & Novel",90,"story-novel",{"id":14,"doc_module":4,"doc_module_name":9,"category_name":15,"show_sort_weight":16,"slug":17},2,"Literature",80,"literature",{"id":19,"doc_module":4,"doc_module_name":9,"category_name":20,"show_sort_weight":21,"slug":22},4,"Exam",70,"exam",{"id":24,"doc_module":4,"doc_module_name":9,"category_name":25,"show_sort_weight":26,"slug":27},5,"Comic",60,"comic",{"id":29,"doc_module":4,"doc_module_name":9,"category_name":30,"show_sort_weight":31,"slug":32},6,"Technology",50,"technology",{"id":34,"doc_module":4,"doc_module_name":9,"category_name":35,"show_sort_weight":36,"slug":37},7,"Healthcare",40,"healthcare",{"id":39,"doc_module":4,"doc_module_name":9,"category_name":40,"show_sort_weight":41,"slug":42},8,"Research & Report",30,"research-report",{"id":44,"doc_module":4,"doc_module_name":9,"category_name":45,"show_sort_weight":46,"slug":47},9,"Religion & Spirituality",20,"religion-spirituality",{"id":46,"doc_module":4,"doc_module_name":9,"category_name":49,"show_sort_weight":46,"slug":50},"World Cup","world-cup",{"id":52,"doc_module":4,"doc_module_name":9,"category_name":53,"show_sort_weight":52,"slug":54},10,"Lifestyle","lifestyle",{"id":56,"doc_module":4,"doc_module_name":9,"category_name":57,"show_sort_weight":24,"slug":58},19,"General","general",{"code":4,"msg":60,"data":61},"ok",{"site_id":62,"language":63,"slug":64,"title":65,"keywords":66,"description":67,"schema_data":68,"social_meta":123,"head_meta":125,"extra_data":127,"updated_unix":129},105,"en","java-mcq-questions-and-answers-basic-to-advanced","Java MCQ Questions and Answers - Basic to Advanced","","Java programming multiple-choice questions and answers focused on core to advanced concepts for interview, placement, and competitive-exam preparation. Covers fundamentals such as primitive data types, automatic type conversion, arrays, packages, static methods, and common Java APIs, then moves to deeper topics including constructors, object creation with new, access modifiers, exception handling, system classes, interfaces, and operators. Designed as a quick practice set with step-by-step outputs and explanations.",{"@graph":69,"@context":122},[70,84,105],{"@type":71,"itemListElement":72},"BreadcrumbList",[73,77,79,82],{"item":74,"name":75,"@type":76,"position":8},"https://docshare.wps.com","Home","ListItem",{"item":78,"name":9,"@type":76,"position":14},"https://docshare.wps.com/document/",{"item":80,"name":20,"@type":76,"position":81},"https://docshare.wps.com/document/exam/",3,{"item":83,"name":65,"@type":76,"position":19},"https://docshare.wps.com/document/java-mcq-questions-and-answers-basic-to-advanced/391200/",{"url":83,"name":65,"@type":85,"image":86,"author":91,"headline":65,"publisher":94,"fileFormat":97,"inLanguage":63,"description":67,"dateModified":98,"datePublished":99,"encodingFormat":97,"isAccessibleForFree":100,"interactionStatistic":101},"DigitalDocument",{"url":87,"@type":88,"width":89,"height":90},"https://docshare.wps.com/thumbnails/java-mcq-questions-and-answers-basic-to-advanced/391200.png","ImageObject",300,407,{"name":92,"@type":93},"Asher","Person",{"url":74,"name":95,"@type":96},"DocShare","Organization","application/pdf","2026-10-30","2026-09-25",true,{"@type":102,"interactionType":103,"userInteractionCount":52},"InteractionCounter",{"@type":104},"ViewAction",{"@type":106,"mainEntity":107},"FAQPage",[108,114,118],{"name":109,"@type":110,"acceptedAnswer":111},"How many primitive data types are there in Java according to the MCQs?","Question",{"text":112,"@type":113},"The question lists options and the answer given is 8 (option c).","Answer",{"name":115,"@type":110,"acceptedAnswer":116},"What is the array reference received by a method when an array is passed?",{"text":117,"@type":113},"The MCQ states that the method receives the reference of the array (option a).",{"name":119,"@type":110,"acceptedAnswer":120},"Which exception is thrown when a program divides by zero?",{"text":121,"@type":113},"The MCQ indicates ArithmeticException is thrown when dividing by zero (option c).","https://schema.org",{"og:url":83,"og:type":124,"og:title":65,"og:site_name":95,"og:description":67},"article",{"robots":126,"canonical":83},"index,follow",{"doc_id":128,"site_id":62},391200,1790694841,{"code":4,"msg":5,"data":131},{"doc_id":128,"user_id":132,"nickname":92,"user_avatar":133,"doc_module":4,"category_id":19,"category_name":20,"doc_title":65,"doc_description":67,"doc_content":134,"file_id":135,"file_url":136,"file_type":137,"file_size":138,"view_count":52,"is_deleted":4,"is_public":8,"is_downloadable":8,"audit_status":8,"page_count":14,"language":139,"language_code":63,"site_id":62,"html_lang":63,"table_of_contents":140,"faqs":141,"seo_title":142,"seo_description":67,"update_tm":143,"read_time":24,"preview_page_count":4},687197207639,"https://ap-avatar.wpscdn.com/davatar_a8503ba1806abce46bf441b54a3ca4cd","Java programming multiple choice questions and answers pdf  \nJava MCQ Questions and answers. Important basic to advance MCQs for freshers interview placement and Competitive Exam’s preparation with PDF Download. Helpful for TCS, Wipro, COPA, Virtusa, DCA, Wings, infytq and other exam. Java MCQ Questions and answers 1. Number of primitive data types in Java are? a) 6 b) 7 c) 8 d) 9 Ans. c  \n2. What is the size of float and double in Java? a) 32 and 64 b) 32 and 32 c) 64 and 64 d) 64 and 32 Ans. a 3. Automatic type conversion is possible in which of the possible cases? a) Byte to int b) Int to long c) Long to int d) Short to int Ans. b 4.  \nFind the output of the [following code. int](following code. int) Integer = 24; char String = ‘I’; System.out.print(Integer); System.out.print(String); a) Compile error b) Throws exception c) I d) 24 I Ans. d 5. Select the valid statement. a) char[] ch = new char(5) b) char[] ch = new char[5] c) char[] ch = new char() d) char[] ch = new char[] Ans. b 6. When an array is passed  \nto a method, what does the method receive? a) The reference of the array b) A copy of the array c) Length of the array d) Copy of the first element Ans. a 7. Select the valid statement to declare and initialize an array. a) int [] A = {} b) int [] A = {1, 2, 3} c) int [] A = (1, 2, 3) d) int [][] A = {1, 2, 3} Ans. b 8. Arrays in java are-a) Object references b) objects c) Primitive data type d) None Ans. b 9. When is the object created with new keyword? a) At run time b) At compile time c) Depends on the code d) None Ans. a 10. Identify the correct definition of a package. a) A package is a collection of editing tools b) A package is a collection of classes c) A package is a collection of classes and interfaces d) A package is a collection of interfaces Ans. c 11. Identify the correct restriction on static methods. i) They must access only static data ii) They can only call other static methods iii) They cannot refer to this or super a) I and ii b) iiand iii c) Only iii d) I, ii and iii Ans. d 12. Identify the keyword among the following that makes a variable belong to a class, rather than being defined for each instance of the class. a) final b) static c) volatile d) abstract Ans. b 13. In which of the following is toString() method defined? a) java.lang.Object b) java.lang. String c) java.lang.util d) None Ans. a 14. CompareTo() returns a) True b) False c) An int value d) None Ans.  \nc 15. Identify the output of the following program. String str = “Hellow”; System.out.println(str.indexOf(‘t)); a) 0 b) 1 c) True d) -1 Ans. d (Since, t isn’t present in the string str, it returns-1 . ) 16. To which of the following does the class string belong to. a) java.lang b) java.awt c) java.applet d) java.string Ans. a 17. How many objects will be created in the following? String a = new String(“heetson”); String b = new String(“heetson”); Strinc c = “heetson”; String d = “heetson”; a) 2 b) 3 c) 4 d) None Ans. b Explanation: Using the new keyword creates an object everytime. Hence, 2 objects are created for first two statement. Next, a string is declared which creates another object. For the fourth  \nstatement, since, a string ”heetson” already exists, it doesn’t create an additional object again. Hence, answer is 3. 18. Total constructor string class have? a) 3 b) 7 c) 13 d) 20 Ans. c 19. Find the output of the [following code. int](following code. int) ++a = 100; System.out.println(++a); a) 101 b) Compile error as ++a is not valid identifier c) 100 d) None Ans. b 20.  \nIdentify the return type of a method that does not return any value. a) int b) void c) double d) None Ans. b 21. Output of Math.floor(3 .6) is a) 3 b) 3.0 c) 4 d) 4.0 Ans.  \nb (floor returns largest integer that is less than or equal to the given number. ) 22. Where does the system stores parameters and local variables whenever a method is invoked? a) Heap b) Stack c) Array d) Tree Ans. b 23. Identify the modifier which cannot be used for constructor. a) public ","cbCaimiybBrFBtQc","https://ap.wps.com/l/cbCaimiybBrFBtQc","pdf",92856,"English","# Java MCQ Questions and Answers\n## Data types, type conversion, and basics\n## Arrays, packages, and OOP concepts\n## Constructors and string/class behavior\n## Operators and utility methods\n## Exceptions and access rules","[{\"question\":\"How many primitive data types are there in Java according to the MCQs?\",\"answer\":\"The question lists options and the answer given is 8 (option c).\"},{\"question\":\"What is the array reference received by a method when an array is passed?\",\"answer\":\"The MCQ states that the method receives the reference of the array (option a).\"},{\"question\":\"Which exception is thrown when a program divides by zero?\",\"answer\":\"The MCQ indicates ArithmeticException is thrown when dividing by zero (option c).\"}]","Java MCQ Questions and Answers - Basic to Advanced | PDF",1790350021]